From: Xiaoguang Wang <wangxg.fnst@cn.fujitsu.com>
To: LTP <ltp-list@lists.sourceforge.net>
Subject: Re: [LTP] [PATCH v3 2/2] mknod/mknod07.c: add EROFS and ELOOP error value tests
Date: Wed, 26 Feb 2014 20:39:02 +0800 [thread overview]
Message-ID: <530DE066.2000105@cn.fujitsu.com> (raw)
In-Reply-To: <1393417946-8817-2-git-send-email-wangxg.fnst@cn.fujitsu.com>
Hi,
Please review this patch, fix some issues Cyril pointed out in fchownat()'s patch.
Thanks,
Xiaoguang Wang
On 02/26/2014 08:32 PM, Xiaoguang Wang wrote:
> Signed-off-by: Xiaoguang Wang <wangxg.fnst@cn.fujitsu.com>
> ---
> runtest/ltplite | 2 +-
> runtest/stress.part3 | 2 +-
> runtest/syscalls | 2 +-
> testcases/kernel/syscalls/mknod/mknod07.c | 64 ++++++++++++++++++++++++++++++-
> 4 files changed, 65 insertions(+), 5 deletions(-)
>
> diff --git a/runtest/ltplite b/runtest/ltplite
> index 4bd1c53..f7127fe 100644
> --- a/runtest/ltplite
> +++ b/runtest/ltplite
> @@ -431,7 +431,7 @@ mknod03 mknod03
> mknod04 mknod04
> mknod05 mknod05
> mknod06 mknod06
> -mknod07 mknod07
> +mknod07 mknod07 -D $LTP_DEV -T $LTP_DEV_FS_TYPE
> mknod08 mknod08
> mknod09 mknod09
>
> diff --git a/runtest/stress.part3 b/runtest/stress.part3
> index d631c19..2f31e93 100644
> --- a/runtest/stress.part3
> +++ b/runtest/stress.part3
> @@ -364,7 +364,7 @@ mknod03 mknod03
> mknod04 mknod04
> mknod05 mknod05
> mknod06 mknod06
> -mknod07 mknod07
> +mknod07 mknod07 -D $LTP_DEV -T $LTP_DEV_FS_TYPE
> mknod08 mknod08
> mknod09 mknod09
>
> diff --git a/runtest/syscalls b/runtest/syscalls
> index 49e3e79..f6b00d9 100644
> --- a/runtest/syscalls
> +++ b/runtest/syscalls
> @@ -553,7 +553,7 @@ mknod03 mknod03
> mknod04 mknod04
> mknod05 mknod05
> mknod06 mknod06
> -mknod07 mknod07
> +mknod07 mknod07 -D $LTP_DEV -T $LTP_DEV_FS_TYPE
> mknod08 mknod08
> mknod09 mknod09
>
> diff --git a/testcases/kernel/syscalls/mknod/mknod07.c b/testcases/kernel/syscalls/mknod/mknod07.c
> index ea17eef..8b4d494 100644
> --- a/testcases/kernel/syscalls/mknod/mknod07.c
> +++ b/testcases/kernel/syscalls/mknod/mknod07.c
> @@ -26,6 +26,10 @@
> * the caller is not super-user.
> * 2) mknod(2) returns -1 and sets errno to EACCES if parent directory
> * does not allow write permission to the process.
> + * 3) mknod(2) returns -1 and sets errno to EROFS if pathname refers to
> + * a file on a read-only file system.
> + * 4) mknod(2) returns -1 and sets errno to ELOOP if too many symbolic
> + * links were encountered in resolving pathname.
> *
> */
>
> @@ -38,6 +42,7 @@
> #include <pwd.h>
> #include <sys/types.h>
> #include <sys/stat.h>
> +#include <sys/mount.h>
>
> #include "test.h"
> #include "usctest.h"
> @@ -45,12 +50,29 @@
>
> #define DIR_TEMP "testdir_1"
> #define DIR_TEMP_MODE (S_IRUSR | S_IXUSR)
> +#define DIR_MODE (S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP| \
> + S_IXGRP|S_IROTH|S_IXOTH)
> +#define MNT_POINT "mntpoint"
>
> #define FIFO_MODE (S_IFIFO | S_IRUSR | S_IRGRP | S_IROTH)
> #define SOCKET_MODE (S_IFSOCK | S_IRWXU | S_IRWXG | S_IRWXO)
> #define CHR_MODE (S_IFCHR | S_IRUSR | S_IWUSR)
> #define BLK_MODE (S_IFBLK | S_IRUSR | S_IWUSR)
>
> +#define ELOPFILE "/test_eloop"
> +
> +static char elooppathname[sizeof(ELOPFILE) * 43] = ".";
> +
> +static char *fstype = "ext2";
> +static char *device;
> +static int mount_flag;
> +
> +static option_t options[] = {
> + {"T:", NULL, &fstype},
> + {"D:", NULL, &device},
> + {NULL, NULL, NULL},
> +};
> +
> static struct test_case_t {
> char *pathname;
> int mode;
> @@ -60,15 +82,18 @@ static struct test_case_t {
> { "testdir_1/tnode_2", FIFO_MODE, EACCES },
> { "tnode_3", CHR_MODE, EPERM },
> { "tnode_4", BLK_MODE, EPERM },
> + { "mntpoint/tnode_5", SOCKET_MODE, EROFS },
> + { elooppathname, FIFO_MODE, ELOOP },
> };
>
> char *TCID = "mknod07";
> int TST_TOTAL = ARRAY_SIZE(test_cases);
> -static int exp_enos[] = { EPERM, EACCES, 0 };
> +static int exp_enos[] = { EPERM, EACCES, EROFS, ELOOP, 0 };
>
> static void setup(void);
> static void mknod_verify(const struct test_case_t *test_case);
> static void cleanup(void);
> +static void help(void);
>
> int main(int ac, char **av)
> {
> @@ -76,10 +101,15 @@ int main(int ac, char **av)
> char *msg;
> int i;
>
> - 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");
> + }
> +
> setup();
>
> for (lc = 0; TEST_LOOPING(lc); lc++) {
> @@ -95,10 +125,13 @@ int main(int ac, char **av)
>
> static void setup(void)
> {
> + int i;
> struct passwd *ltpuser;
>
> tst_require_root(NULL);
>
> + tst_mkfs(NULL, device, fstype, NULL);
> +
> tst_sig(NOFORK, DEF_HANDLER, cleanup);
>
> TEST_EXP_ENOS(exp_enos);
> @@ -107,10 +140,27 @@ static void setup(void)
>
> TEST_PAUSE;
>
> + /* mount a read-only file system for EROFS test */
> + SAFE_MKDIR(cleanup, MNT_POINT, DIR_MODE);
> + if (mount(device, MNT_POINT, fstype, MS_RDONLY, NULL) < 0) {
> + tst_brkm(TBROK | TERRNO, cleanup,
> + "mount device:%s failed", device);
> + }
> + mount_flag = 1;
> +
> ltpuser = SAFE_GETPWNAM(cleanup, "nobody");
> SAFE_SETEUID(cleanup, ltpuser->pw_uid);
>
> SAFE_MKDIR(cleanup, DIR_TEMP, DIR_TEMP_MODE);
> +
> + /*
> + * NOTE: the ELOOP test is written based on that the consecutive
> + * symlinks limits in kernel is hardwired to 40.
> + */
> + SAFE_MKDIR(cleanup, "test_eloop", DIR_MODE);
> + SAFE_SYMLINK(cleanup, "../test_eloop", "test_eloop/test_eloop");
> + for (i = 0; i < 43; i++)
> + strcat(elooppathname, ELOPFILE);
> }
>
> static void mknod_verify(const struct test_case_t *test_case)
> @@ -139,5 +189,15 @@ static void cleanup(void)
> if (seteuid(0) == -1)
> tst_resm(TWARN | TERRNO, "seteuid(0) failed");
>
> + if (mount_flag && umount(MNT_POINT) < 0)
> + tst_resm(TWARN | TERRNO, "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");
> +}
------------------------------------------------------------------------------
Flow-based real-time traffic analytics software. Cisco certified tool.
Monitor traffic, SLAs, QoS, Medianet, WAAS etc. with NetFlow Analyzer
Customize your own dashboards, set traffic alerts and generate reports.
Network behavioral analysis & security monitoring. All-in-one tool.
http://pubads.g.doubleclick.net/gampad/clk?id=126839071&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
next prev parent reply other threads:[~2014-02-26 12:43 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-26 12:32 [LTP] [PATCH v3 1/2] mknod/mknod07.c: cleanup Xiaoguang Wang
2014-02-26 12:32 ` [LTP] [PATCH v3 2/2] mknod/mknod07.c: add EROFS and ELOOP error value tests Xiaoguang Wang
2014-02-26 12:39 ` Xiaoguang Wang [this message]
2014-02-27 5:58 ` Wanlong Gao
2014-02-27 5:58 ` [LTP] [PATCH v3 1/2] mknod/mknod07.c: cleanup Wanlong Gao
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=530DE066.2000105@cn.fujitsu.com \
--to=wangxg.fnst@cn.fujitsu.com \
--cc=ltp-list@lists.sourceforge.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox