fchmod/fchmod06.c: add EROFS
PATCH 1/1 fchmod/fchmod06.c: add EROFS
add EROFS error for fchmod(2)
Signed-off-by Zeng Linggang <[email protected]>
--- testcases/kernel/syscalls/fchmod/fchmod06.c | 63 ++++++++++++++++++++++++++++- 1 file changed, 62 insertions(+), 1 deletion(-)
testcases/kernel/syscalls/fchmod/fchmod06.c +62 -1
@@ -80,6 +80,7 @@#include <unistd.h> #include <grp.h> #include <pwd.h> +#include <sys/mount.h> #include "test.h" #include "usctest.h"
@@ -88,9 +89,23 @@#define FILE_MODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH)#define TEST_FILE1 "tfile_1"#define TEST_FILE2 "tfile_2" +#define TEST_FILE3 "mntpoint/tfile_3" +#define DIR_MODE (S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP| \ + S_IXGRP|S_IROTH|S_IXOTH)static int fd1;static int fd2; +static int fd3; +static char *fstype ="ext2" ; +static char *device; +static int dflag; +static int mount_flag; + +static option_t options[] = { + {"T:" ,NULL , &fstype}, + {"D:" , &dflag, &device}, + {NULL ,NULL ,NULL } +}; static struct test_case_t { int *fd;
@@ -99,20 +114,33 @@ static struct test_case_t { } test_cases[] = { {&fd1, FILE_MODE, EPERM}, {&fd2, FILE_MODE, EBADF}, + {&fd3, FILE_MODE, EROFS}, }; char *TCID = "fchmod06"; int TST_TOTAL = ARRAY_SIZE(test_cases); -static int exp_enos[] = { EPERM, EBADF, 0 }; +static int exp_enos[] = { EPERM, EBADF, EROFS, 0 }; static struct passwd *ltpuser; static void setup(void); static void cleanup(void); +static void help(void); int main(int ac, char **av) { int lc; int i; + char *msg; + + msg = parse_opts(ac, av, options, help); + if (msg != NULL) + tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg); + + /* Check for mandatory option of the testcase */ + if (!dflag) { + tst_brkm(TBROK, NULL, "you must specify the device used for " + "mounting with -D option"); + } setup();
@@ -171,6 +199,24 @@ static void setup(void) TEST_FILE1); } +tst_mkfs (NULL , device, fstype,NULL ); +SAFE_MKDIR (cleanup,"mntpoint" ,DIR_MODE ); +if (mount (device,"mntpoint" , fstype,0 ,NULL ) <0 ) { +tst_brkm (TBROK |TERRNO , cleanup, +"mount device:%s failed" , device); + } + mount_flag =1 ; + + fd3 =SAFE_CREAT (cleanup,TEST_FILE3 ,0666 ); +SAFE_CLOSE (cleanup, fd3); +if (mount (device,"mntpoint" , fstype, +MS_REMOUNT |MS_RDONLY ,NULL ) <0 ) { +tst_brkm (TBROK |TERRNO , cleanup, +"mount device:%s failed" , device); + } + mount_flag =1 ; + fd3 =SAFE_OPEN (cleanup,TEST_FILE3 ,O_RDONLY ,0666 ); +SAFE_CLOSE (cleanup, fd2);SAFE_SETEUID (cleanup, ltpuser->pw_uid);
@@ -182,5 +228,20 @@ static void cleanup(void)SAFE_CLOSE (NULL , fd1); +SAFE_CLOSE (NULL , fd3); + +SAFE_SETEUID (NULL ,0 ); +if (mount_flag &&umount ("mntpoint" ) <0 ) { +tst_brkm (TBROK |TERRNO ,NULL , +"umount device:%s failed" , device); + } +tst_rmdir (); } + +static void help (void ) +{ +printf ("-T type : specifies the type of filesystem to be mounted. " +"Default ext2.\n" ); +printf ("-D device : device used for mounting.\n" ); +}
Signature · 15 lines
1.8.2.1 ------------------------------------------------------------------------------ Shape the Mobile Experience: Free Subscription Software experts and developers: Be at the forefront of tech innovation. Intel(R) Software Adrenaline delivers strategic insight and game-changing conversations that shape the rapidly evolving mobile landscape. Sign up now. http://pubads.g.doubleclick.net/gampad/clk?id=63431311&iu=/4140/ostg.clktrk _______________________________________________ Ltp-list mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ltp-list