From: gux.fnst <gux...@cn...> - 2014-05-16 01:50:06
|
于 05/15/2014 08:14 PM, ch...@su... 写道: > Hi! >> int main(int ac, char **av) >> { >> int i, lc; >> char *msg; >> >> - msg = parse_opts(ac, av, NULL, NULL); >> + msg = parse_opts(ac, av, options, help); >> if (msg != NULL) >> tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg); >> >> + if (!device) { >> + tst_brkm(TBROK, NULL, "you must specify the device " >> + "used for mounting with -D option"); > This should be TCONF rather than TBROK (I've fixed > that). > Got it. > >> setup(); >> >> TEST_EXP_ENOS(exp_enos); >> @@ -108,12 +141,34 @@ int main(int ac, char **av) >> >> static void setup(void) >> { >> + int i; >> + struct passwd *ltpuser; >> + >> + tst_require_root(NULL); >> + >> tst_sig(NOFORK, DEF_HANDLER, cleanup); >> >> TEST_PAUSE; >> >> tst_tmpdir(); >> >> + tst_mkfs(NULL, device, fstype, NULL); >> + SAFE_MKDIR(cleanup, MNTPOINT, DIR_MODE); >> + if (mount(device, MNTPOINT, fstype, 0, NULL) == -1) { >> + tst_brkm(TBROK | TERRNO, cleanup, >> + "mount device:%s failed", device); >> + } >> + SAFE_MKDIR(cleanup, TESTDIR5, DIR_MODE); >> + if (mount(device, MNTPOINT, fstype, MS_REMOUNT | MS_RDONLY, >> + NULL) == -1) { >> + tst_brkm(TBROK | TERRNO, cleanup, >> + "mount device:%s failed", device); >> + } >> + mount_flag = 1; >> + >> + ltpuser = SAFE_GETPWNAM(cleanup, "nobody"); >> + SAFE_SETEUID(cleanup, ltpuser->pw_uid); > > I've removed the EUID changes for all because these has no effect on the > test behavior (at least I haven't figured out why they are needed). I tested with the UEID is aimed to prove the system call can be executed right with a normal user account, to provide a more overall testcase. Regards, Xing Gu > > And pushed, thanks. > |