From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp02.citrix.com ([66.165.176.63]:37767 "EHLO SMTP02.CITRIX.COM" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751157AbcGKJiQ (ORCPT ); Mon, 11 Jul 2016 05:38:16 -0400 Subject: Re: [Xen-devel] [PATCHv3 1/2] libfs: allow simple_fill_super() to add symlinks To: David Vrabel , Alexander Viro References: <1467137167-28546-1-git-send-email-david.vrabel@citrix.com> <1467137167-28546-2-git-send-email-david.vrabel@citrix.com> CC: Juergen Gross , , , , "Boris Ostrovsky" From: David Vrabel Message-ID: <57836903.1010802@citrix.com> Date: Mon, 11 Jul 2016 10:38:11 +0100 MIME-Version: 1.0 In-Reply-To: <1467137167-28546-2-git-send-email-david.vrabel@citrix.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On 28/06/16 19:06, 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. Can I get an ack for this, please? So it can go into 4.8 via the Xen tree. David > > Signed-off-by: David Vrabel > --- > 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 cedeacb..bbf2d82 100644 > --- a/fs/libfs.c > +++ b/fs/libfs.c > @@ -512,9 +512,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 dd28814..20c54a2 100644 > --- a/include/linux/fs.h > +++ b/include/linux/fs.h > @@ -2953,7 +2953,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); >