From 2ff6672d9a317df122734dce4685c9512c07fe5a Mon Sep 17 00:00:00 2001 From: Nikias Bassen Date: Tue, 21 Apr 2009 17:46:42 +0200 Subject: [PATCH] afc error handling in ifuse_open and ifuse_getattr --- src/ifuse.c | 25 ++++++++++++++++++++++--- 1 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/ifuse.c b/src/ifuse.c index c591c42..5fcf3ee 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; } @@ -125,12 +133,23 @@ static int ifuse_open(const char *path, struct fuse_file_info *fi) iphone_afc_file_t file = NULL; iphone_afc_client_t afc = fuse_get_context()->private_data; iphone_afc_file_mode_t mode = 0; + iphone_error_t err; if (get_afc_file_mode(&mode, fi->flags) < 0 || (mode == 0)) { return -EPERM; } - 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; + } uint32_t *argh_filehandle = (uint32_t*) malloc(sizeof(uint32_t)); *argh_filehandle = iphone_afc_get_file_handle(file); -- 1.6.0.4