Cannot override certain umask

Hi,

I’d like to create files with certain permissons, especially g+w. With the following code:

Char_t *sf = gSystem->ExpandPathName(“newfile”);
Int_t umask = gSystem->Umask(n);
TFile *fFile = new TFile(sf, “UPDATE”);
gSystem->Umask(umask);

I may create a file with the umask “n”. However, this only works for removing permissions from the default value of 022. But it is not possible to give permissions which are not part of the default.

According to the source code, Umask() simply calls the unix command umask, so I’m a little bit puzzled.

On the other hand, setting a Umask(n) in root and then creating a file in a shell opened with “.!/bin/bash” provides exactly the permissions “n” to that file.

How may I overcome this, or where may I change the default value for umask?

Cheers,
Stefan

Hi Stefan,

ROOT TFile’s are always created with the permissions 0644 so there is no way with umask to add permissions to it. You can only use umask to restrict the default specified permissions.

You can use chmod() to change the permissions after having created the file. In the latest version in cvs you can do that in a machine independent way via TSystem::Chmod().

Cheers, Fons.

Hello Fons,

Is there a good reason for this behavior? I would guess that something called "umask"
should intuitively work like its UNIX-pedant rather than working in a way “I know better what you really want” …

Cheers

Benjamin