Search code examples
embedded-linuxglibvala

How to create folders with 666 permission using vala?


Any user needs to be able to delete files and/or folders created by this embedded-linux root process. But this vala source DirUtils.create_with_parents(folder, 0666) is creating 0644 folders owned by root. The generated c code is g_mkdir_with_parents (folder, 0666) and the file-system is ext2.

chmod 0666 [folder] works as expected when using a console connected to the target but the typical connection will not use the console and will not be root (the typical connection will be embedded-linux USB).

Adding system("chmod 0666 folder") to the vala source was tried as a possible workaround but does not change the permissions of the folder from 644 to 666.

  • Is DirUtils.create_with_parents(folder, 0666) correct usage?
  • If so, is there another workaround I should try?

Solution

  • You probably need to set the umask, a default restriction on the permissive of permissions on new files. There is GNU library call umask().