Skip to content

Commit

Permalink
Merge uncontroversial parts of branch 'readlink' of git://git.kernel.…
Browse files Browse the repository at this point in the history
…org/pub/scm/linux/kernel/git/mszeredi/vfs

Pull partial readlink cleanups from Miklos Szeredi.

This is the uncontroversial part of the readlink cleanup patch-set that
simplifies the default readlink handling.

Miklos and Al are still discussing the rest of the series.

* git://git.kernel.org/pub/scm/linux/kernel/git/mszeredi/vfs:
  vfs: make generic_readlink() static
  vfs: remove ".readlink = generic_readlink" assignments
  vfs: default to generic_readlink()
  vfs: replace calling i_op->readlink with vfs_readlink()
  proc/self: use generic_readlink
  ecryptfs: use vfs_get_link()
  bad_inode: add missing i_op initializers
  • Loading branch information
torvalds committed Dec 18, 2016
2 parents 0110c35 + d16744e commit 231753e
Show file tree
Hide file tree
Showing 46 changed files with 120 additions and 110 deletions.
4 changes: 4 additions & 0 deletions Documentation/filesystems/porting
Original file line number Diff line number Diff line change
Expand Up @@ -596,3 +596,7 @@ in your dentry operations instead.
[mandatory]
->rename() has an added flags argument. Any flags not handled by the
filesystem should result in EINVAL being returned.
--
[recommended]
->readlink is optional for symlinks. Don't set, unless filesystem needs
to fake something for readlink(2).
9 changes: 6 additions & 3 deletions Documentation/filesystems/vfs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -451,9 +451,6 @@ otherwise noted.
exist; this is checked by the VFS. Unlike plain rename,
source and target may be of different type.

readlink: called by the readlink(2) system call. Only required if
you want to support reading symbolic links

get_link: called by the VFS to follow a symbolic link to the
inode it points to. Only required if you want to support
symbolic links. This method returns the symlink body
Expand All @@ -468,6 +465,12 @@ otherwise noted.
argument. If request can't be handled without leaving RCU mode,
have it return ERR_PTR(-ECHILD).

readlink: this is now just an override for use by readlink(2) for the
cases when ->get_link uses nd_jump_link() or object is not in
fact a symlink. Normally filesystems should only implement
->get_link for symlinks and readlink(2) will automatically use
that.

permission: called by the VFS to check for access rights on a POSIX-like
filesystem.

Expand Down
1 change: 0 additions & 1 deletion drivers/staging/lustre/lustre/llite/symlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ static const char *ll_get_link(struct dentry *dentry,
}

const struct inode_operations ll_fast_symlink_inode_operations = {
.readlink = generic_readlink,
.setattr = ll_setattr,
.get_link = ll_get_link,
.getattr = ll_getattr,
Expand Down
1 change: 0 additions & 1 deletion fs/9p/vfs_inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -1464,7 +1464,6 @@ static const struct inode_operations v9fs_file_inode_operations = {
};

static const struct inode_operations v9fs_symlink_inode_operations = {
.readlink = generic_readlink,
.get_link = v9fs_vfs_get_link,
.getattr = v9fs_vfs_getattr,
.setattr = v9fs_vfs_setattr,
Expand Down
1 change: 0 additions & 1 deletion fs/9p/vfs_inode_dotl.c
Original file line number Diff line number Diff line change
Expand Up @@ -979,7 +979,6 @@ const struct inode_operations v9fs_file_inode_operations_dotl = {
};

const struct inode_operations v9fs_symlink_inode_operations_dotl = {
.readlink = generic_readlink,
.get_link = v9fs_vfs_get_link_dotl,
.getattr = v9fs_vfs_getattr_dotl,
.setattr = v9fs_vfs_setattr_dotl,
Expand Down
1 change: 0 additions & 1 deletion fs/affs/symlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ const struct address_space_operations affs_symlink_aops = {
};

const struct inode_operations affs_symlink_inode_operations = {
.readlink = generic_readlink,
.get_link = page_get_link,
.setattr = affs_notify_change,
};
1 change: 0 additions & 1 deletion fs/autofs4/symlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,5 @@ static const char *autofs4_get_link(struct dentry *dentry,
}

const struct inode_operations autofs4_symlink_inode_operations = {
.readlink = generic_readlink,
.get_link = autofs4_get_link
};
55 changes: 51 additions & 4 deletions fs/bad_inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,50 @@ static ssize_t bad_inode_listxattr(struct dentry *dentry, char *buffer,
return -EIO;
}

static const char *bad_inode_get_link(struct dentry *dentry,
struct inode *inode,
struct delayed_call *done)
{
return ERR_PTR(-EIO);
}

static struct posix_acl *bad_inode_get_acl(struct inode *inode, int type)
{
return ERR_PTR(-EIO);
}

static int bad_inode_fiemap(struct inode *inode,
struct fiemap_extent_info *fieinfo, u64 start,
u64 len)
{
return -EIO;
}

static int bad_inode_update_time(struct inode *inode, struct timespec *time,
int flags)
{
return -EIO;
}

static int bad_inode_atomic_open(struct inode *inode, struct dentry *dentry,
struct file *file, unsigned int open_flag,
umode_t create_mode, int *opened)
{
return -EIO;
}

static int bad_inode_tmpfile(struct inode *inode, struct dentry *dentry,
umode_t mode)
{
return -EIO;
}

static int bad_inode_set_acl(struct inode *inode, struct posix_acl *acl,
int type)
{
return -EIO;
}

static const struct inode_operations bad_inode_ops =
{
.create = bad_inode_create,
Expand All @@ -118,14 +162,17 @@ static const struct inode_operations bad_inode_ops =
.mknod = bad_inode_mknod,
.rename = bad_inode_rename2,
.readlink = bad_inode_readlink,
/* follow_link must be no-op, otherwise unmounting this inode
won't work */
/* put_link returns void */
/* truncate returns void */
.permission = bad_inode_permission,
.getattr = bad_inode_getattr,
.setattr = bad_inode_setattr,
.listxattr = bad_inode_listxattr,
.get_link = bad_inode_get_link,
.get_acl = bad_inode_get_acl,
.fiemap = bad_inode_fiemap,
.update_time = bad_inode_update_time,
.atomic_open = bad_inode_atomic_open,
.tmpfile = bad_inode_tmpfile,
.set_acl = bad_inode_set_acl,
};


Expand Down
1 change: 0 additions & 1 deletion fs/btrfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -10653,7 +10653,6 @@ static const struct inode_operations btrfs_special_inode_operations = {
.update_time = btrfs_update_time,
};
static const struct inode_operations btrfs_symlink_inode_operations = {
.readlink = generic_readlink,
.get_link = page_get_link,
.getattr = btrfs_getattr,
.setattr = btrfs_setattr,
Expand Down
1 change: 0 additions & 1 deletion fs/ceph/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -1869,7 +1869,6 @@ void __ceph_do_pending_vmtruncate(struct inode *inode)
* symlinks
*/
static const struct inode_operations ceph_symlink_iops = {
.readlink = generic_readlink,
.get_link = simple_get_link,
.setattr = ceph_setattr,
.getattr = ceph_getattr,
Expand Down
1 change: 0 additions & 1 deletion fs/cifs/cifsfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -914,7 +914,6 @@ const struct inode_operations cifs_file_inode_ops = {
};

const struct inode_operations cifs_symlink_inode_ops = {
.readlink = generic_readlink,
.get_link = cifs_get_link,
.permission = cifs_permission,
.listxattr = cifs_listxattr,
Expand Down
1 change: 0 additions & 1 deletion fs/coda/cnode.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ static inline int coda_fideq(struct CodaFid *fid1, struct CodaFid *fid2)
}

static const struct inode_operations coda_symlink_inode_operations = {
.readlink = generic_readlink,
.get_link = page_get_link,
.setattr = coda_setattr,
};
Expand Down
1 change: 0 additions & 1 deletion fs/configfs/symlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,6 @@ static const char *configfs_get_link(struct dentry *dentry,

const struct inode_operations configfs_symlink_inode_operations = {
.get_link = configfs_get_link,
.readlink = generic_readlink,
.setattr = configfs_setattr,
};

30 changes: 12 additions & 18 deletions fs/ecryptfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -631,28 +631,23 @@ ecryptfs_rename(struct inode *old_dir, struct dentry *old_dentry,

static char *ecryptfs_readlink_lower(struct dentry *dentry, size_t *bufsiz)
{
DEFINE_DELAYED_CALL(done);
struct dentry *lower_dentry = ecryptfs_dentry_to_lower(dentry);
char *lower_buf;
const char *link;
char *buf;
mm_segment_t old_fs;
int rc;

lower_buf = kmalloc(PATH_MAX, GFP_KERNEL);
if (!lower_buf)
return ERR_PTR(-ENOMEM);
old_fs = get_fs();
set_fs(get_ds());
rc = d_inode(lower_dentry)->i_op->readlink(lower_dentry,
(char __user *)lower_buf,
PATH_MAX);
set_fs(old_fs);
if (rc < 0)
goto out;
link = vfs_get_link(lower_dentry, &done);
if (IS_ERR(link))
return ERR_CAST(link);

rc = ecryptfs_decode_and_decrypt_filename(&buf, bufsiz, dentry->d_sb,
lower_buf, rc);
out:
kfree(lower_buf);
return rc ? ERR_PTR(rc) : buf;
link, strlen(link));
do_delayed_call(&done);
if (rc)
return ERR_PTR(rc);

return buf;
}

static const char *ecryptfs_get_link(struct dentry *dentry,
Expand Down Expand Up @@ -1089,7 +1084,6 @@ static int ecryptfs_removexattr(struct dentry *dentry, struct inode *inode,
}

const struct inode_operations ecryptfs_symlink_iops = {
.readlink = generic_readlink,
.get_link = ecryptfs_get_link,
.permission = ecryptfs_permission,
.setattr = ecryptfs_setattr,
Expand Down
2 changes: 0 additions & 2 deletions fs/ext2/symlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#include "xattr.h"

const struct inode_operations ext2_symlink_inode_operations = {
.readlink = generic_readlink,
.get_link = page_get_link,
.setattr = ext2_setattr,
#ifdef CONFIG_EXT2_FS_XATTR
Expand All @@ -30,7 +29,6 @@ const struct inode_operations ext2_symlink_inode_operations = {
};

const struct inode_operations ext2_fast_symlink_inode_operations = {
.readlink = generic_readlink,
.get_link = simple_get_link,
.setattr = ext2_setattr,
#ifdef CONFIG_EXT2_FS_XATTR
Expand Down
3 changes: 0 additions & 3 deletions fs/ext4/symlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,21 +83,18 @@ static const char *ext4_encrypted_get_link(struct dentry *dentry,
}

const struct inode_operations ext4_encrypted_symlink_inode_operations = {
.readlink = generic_readlink,
.get_link = ext4_encrypted_get_link,
.setattr = ext4_setattr,
.listxattr = ext4_listxattr,
};

const struct inode_operations ext4_symlink_inode_operations = {
.readlink = generic_readlink,
.get_link = page_get_link,
.setattr = ext4_setattr,
.listxattr = ext4_listxattr,
};

const struct inode_operations ext4_fast_symlink_inode_operations = {
.readlink = generic_readlink,
.get_link = simple_get_link,
.setattr = ext4_setattr,
.listxattr = ext4_listxattr,
Expand Down
2 changes: 0 additions & 2 deletions fs/f2fs/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -1075,7 +1075,6 @@ static const char *f2fs_encrypted_get_link(struct dentry *dentry,
}

const struct inode_operations f2fs_encrypted_symlink_inode_operations = {
.readlink = generic_readlink,
.get_link = f2fs_encrypted_get_link,
.getattr = f2fs_getattr,
.setattr = f2fs_setattr,
Expand Down Expand Up @@ -1105,7 +1104,6 @@ const struct inode_operations f2fs_dir_inode_operations = {
};

const struct inode_operations f2fs_symlink_inode_operations = {
.readlink = generic_readlink,
.get_link = f2fs_get_link,
.getattr = f2fs_getattr,
.setattr = f2fs_setattr,
Expand Down
1 change: 0 additions & 1 deletion fs/fuse/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -1831,7 +1831,6 @@ static const struct inode_operations fuse_common_inode_operations = {
static const struct inode_operations fuse_symlink_inode_operations = {
.setattr = fuse_setattr,
.get_link = fuse_get_link,
.readlink = generic_readlink,
.getattr = fuse_getattr,
.listxattr = fuse_listxattr,
};
Expand Down
1 change: 0 additions & 1 deletion fs/gfs2/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -2067,7 +2067,6 @@ const struct inode_operations gfs2_dir_iops = {
};

const struct inode_operations gfs2_symlink_iops = {
.readlink = generic_readlink,
.get_link = gfs2_get_link,
.permission = gfs2_permission,
.setattr = gfs2_setattr,
Expand Down
1 change: 0 additions & 1 deletion fs/hostfs/hostfs_kern.c
Original file line number Diff line number Diff line change
Expand Up @@ -920,7 +920,6 @@ static const char *hostfs_get_link(struct dentry *dentry,
}

static const struct inode_operations hostfs_link_iops = {
.readlink = generic_readlink,
.get_link = hostfs_get_link,
};

Expand Down
1 change: 0 additions & 1 deletion fs/jffs2/symlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

const struct inode_operations jffs2_symlink_inode_operations =
{
.readlink = generic_readlink,
.get_link = simple_get_link,
.setattr = jffs2_setattr,
.listxattr = jffs2_listxattr,
Expand Down
2 changes: 0 additions & 2 deletions fs/jfs/symlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,12 @@
#include "jfs_xattr.h"

const struct inode_operations jfs_fast_symlink_inode_operations = {
.readlink = generic_readlink,
.get_link = simple_get_link,
.setattr = jfs_setattr,
.listxattr = jfs_listxattr,
};

const struct inode_operations jfs_symlink_inode_operations = {
.readlink = generic_readlink,
.get_link = page_get_link,
.setattr = jfs_setattr,
.listxattr = jfs_listxattr,
Expand Down
1 change: 0 additions & 1 deletion fs/kernfs/symlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ static const char *kernfs_iop_get_link(struct dentry *dentry,

const struct inode_operations kernfs_symlink_iops = {
.listxattr = kernfs_iop_listxattr,
.readlink = generic_readlink,
.get_link = kernfs_iop_get_link,
.setattr = kernfs_iop_setattr,
.getattr = kernfs_iop_getattr,
Expand Down
1 change: 0 additions & 1 deletion fs/libfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1131,7 +1131,6 @@ EXPORT_SYMBOL(simple_get_link);

const struct inode_operations simple_symlink_inode_operations = {
.get_link = simple_get_link,
.readlink = generic_readlink
};
EXPORT_SYMBOL(simple_symlink_inode_operations);

Expand Down
1 change: 0 additions & 1 deletion fs/minix/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,6 @@ static const struct address_space_operations minix_aops = {
};

static const struct inode_operations minix_symlink_inode_operations = {
.readlink = generic_readlink,
.get_link = page_get_link,
.getattr = minix_getattr,
};
Expand Down
Loading

0 comments on commit 231753e

Please sign in to comment.