diff --git a/src/AFC.c b/src/AFC.c
index 382851993af9b4bdb60629d4fe19fd30043eff03..b475a06dbf46eacec2f68cc782541bd903abf631 100644
--- a/src/AFC.c
+++ b/src/AFC.c
@@ -593,7 +593,7 @@ iphone_afc_file_t afc_get_file_info(iphone_afc_client_t client, const char *path
  */
 iphone_error_t iphone_afc_get_file_attr ( iphone_afc_client_t client, const char *filename, struct stat *stbuf ) {
 
-	int ret = IPHONE_E_SUCCESS;
+	iphone_error_t ret = IPHONE_E_UNKNOWN_ERROR;
 	if (!client ||!client->connection || !client->afc_packet || !stbuf) return IPHONE_E_INVALID_ARG;
 
 	memset(stbuf, 0, sizeof(struct stat));
@@ -608,8 +608,9 @@ iphone_error_t iphone_afc_get_file_attr ( iphone_afc_client_t client, const char
 		stbuf->st_uid = getuid();
 		stbuf->st_gid = getgid();
 
-		iphone_afc_close_file(client,file);
+		ret = iphone_afc_close_file(client,file);
 	}
+	return ret;
 }
 
 /** Opens a file on the phone.
diff --git a/src/ifuse.c b/src/ifuse.c
index ed36117cab3e791b8dbd2f00960dd2935377f306..c266879e0f994ab266dd5a5e2eb3b1bd3416fa4a 100644
--- a/src/ifuse.c
+++ b/src/ifuse.c
@@ -46,7 +46,10 @@ static int ifuse_getattr(const char *path, struct stat *stbuf) {
 	int res = 0;
 
 	iphone_afc_client_t afc = fuse_get_context()->private_data;
-	iphone_afc_get_file_attr(afc, path, stbuf);
+	iphone_error_t ret = iphone_afc_get_file_attr(afc, path, stbuf);
+
+	if (ret != IPHONE_E_SUCCESS)
+		res = -ENOENT;
 
 	return res;
 }
@@ -253,19 +256,19 @@ int ifuse_ftruncate(const char *path, off_t size, struct fuse_file_info *fi) {
 
 int ifuse_unlink(const char *path) {
 	iphone_afc_client_t afc = fuse_get_context()->private_data;
-	if (iphone_afc_delete_file(afc, path)) return 0;
+	if (IPHONE_E_SUCCESS == iphone_afc_delete_file(afc, path)) return 0;
 	else return -1;
 }
 
 int ifuse_rename(const char *from, const char *to) {
 	iphone_afc_client_t afc = fuse_get_context()->private_data;
-	if (iphone_afc_rename_file(afc, from, to)) return 0;
+	if (IPHONE_E_SUCCESS == iphone_afc_rename_file(afc, from, to)) return 0;
 	else return -1;
 }
 
 int ifuse_mkdir(const char *dir, mode_t ignored) {
 	iphone_afc_client_t afc = fuse_get_context()->private_data;
-	if (iphone_afc_mkdir(afc, dir)) return 0;
+	if (IPHONE_E_SUCCESS == iphone_afc_mkdir(afc, dir)) return 0;
 	else return -1;
 }