]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
fallocate: create mode 0666, that's what umask is for
authorKarel Zak <kzak@redhat.com>
Wed, 7 Jan 2015 08:57:55 +0000 (09:57 +0100)
committerKarel Zak <kzak@redhat.com>
Wed, 7 Jan 2015 08:57:55 +0000 (09:57 +0100)
User's umask will typically mask the mode down to 0664 or 0644.

Reported-by: Peter Cordes <peter@cordes.ca>
Signed-off-by: Karel Zak <kzak@redhat.com>
sys-utils/fallocate.c

index 0e4eb4971c42b77b25200fe5dab59396b061b82a..84b06b9609ec3f853d840b867a529f5e2d09919f 100644 (file)
@@ -368,7 +368,8 @@ int main(int argc, char **argv)
 
        /* O_CREAT makes sense only for the default fallocate(2) behavior
         * when mode is no specified and new space is allocated */
-       fd = open(filename, O_RDWR | (!dig && !mode ? O_CREAT : 0), 0644);
+       fd = open(filename, O_RDWR | (!dig && !mode ? O_CREAT : 0),
+                 S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
        if (fd < 0)
                err(EXIT_FAILURE, _("cannot open %s"), filename);