aboutsummaryrefslogtreecommitdiff
path: root/src/fuse/gnunet-fuse.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/fuse/gnunet-fuse.h')
-rw-r--r--src/fuse/gnunet-fuse.h95
1 files changed, 77 insertions, 18 deletions
diff --git a/src/fuse/gnunet-fuse.h b/src/fuse/gnunet-fuse.h
index d8f567b..99137d8 100644
--- a/src/fuse/gnunet-fuse.h
+++ b/src/fuse/gnunet-fuse.h
@@ -52,8 +52,36 @@ extern const struct GNUNET_CONFIGURATION_Handle *cfg;
52 */ 52 */
53struct GNUNET_FUSE_PathInfo 53struct GNUNET_FUSE_PathInfo
54{ 54{
55
56 /**
57 * All files in a directory are kept in a DLL.
58 */
59 struct GNUNET_FUSE_PathInfo *next;
60
61 /**
62 * All files in a directory are kept in a DLL.
63 */
64 struct GNUNET_FUSE_PathInfo *prev;
65
66 /**
67 * Parent directory, NULL for the root.
68 */
69 struct GNUNET_FUSE_PathInfo *parent;
70
55 /** 71 /**
56 * uri to corresponding path 72 * Head of linked list of entries in this directory
73 * (NULL if this is a file).
74 */
75 struct GNUNET_FUSE_PathInfo *child_head;
76
77 /**
78 * Head of linked list of entries in this directory
79 * (NULL if this is a file).
80 */
81 struct GNUNET_FUSE_PathInfo *child_tail;
82
83 /**
84 * URI of the file or directory.
57 */ 85 */
58 struct GNUNET_FS_Uri *uri; 86 struct GNUNET_FS_Uri *uri;
59 87
@@ -63,14 +91,15 @@ struct GNUNET_FUSE_PathInfo
63 struct GNUNET_CONTAINER_MetaData *meta; 91 struct GNUNET_CONTAINER_MetaData *meta;
64 92
65 /** 93 /**
66 * pathname 94 * Name of the file for this path (i.e. "home"). '/' for the root (all other
95 * filenames must not contain '/')
67 */ 96 */
68 char* path; 97 char *filename;
69 98
70 /** 99 /**
71 * name of temporary file 100 * Name of temporary file, NULL if we never accessed this file or directory.
72 */ 101 */
73 char* tmpfile; 102 char *tmpfile;
74 103
75 /** 104 /**
76 * file attributes 105 * file attributes
@@ -78,12 +107,25 @@ struct GNUNET_FUSE_PathInfo
78 struct stat stbuf; 107 struct stat stbuf;
79 108
80 /** 109 /**
81 * Lock for exclusive access to this struct. 110 * Lock for exclusive access to this struct (i.e. for downloading blocks).
111 * Lock order: always lock parents before children.
82 */ 112 */
83 struct GNUNET_Mutex *lock; 113 struct GNUNET_Mutex *lock;
84 114
85 /** 115 /**
86 * Reference counter. 116 * Beginning of a contiguous range of blocks of the file what we
117 * have downloaded already to 'tmpfile'.
118 */
119 uint64_t download_start;
120
121 /**
122 * End of a contiguous range of blocks of the file what we
123 * have downloaded already to 'tmpfile'.
124 */
125 uint64_t download_end;
126
127 /**
128 * Reference counter (used if the file is deleted while being opened, etc.)
87 */ 129 */
88 unsigned int rc; 130 unsigned int rc;
89 131
@@ -97,7 +139,8 @@ struct GNUNET_FUSE_PathInfo
97/** 139/**
98 * Create a new path info entry in the global map. 140 * Create a new path info entry in the global map.
99 * 141 *
100 * @param path path the entry represents 142 * @param parent parent directory (can be NULL)
143 * @param filename name of the file to create
101 * @param uri URI to use for the path 144 * @param uri URI to use for the path
102 * @param is_directory GNUNET_YES if this entry is for a directory 145 * @param is_directory GNUNET_YES if this entry is for a directory
103 * @return existing path entry if one already exists, otherwise 146 * @return existing path entry if one already exists, otherwise
@@ -105,7 +148,8 @@ struct GNUNET_FUSE_PathInfo
105 * the reference counter has been incremented by 1 148 * the reference counter has been incremented by 1
106 */ 149 */
107struct GNUNET_FUSE_PathInfo * 150struct GNUNET_FUSE_PathInfo *
108GNUNET_FUSE_path_info_create (const char *path, 151GNUNET_FUSE_path_info_create (struct GNUNET_FUSE_PathInfo *parent,
152 const char *filename,
109 const struct GNUNET_FS_Uri *uri, 153 const struct GNUNET_FS_Uri *uri,
110 int is_directory); 154 int is_directory);
111 155
@@ -114,11 +158,13 @@ GNUNET_FUSE_path_info_create (const char *path,
114 * Obtain an existing path info entry from the global map. 158 * Obtain an existing path info entry from the global map.
115 * 159 *
116 * @param path path the entry represents 160 * @param path path the entry represents
161 * @param eno where to store 'errno' on errors
117 * @return NULL if no such path entry exists, otherwise 162 * @return NULL if no such path entry exists, otherwise
118 * an entry with incremented reference counter (!) 163 * an entry with incremented reference counter (!)
119 */ 164 */
120struct GNUNET_FUSE_PathInfo * 165struct GNUNET_FUSE_PathInfo *
121GNUNET_FUSE_path_info_get (const char *path); 166GNUNET_FUSE_path_info_get (const char *path,
167 int *eno);
122 168
123 169
124/** 170/**
@@ -141,9 +187,30 @@ int
141GNUNET_FUSE_path_info_delete (struct GNUNET_FUSE_PathInfo *pi); 187GNUNET_FUSE_path_info_delete (struct GNUNET_FUSE_PathInfo *pi);
142 188
143 189
190/**
191 * Load and parse a directory.
192 *
193 * @param pi path to the directory
194 * @param eno where to store 'errno' on errors
195 * @return GNUNET_OK on success
196 */
197int
198GNUNET_FUSE_load_directory (struct GNUNET_FUSE_PathInfo *pi,
199 int * eno);
200
201
144/* FUSE function files */ 202/* FUSE function files */
145int gn_getattr(const char *path, struct stat *stbuf); 203int gn_getattr(const char *path, struct stat *stbuf);
146 204
205int gn_open(const char *path, struct fuse_file_info *fi);
206
207int gn_read(const char *path, char *buf, size_t size, off_t offset,
208 struct fuse_file_info *fi);
209
210int gn_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
211 off_t offset, struct fuse_file_info *fi);
212
213
147int gn_mknod(const char *path, mode_t mode, dev_t rdev); 214int gn_mknod(const char *path, mode_t mode, dev_t rdev);
148 215
149int gn_mkdir(const char *path, mode_t mode); 216int gn_mkdir(const char *path, mode_t mode);
@@ -156,19 +223,11 @@ int gn_rename(const char *from, const char *to);
156 223
157int gn_truncate(const char *path, off_t size); 224int gn_truncate(const char *path, off_t size);
158 225
159int gn_open(const char *path, struct fuse_file_info *fi);
160
161int gn_read(const char *path, char *buf, size_t size, off_t offset,
162 struct fuse_file_info *fi);
163
164int gn_write(const char *path, const char *buf, size_t size, off_t offset, 226int gn_write(const char *path, const char *buf, size_t size, off_t offset,
165 struct fuse_file_info *fi); 227 struct fuse_file_info *fi);
166 228
167int gn_release(const char *path, struct fuse_file_info *fi); 229int gn_release(const char *path, struct fuse_file_info *fi);
168 230
169int gn_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
170 off_t offset, struct fuse_file_info *fi);
171
172int gn_utimens(const char *path, const struct timespec ts[2]); 231int gn_utimens(const char *path, const struct timespec ts[2]);
173 232
174 233