]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
test: (mkfds::make-regular-file) add a parameter for making the new file readable
authorMasatake YAMATO <yamato@redhat.com>
Tue, 4 Jul 2023 16:56:37 +0000 (01:56 +0900)
committerMasatake YAMATO <yamato@redhat.com>
Wed, 5 Jul 2023 04:51:11 +0000 (13:51 +0900)
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
tests/helpers/test_mkfds.c

index fe3c35ad4e46436ad61913c32dfffdcfafd0dd9d..a71eaea68f57835fb992b2b0edfcd33ffa8cccf2 100644 (file)
@@ -404,14 +404,18 @@ static void *make_w_regular_file(const struct factory *factory, struct fdesc fde
        struct arg write_bytes = decode_arg("write-bytes", factory->params, argc, argv);
        int iWrite_bytes = ARG_INTEGER(write_bytes);
 
+       struct arg readable = decode_arg("readable", factory->params, argc, argv);
+       bool bReadable = ARG_BOOLEAN(readable);
+
        if (iWrite_bytes < 0)
                err(EXIT_FAILURE, "write-bytes must be a positive number or zero.");
 
+       free_arg(&readable);
        free_arg(&write_bytes);
        free_arg(&delete);
        free_arg(&file);
 
-       fd = open(fname, O_CREAT|O_EXCL|O_WRONLY, S_IWUSR);
+       fd = open(fname, O_CREAT|O_EXCL|(bReadable? O_RDWR: O_WRONLY), S_IWUSR);
        if (fd < 0)
                err(EXIT_FAILURE, "failed to make: %s", fname);
 
@@ -2651,6 +2655,12 @@ static const struct factory factories[] = {
                                .desc = "write something (> 0)",
                                .defv.integer = 0,
                        },
+                       {
+                               .name = "readable",
+                               .type = PTYPE_BOOLEAN,
+                               .desc = "open the new file readable way",
+                               .defv.string = false,
+                       },
                        PARAM_END
                },
        },