[Libguestfs] Should umask takes effect when we create device file via mknod?

Richard W.M. Jones rjones at redhat.com
Sat Apr 17 08:37:28 UTC 2010


On Thu, Apr 15, 2010 at 07:18:15PM +0800, Yufang Zhang wrote:
> Hi all,
> Currently, umask takes effect when we create device file via mknod, as  
> bellow commands show:
> ><fs> mknod-b 0760 8 1 /dev/sdf
> ><fs> ll /dev/sdf
> brwxr----- 1 root root 8, 1 Apr 15 11:10 /sysroot/dev/sdf
>
> But I wonder whether it is reasonable? For mknod(1), when we use option  
> -m mode, we set file permission bits to MODE, not a=rw - umask. Should  
> this also be applicable to mknod in guestfish, thus when we create  
> device file with mode set, umask doesn't take effect?

I think it's reasonable for us to use the umask, but probably
it should be better documented.

In the daemon we use the mknod(2) system call which is documented
to be affected by umask:

   The permissions are modified by the process’s umask in the  usual  way:
   the permissions of the created node are (mode & ~umask).

But the behaviour is a little bit different from the mknod(1)
program.

We could add a mknod-mode command (see also mkdir-mode).  If you
think this is worth it, then please file a bug or send a patch.

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
libguestfs lets you edit virtual machines.  Supports shell scripting,
bindings from many languages.  http://et.redhat.com/~rjones/libguestfs/
See what it can do: http://et.redhat.com/~rjones/libguestfs/recipes.html




More information about the Libguestfs mailing list