summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/AFC.c4
-rw-r--r--src/ifuse.c18
2 files changed, 19 insertions, 3 deletions
diff --git a/src/AFC.c b/src/AFC.c
index 680a08f..6fb5a9e 100644
--- a/src/AFC.c
+++ b/src/AFC.c
@@ -423,9 +423,11 @@ int afc_read_file(AFClient *client, AFCFile *file, char *data, int length) {
423 bytes = receive_AFC_data(client, &input); 423 bytes = receive_AFC_data(client, &input);
424 if (bytes < 0) { 424 if (bytes < 0) {
425 if (input) free(input); 425 if (input) free(input);
426 afc_unlock(client);
426 return -1; 427 return -1;
427 } else if (bytes == 0) { 428 } else if (bytes == 0) {
428 if (input) free(input); 429 if (input) free(input);
430 afc_unlock(client);
429 return current_count; 431 return current_count;
430 } else { 432 } else {
431 if (input) { 433 if (input) {
@@ -493,6 +495,4 @@ void afc_close_file(AFClient *client, AFCFile *file) {
493 bytes = receive_AFC_data(client, &buffer); 495 bytes = receive_AFC_data(client, &buffer);
494 afc_unlock(client); 496 afc_unlock(client);
495 return; 497 return;
496 if (buffer) free(buffer); // we're *SUPPOSED* to get an "error" here.
497} 498}
498
diff --git a/src/ifuse.c b/src/ifuse.c
index a56289d..3d921fd 100644
--- a/src/ifuse.c
+++ b/src/ifuse.c
@@ -112,10 +112,25 @@ static int ifuse_read(const char *path, char *buf, size_t size, off_t offset,
112 } 112 }
113 113
114 bytes = afc_read_file(afc, file, buf, size); 114 bytes = afc_read_file(afc, file, buf, size);
115
116 return bytes; 115 return bytes;
117} 116}
118 117
118static int ifuse_release(const char *path, struct fuse_file_info *fi){
119 AFCFile *file;
120 AFClient *afc = fuse_get_context()->private_data;
121
122 file = g_hash_table_lookup(file_handles, &(fi->fh));
123 if (!file){
124 return -ENOENT;
125 }
126 afc_close_file(afc, file);
127
128 free(file);
129 g_hash_table_remove(file_handles, &(fi->fh));
130
131 return 0;
132}
133
119void *ifuse_init(struct fuse_conn_info *conn) { 134void *ifuse_init(struct fuse_conn_info *conn) {
120 char *response = (char*)malloc(sizeof(char) * 2048); 135 char *response = (char*)malloc(sizeof(char) * 2048);
121 int bytes = 0, port = 0, i = 0; 136 int bytes = 0, port = 0, i = 0;
@@ -171,6 +186,7 @@ static struct fuse_operations ifuse_oper = {
171 .readdir = ifuse_readdir, 186 .readdir = ifuse_readdir,
172 .open = ifuse_open, 187 .open = ifuse_open,
173 .read = ifuse_read, 188 .read = ifuse_read,
189 .release = ifuse_release,
174 .init = ifuse_init, 190 .init = ifuse_init,
175 .destroy = ifuse_cleanup 191 .destroy = ifuse_cleanup
176}; 192};