Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1419401 > unrolled thread

Re: [Xen-devel] [PATCHv1 1/2] libfs: allow simple_fill_super() to add symlinks

Started byDavid Vrabel <david.vrabel@citrix.com>
First post2016-06-10 15:20 +0200
Last post2016-06-10 15:20 +0200
Articles 1 — 1 participant

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [Xen-devel] [PATCHv1 1/2] libfs: allow simple_fill_super() to add  symlinks David Vrabel <david.vrabel@citrix.com> - 2016-06-10 15:20 +0200

#1419401 — Re: [Xen-devel] [PATCHv1 1/2] libfs: allow simple_fill_super() to add symlinks

FromDavid Vrabel <david.vrabel@citrix.com>
Date2016-06-10 15:20 +0200
SubjectRe: [Xen-devel] [PATCHv1 1/2] libfs: allow simple_fill_super() to add symlinks
Message-ID<rIuvU-527-37@gated-at.bofh.it>
On 17/05/16 11:27, David Vrabel wrote:
> simple_fill_super() will add symlinks if an entry has mode & S_IFLNK.
> The target is provided in the new "link" field.

Ping?

> Signed-off-by: David Vrabel <david.vrabel@citrix.com>
> ---
> v2:
> - simplified.
> ---
>  fs/libfs.c         | 15 +++++++++++++--
>  include/linux/fs.h |  2 +-
>  2 files changed, 14 insertions(+), 3 deletions(-)
> 
> diff --git a/fs/libfs.c b/fs/libfs.c
> index f3fa82c..5b3a391 100644
> --- a/fs/libfs.c
> +++ b/fs/libfs.c
> @@ -517,9 +517,20 @@ int simple_fill_super(struct super_block *s, unsigned long magic,
>  			dput(dentry);
>  			goto out;
>  		}
> -		inode->i_mode = S_IFREG | files->mode;
> +		if (files->mode & S_IFLNK) {
> +			inode->i_mode = files->mode;
> +			inode->i_op = &simple_symlink_inode_operations;
> +			inode->i_link = kstrdup(files->link, GFP_KERNEL);
> +			if (!inode->i_link) {
> +				iput(inode);
> +				dput(dentry);
> +				goto out;
> +			}
> +		} else {
> +			inode->i_mode = S_IFREG | files->mode;
> +			inode->i_fop = files->ops;
> +		}
>  		inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
> -		inode->i_fop = files->ops;
>  		inode->i_ino = i;
>  		d_add(dentry, inode);
>  	}
> diff --git a/include/linux/fs.h b/include/linux/fs.h
> index 70e61b5..8a09998 100644
> --- a/include/linux/fs.h
> +++ b/include/linux/fs.h
> @@ -2897,7 +2897,7 @@ extern const struct file_operations simple_dir_operations;
>  extern const struct inode_operations simple_dir_inode_operations;
>  extern void make_empty_dir_inode(struct inode *inode);
>  extern bool is_empty_dir_inode(struct inode *inode);
> -struct tree_descr { char *name; const struct file_operations *ops; int mode; };
> +struct tree_descr { char *name; const struct file_operations *ops; int mode; char *link; };
>  struct dentry *d_alloc_name(struct dentry *, const char *);
>  extern int simple_fill_super(struct super_block *, unsigned long, struct tree_descr *);
>  extern int simple_pin_fs(struct file_system_type *, struct vfsmount **mount, int *count);
> 

[toc] | [standalone]


Back to top | Article view | linux.kernel


csiph-web