From patchwork Tue May 17 10:27:22 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Vrabel X-Patchwork-Id: 9111461 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id E674B9F30C for ; Tue, 17 May 2016 10:29:48 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1DE46202EC for ; Tue, 17 May 2016 10:29:48 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3900C202AE for ; Tue, 17 May 2016 10:29:47 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b2cE1-0004bV-9v; Tue, 17 May 2016 10:27:41 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b2cE0-0004bA-EA for xen-devel@lists.xenproject.org; Tue, 17 May 2016 10:27:40 +0000 Received: from [193.109.254.147] by server-6.bemta-14.messagelabs.com id 90/18-03753-B12FA375; Tue, 17 May 2016 10:27:39 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprEIsWRWlGSWpSXmKPExsXitHSDva70J6t wg2+ThC2+b5nM5MDocfjDFZYAxijWzLyk/IoE1oy2dUdZCl7xVZw9vI+pgXEXTxcjJ4eEgL/E 8fmnmUFsNgEdicdLZrCD2CJA9u+GsyxdjFwczAIPGCWe/HrFCJIQFnCXOPRoAQuIzSKgKvHh8 XQ2EJtXwE2i58MPdoihchLnj/8EG8oJVH9hy3kwWwik5uYldghbReLj2lWsEL2CEidnPgGbyS wgIXHwxQtmiDncErdPT2WewMg3C0nZLCRlCxiZVjFqFKcWlaUW6Roa6yUVZaZnlOQmZuboGhq a6OWmFhcnpqfmJCYV6yXn525iBIZVPQMD4w7GXds9DzFKcjApifK+vGgVLsSXlJ9SmZFYnBFf VJqTWnyIUYaDQ0mCN/4DUE6wKDU9tSItMwcY4DBpCQ4eJRHeUyBp3uKCxNzizHSI1ClGRSlx3 kaQhABIIqM0D64NFlWXGGWlhHkZGRgYhHgKUotyM0tQ5V8xinMwKglDjOfJzCuBm/4KaDET0O IJZhYgi0sSEVJSDYy8t3f+CdjDf9Q44tzya+HzNbr86g5MjLncPvFF87G+i+Vy7McOsl5jvH6 u02PbjcqALKHD4emrK7vykqMtVKr//7+rdOJw7ruaRLZJyad3hlSpMM0uSn29jkEgW2Zz76Y5 /9evEHr8XCTNfNWyH9L68/rOFyrPUr8Ut83l5V7+32xr1sxc6GevxFKckWioxVxUnAgA+wvvL 6UCAAA= X-Env-Sender: prvs=9381a948e=david.vrabel@citrix.com X-Msg-Ref: server-10.tower-27.messagelabs.com!1463480857!42022626!2 X-Originating-IP: [66.165.176.63] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni42MyA9PiAzMDYwNDg=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 8.34; banners=-,-,- X-VirusChecked: Checked Received: (qmail 18210 invoked from network); 17 May 2016 10:27:39 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-10.tower-27.messagelabs.com with RC4-SHA encrypted SMTP; 17 May 2016 10:27:39 -0000 X-IronPort-AV: E=Sophos;i="5.26,324,1459814400"; d="scan'208";a="361477429" From: David Vrabel To: Alexander Viro Date: Tue, 17 May 2016 11:27:22 +0100 Message-ID: <1463480843-3860-2-git-send-email-david.vrabel@citrix.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1463480843-3860-1-git-send-email-david.vrabel@citrix.com> References: <1463480843-3860-1-git-send-email-david.vrabel@citrix.com> MIME-Version: 1.0 X-DLP: MIA2 Cc: Juergen Gross , linux-kernel@vger.kernel.org, David Vrabel , linux-fsdevel@vger.kernel.org, xen-devel@lists.xenproject.org, Boris Ostrovsky Subject: [Xen-devel] [PATCHv1 1/2] libfs: allow simple_fill_super() to add symlinks X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP simple_fill_super() will add symlinks if an entry has mode & S_IFLNK. The target is provided in the new "link" field. 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 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);