[LTP] [PATCH v1] chdir01.c: set umask to 0 within setup

Martin Doucha mdoucha@suse.cz
Fri Mar 8 10:31:57 CET 2024


On 08. 03. 24 0:21, Wei Gao wrote:
> On Thu, Mar 07, 2024 at 04:18:35PM +0100, Martin Doucha wrote:
>> Hi,
>> you're trying to fix a vfat mount quirk. We should fix that in the LTP
>> library instead, e.g. by setting umask(0) and then restoring the original
>> value inside safe_mount().
> 
> Thanks for your feedback.
> 
> For chdir case i just use Petr's below suggestion(Detail info you can check patch link
> in below):
> 
> "2) tests, which set .mount_device = 1 and have more restrictive umask will not
> work. Workaround would be to not use it and mount manually in the setup().
> Or, reset umask with umask(0)."
> 
> https://patchwork.ozlabs.org/project/ltp/patch/20240219134845.22171-1-wegao@suse.com/

I'd rather avoid mounting in setup unless you need to set special mount 
parameters.

Mount-time umask does not matter for most filesystem. The exception are 
vfat and exfat which don't have any internal concept of access 
permissions and instead you need to either pass mount options that'll 
define access permissions for all files and directories, otherwise 
current process umask value will be used as the default.

So resetting umask to 0 before mount and restoring immediately after is 
perfectly safe. But we should later fix it properly by implementing 
per-filesystem mount options.

-- 
Martin Doucha   mdoucha@suse.cz
SW Quality Engineer
SUSE LINUX, s.r.o.
CORSO IIa
Krizikova 148/34
186 00 Prague 8
Czech Republic



More information about the ltp mailing list