@@ -50,16 +50,18 @@ static void setup(void)
int fd;
struct stat statbuf;
+ umask(0);
+
+ SAFE_MOUNT(tst_device->dev, MNTPOINT, tst_device->fs_type, 0, NULL);
+
cwd = SAFE_GETCWD(NULL, 0);
workdir = SAFE_MALLOC(strlen(cwd) + strlen(MNTPOINT) + 2);
sprintf(workdir, "%s/%s", cwd, MNTPOINT);
free(cwd);
SAFE_CHDIR(workdir);
- mode_t sys_umask = umask(0);
SAFE_MKDIR(DIR_NAME, 0755);
SAFE_MKDIR(BLOCKED_NAME, 0644);
- umask(sys_umask);
/* FAT and NTFS override file and directory permissions */
SAFE_STAT(BLOCKED_NAME, &statbuf);
@@ -132,12 +134,14 @@ static void run(unsigned int n)
static void cleanup(void)
{
+ SAFE_CHDIR("..");
+ tst_umount(workdir);
free(workdir);
}
static struct tst_test test = {
.needs_root = 1,
- .mount_device = 1,
+ .format_device = 1,
.mntpoint = MNTPOINT,
.all_filesystems = 1,
.test = run,
Fixes the test on more restrictive umask, this was found on FIPS but it's not limited to the FIPS system at all. All that is needed to reproduce the problem is to set umask to 077 before the test is executed. The troublemaker here is the FAT filesystem since there are no access bits defined in FAT disk format and they are emulated completely by the kernel. This means that all files on FAT filesytem have access bits generated by the kernel accordingly to system umask at the time the filesystem was mounted. This means that in order to be able to access the files on FAT we have to set the umask(0) before we mount the filesystem. Signed-off-by: Cyril Hrubis <chrubis@suse.cz> --- testcases/kernel/syscalls/chdir/chdir01.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)