1 #ifndef _MTPFS_H_ 2 #define _MTPFS_H_ 3 4 #ifdef HAVE_CONFIG_H 5 #include "config.h" 6 #endif 7 8 #ifdef linux 9 /* For pread()/pwrite() */ 10 #define _XOPEN_SOURCE 500 11 #endif 12 13 #include <fuse.h> 14 #include <stdio.h> 15 #include <string.h> 16 #include <unistd.h> 17 #include <fcntl.h> 18 #include <dirent.h> 19 #include <errno.h> 20 #include <sys/mount.h> 21 22 #include <libmtp.h> 23 #include <glib.h> 24 #include <sys/mman.h> 25 #include <strings.h> 26 #ifdef USEMAD 27 #include <mad.h> 28 #include <id3tag.h> 29 #include "id3read.h" 30 #endif 31 32 typedef struct 33 { 34 LIBMTP_devicestorage_t *storage; 35 LIBMTP_folder_t *folders; 36 gboolean folders_changed; 37 } StorageArea; 38 39 /* Function declarations */ 40 41 /* local functions */ 42 static LIBMTP_filetype_t find_filetype (const gchar * filename); 43 static int lookup_folder_id (LIBMTP_folder_t * folderlist, gchar * path, 44 gchar * parent); 45 static int parse_path (const gchar * path); 46 static void check_lost_files (); 47 void check_folders (); 48 static int find_storage (const gchar * path); 49 50 /* fuse functions */ 51 static void *mtpfs_init (void); 52 static int mtpfs_blank (); 53 static int mtpfs_release (const char *path, struct fuse_file_info *fi); 54 void mtpfs_destroy (); 55 static int mtpfs_readdir (const gchar * path, void *buf, 56 fuse_fill_dir_t filler, off_t offset, 57 struct fuse_file_info *fi); 58 static int mtpfs_getattr (const gchar * path, struct stat *stbuf); 59 static int mtpfs_mknod (const gchar * path, mode_t mode, dev_t dev); 60 static int mtpfs_open (const gchar * path, struct fuse_file_info *fi); 61 static int mtpfs_read (const gchar * path, gchar * buf, size_t size, 62 off_t offset, struct fuse_file_info *fi); 63 static int mtpfs_write (const gchar * path, const gchar * buf, size_t size, 64 off_t offset, struct fuse_file_info *fi); 65 static int mtpfs_unlink (const gchar * path); 66 static int mtpfs_mkdir (const char *path, mode_t mode); 67 static int mtpfs_rmdir (const char *path); 68 static int mtpfs_statfs (const char *path, struct statfs *stbuf); 69 int calc_length (int f); 70 71 static LIBMTP_mtpdevice_t *device; 72 static StorageArea storageArea[4]; 73 static LIBMTP_file_t *files = NULL; 74 static gboolean files_changed = TRUE; 75 static GSList *lostfiles = NULL; 76 static GSList *myfiles = NULL; 77 static LIBMTP_playlist_t *playlists = NULL; 78 static gboolean playlists_changed = FALSE; 79 static GMutex device_lock = G_STATIC_MUTEX_INIT; 80 81 #endif /* _MTPFS_H_ */ 82