From: Charles Manning Date: Mon, 15 Nov 2010 02:02:03 +0000 (+1300) Subject: yaffs direct: Add EROFS error for hundling chmod on a read-only fs X-Git-Tag: linux-mainline-patchset-4~98 X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs2.git;a=commitdiff_plain;h=105583dbe67bb27204f5b9cfc3692393b38831d2;ds=sidebyside yaffs direct: Add EROFS error for hundling chmod on a read-only fs Was EINVAL. EROFS is more meaningful. Signed-off-by: Charles Manning --- diff --git a/direct/python/yaffs_error_converter.c b/direct/python/yaffs_error_converter.c index e9a8070..1fd7b21 100644 --- a/direct/python/yaffs_error_converter.c +++ b/direct/python/yaffs_error_converter.c @@ -37,6 +37,7 @@ const error_entry error_list[] = { { ENOTDIR , "ENOTDIR"}, { EISDIR , "EISDIR"}, { ENFILE, "ENFILE"}, + { EROFS, "EROFS"}, { 0, NULL } }; diff --git a/direct/yaffsfs.c b/direct/yaffsfs.c index 203a034..7a05c21 100644 --- a/direct/yaffsfs.c +++ b/direct/yaffsfs.c @@ -1737,9 +1737,13 @@ int yaffs_access(const YCHAR *path, int amode) int yaffs_chmod(const YCHAR *path, mode_t mode) { struct yaffs_obj *obj; - int retVal = -1; + if(mode & ~(0777)){ + yaffsfs_SetError(-EINVAL); + return -1; + } + yaffsfs_Lock(); obj = yaffsfs_FindObject(NULL,path,0,1); @@ -1747,7 +1751,7 @@ int yaffs_chmod(const YCHAR *path, mode_t mode) if(!obj) yaffsfs_SetError(-ENOENT); else if(obj->my_dev->read_only) - yaffsfs_SetError(-EINVAL); + yaffsfs_SetError(-EROFS); else retVal = yaffsfs_DoChMod(obj,mode); @@ -1761,16 +1765,20 @@ int yaffs_chmod(const YCHAR *path, mode_t mode) int yaffs_fchmod(int fd, mode_t mode) { struct yaffs_obj *obj; - int retVal = -1; + if(mode & ~(0777)){ + yaffsfs_SetError(-EINVAL); + return -1; + } + yaffsfs_Lock(); obj = yaffsfs_GetHandleObject(fd); if(!obj) - yaffsfs_SetError(-ENOENT); + yaffsfs_SetError(-EBADF); else if(obj->my_dev->read_only) - yaffsfs_SetError(-EINVAL); + yaffsfs_SetError(-EROFS); else retVal = yaffsfs_DoChMod(obj,mode); diff --git a/direct/yportenv.h b/direct/yportenv.h index 22afb06..3f368aa 100644 --- a/direct/yportenv.h +++ b/direct/yportenv.h @@ -163,6 +163,10 @@ #define ENOSPC 28 #endif +#ifndef EROFS +#define EROFS 30 +#endif + #ifndef ERANGE #define ERANGE 34 #endif