Messages in this thread Patch in this message | | | Date | Wed, 15 Oct 2003 19:19:46 +0100 (BST) | From | Hugh Dickins <> | Subject | [PATCH] tmpfs 2/7 LTP S_ISGID dir |
| |
LTP tests the filesystem on /tmp: many failures when tmpfs because it missed the way giddy directories hand down their gid. Also fix ramfs and hugetlbfs.
--- tmpfs1/fs/hugetlbfs/inode.c 2003-10-15 08:49:54.000000000 +0100 +++ tmpfs2/fs/hugetlbfs/inode.c 2003-10-15 15:38:41.333893024 +0100 @@ -409,10 +409,18 @@ static int hugetlbfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev) { - struct inode *inode = hugetlbfs_get_inode(dir->i_sb, current->fsuid, - current->fsgid, mode, dev); + struct inode *inode; int error = -ENOSPC; + gid_t gid; + if (dir->i_mode & S_ISGID) { + gid = dir->i_gid; + if (S_ISDIR(mode)) + mode |= S_ISGID; + } else { + gid = current->fsgid; + } + inode = hugetlbfs_get_inode(dir->i_sb, current->fsuid, gid, mode, dev); if (inode) { dir->i_size += PSEUDO_DIRENT_SIZE; dir->i_ctime = dir->i_mtime = CURRENT_TIME; @@ -441,9 +449,15 @@ { struct inode *inode; int error = -ENOSPC; + gid_t gid; + + if (dir->i_mode & S_ISGID) + gid = dir->i_gid; + else + gid = current->fsgid; inode = hugetlbfs_get_inode(dir->i_sb, current->fsuid, - current->fsgid, S_IFLNK|S_IRWXUGO, 0); + gid, S_IFLNK|S_IRWXUGO, 0); if (inode) { int l = strlen(symname)+1; error = page_symlink(inode, symname, l); --- tmpfs1/fs/ramfs/inode.c 2003-09-08 20:51:04.000000000 +0100 +++ tmpfs2/fs/ramfs/inode.c 2003-10-15 15:38:41.333893024 +0100 @@ -95,6 +95,11 @@ int error = -ENOSPC; if (inode) { + if (dir->i_mode & S_ISGID) { + inode->i_gid = dir->i_gid; + if (S_ISDIR(mode)) + inode->i_mode |= S_ISGID; + } d_instantiate(dentry, inode); dget(dentry); /* Extra count - pin the dentry in core */ error = 0; @@ -125,6 +130,8 @@ int l = strlen(symname)+1; error = page_symlink(inode, symname, l); if (!error) { + if (dir->i_mode & S_ISGID) + inode->i_gid = dir->i_gid; d_instantiate(dentry, inode); dget(dentry); } else --- tmpfs1/mm/shmem.c 2003-10-15 08:47:31.000000000 +0100 +++ tmpfs2/mm/shmem.c 2003-10-15 15:38:41.336892568 +0100 @@ -1395,6 +1395,11 @@ int error = -ENOSPC; if (inode) { + if (dir->i_mode & S_ISGID) { + inode->i_gid = dir->i_gid; + if (S_ISDIR(mode)) + inode->i_mode |= S_ISGID; + } dir->i_size += BOGO_DIRENT_SIZE; dir->i_ctime = dir->i_mtime = CURRENT_TIME; d_instantiate(dentry, inode); @@ -1531,6 +1536,8 @@ set_page_dirty(page); page_cache_release(page); } + if (dir->i_mode & S_ISGID) + inode->i_gid = dir->i_gid; dir->i_size += BOGO_DIRENT_SIZE; dir->i_ctime = dir->i_mtime = CURRENT_TIME; d_instantiate(dentry, inode); - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |