summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2009-05-08 08:16:58 -0700
committerGravatar Matt Colyer2009-05-08 08:17:32 -0700
commitd30ef14da1ca630c1842f1d47bd89abdc023585d (patch)
tree277ccbf1d2c84679d462ef20ce0a79fe80162b1b /src
parentc6f501b8a576ee7be19dd595f1b073e107ee9769 (diff)
downloadifuse-d30ef14da1ca630c1842f1d47bd89abdc023585d.tar.gz
ifuse-d30ef14da1ca630c1842f1d47bd89abdc023585d.tar.bz2
afc error handling in ifuse_open and ifuse_getattr
[#37 state:resolved] Signed-off-by: Matt Colyer <matt@colyer.name>
Diffstat (limited to 'src')
-rw-r--r--src/ifuse.c26
1 files changed, 23 insertions, 3 deletions
diff --git a/src/ifuse.c b/src/ifuse.c
index bdbacfd..68fcd5d 100644
--- a/src/ifuse.c
+++ b/src/ifuse.c
@@ -50,8 +50,16 @@ static int ifuse_getattr(const char *path, struct stat *stbuf)
iphone_afc_client_t afc = fuse_get_context()->private_data;
iphone_error_t ret = iphone_afc_get_file_attr(afc, path, stbuf);
- if (ret != IPHONE_E_SUCCESS)
- res = -ENOENT;
+ if (ret == IPHONE_E_AFC_ERROR) {
+ int e = iphone_afc_get_errno(afc);
+ if (e < 0) {
+ res = -EACCES;
+ } else {
+ res = -e;
+ }
+ } else if (ret != IPHONE_E_SUCCESS) {
+ res = -EACCES;
+ }
return res;
}
@@ -109,6 +117,7 @@ static int ifuse_open(const char *path, struct fuse_file_info *fi)
uint32 *argh_filehandle = (uint32 *) malloc(sizeof(uint32));
iphone_afc_client_t afc = fuse_get_context()->private_data;
uint32_t mode = 0;
+ iphone_error_t err;
if ((fi->flags & 3) == O_RDWR) {
mode = IPHONE_AFC_FILE_RW;
@@ -120,7 +129,18 @@ static int ifuse_open(const char *path, struct fuse_file_info *fi)
mode = IPHONE_AFC_FILE_READ;
}
- iphone_afc_open_file(afc, path, mode, &file);
+ err = iphone_afc_open_file(afc, path, mode, &file);
+ if (err == IPHONE_E_AFC_ERROR) {
+ int res = iphone_afc_get_errno(afc);
+ if (res < 0) {
+ return -EACCES;
+ } else {
+ return res;
+ }
+ } else if (err != IPHONE_E_SUCCESS) {
+ return -EINVAL;
+ }
+
*argh_filehandle = iphone_afc_get_file_handle(file);
fi->fh = *argh_filehandle;