From patchwork Sun Nov 28 04:22:13 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Calvin Walton X-Patchwork-Id: 361712 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id oAS4MYWG002840 for ; Sun, 28 Nov 2010 04:22:36 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751266Ab0K1EWS (ORCPT ); Sat, 27 Nov 2010 23:22:18 -0500 Received: from mail-yx0-f174.google.com ([209.85.213.174]:62475 "EHLO mail-yx0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750956Ab0K1EWR (ORCPT ); Sat, 27 Nov 2010 23:22:17 -0500 Received: by yxt3 with SMTP id 3so996870yxt.19 for ; Sat, 27 Nov 2010 20:22:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:subject:from:to:cc :in-reply-to:references:content-type:date:message-id:mime-version :x-mailer:content-transfer-encoding; bh=Rdi/uLqDHHJNM0ptd5FF70ox6Cdecb8umL7Wk6hWCNs=; b=fKpnJMVrnF+YU7jfu+trDDAQRrQ/lrg3SqAqC4YR3jiAARx73wYoiPsjpjLJK2i/8V mZr6ujmsv9ZU4y8N9zT2eK4qhDbboyKDxbtemdAhNzMCLSeDc/zl7HT9bsoM/WXCObr/ VUsyqtgwu64w5bdRSFiVGQDNuM6+ZihrVDu/s= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=subject:from:to:cc:in-reply-to:references:content-type:date :message-id:mime-version:x-mailer:content-transfer-encoding; b=oK2GQAuQ8jqeG19+QN0kLi37qJHFhghfE/pOq+oYnM34vctUPFnAzCof4dXfrEocvt xJF6XqQ5TPMMCZNLZJFHVGzpBSzb3s2s+vSCKhO09xx1dzdLZhu1MaLUPT19PqN7qD7E cPIednZ40Ynek2PQGGfRZYGYbpWajvBcmWgMM= Received: by 10.151.102.9 with SMTP id e9mr7805592ybm.173.1290918136750; Sat, 27 Nov 2010 20:22:16 -0800 (PST) Received: from [192.168.2.139] (CABLE-206-188-91-131.cia.com [206.188.91.131]) by mx.google.com with ESMTPS id w5sm2426980ybe.22.2010.11.27.20.22.14 (version=SSLv3 cipher=RC4-MD5); Sat, 27 Nov 2010 20:22:15 -0800 (PST) Subject: [RFC-PATCH] Re: mounting arbitrary directories From: Calvin Walton To: C Anthony Risinger Cc: linux-btrfs@vger.kernel.org In-Reply-To: References: Date: Sat, 27 Nov 2010 23:22:13 -0500 Message-ID: <1290918133.14274.20.camel@nayuki> Mime-Version: 1.0 X-Mailer: Evolution 2.32.1 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Sun, 28 Nov 2010 04:22:36 +0000 (UTC) diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index 8299a25..5e78c86 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c @@ -646,26 +646,31 @@ static struct dentry *btrfs_mount(struct file_system_type *fs_type, int flags, /* if they gave us a subvolume name bind mount into that */ if (strcmp(subvol_name, ".")) { struct dentry *new_root; - mutex_lock(&root->d_inode->i_mutex); - new_root = lookup_one_len(subvol_name, root, - strlen(subvol_name)); - mutex_unlock(&root->d_inode->i_mutex); - - if (IS_ERR(new_root)) { - deactivate_locked_super(s); - error = PTR_ERR(new_root); - dput(root); - goto error_free_subvol_name; - } - if (!new_root->d_inode) { + char *subvol_name_next = subvol_name; + char *subvol_name_part; + + while ((subvol_name_part = strsep(&subvol_name_next, "/"))) { + mutex_lock(&root->d_inode->i_mutex); + new_root = lookup_one_len(subvol_name, root, + strlen(subvol_name)); + mutex_unlock(&root->d_inode->i_mutex); + + if (IS_ERR(new_root)) { + deactivate_locked_super(s); + error = PTR_ERR(new_root); + dput(root); + goto error_free_subvol_name; + } + if (!new_root->d_inode) { + dput(root); + dput(new_root); + deactivate_locked_super(s); + error = -ENXIO; + goto error_free_subvol_name; + } dput(root); - dput(new_root); - deactivate_locked_super(s); - error = -ENXIO; - goto error_free_subvol_name; + root = new_root; } - dput(root); - root = new_root; } kfree(subvol_name);