From patchwork Mon May 29 14:33:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rabin Vincent X-Patchwork-Id: 9753297 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2DDC260249 for ; Mon, 29 May 2017 14:34:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1CCDC204C2 for ; Mon, 29 May 2017 14:34:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 10725209D8; Mon, 29 May 2017 14:34:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 96311204C2 for ; Mon, 29 May 2017 14:34:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751141AbdE2OeD (ORCPT ); Mon, 29 May 2017 10:34:03 -0400 Received: from bes.se.axis.com ([195.60.68.10]:52004 "EHLO bes.se.axis.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751080AbdE2OeC (ORCPT ); Mon, 29 May 2017 10:34:02 -0400 Received: from localhost (localhost [127.0.0.1]) by bes.se.axis.com (Postfix) with ESMTP id 59A162E3D7; Mon, 29 May 2017 16:34:00 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at bes.se.axis.com Received: from bes.se.axis.com ([IPv6:::ffff:127.0.0.1]) by localhost (bes.se.axis.com [::ffff:127.0.0.1]) (amavisd-new, port 10024) with LMTP id JLxTjL25QXkh; Mon, 29 May 2017 16:33:58 +0200 (CEST) Received: from boulder02.se.axis.com (boulder02.se.axis.com [10.0.8.16]) by bes.se.axis.com (Postfix) with ESMTPS id C8CF92E3E2; Mon, 29 May 2017 16:33:58 +0200 (CEST) Received: from boulder02.se.axis.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B7D771A065; Mon, 29 May 2017 16:33:58 +0200 (CEST) Received: from boulder02.se.axis.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AB6121A05E; Mon, 29 May 2017 16:33:58 +0200 (CEST) Received: from seth.se.axis.com (unknown [10.0.2.172]) by boulder02.se.axis.com (Postfix) with ESMTP; Mon, 29 May 2017 16:33:58 +0200 (CEST) Received: from lnxartpec.se.axis.com (lnxartpec.se.axis.com [10.88.4.9]) by seth.se.axis.com (Postfix) with ESMTP id 9E6EF20E9; Mon, 29 May 2017 16:33:58 +0200 (CEST) Received: by lnxartpec.se.axis.com (Postfix, from userid 10564) id 98507800A4; Mon, 29 May 2017 16:33:58 +0200 (CEST) Date: Mon, 29 May 2017 16:33:58 +0200 From: Rabin Vincent To: Al Viro , Richard Weinberger Cc: dedekind1@gmail.com, adrian.hunter@intel.com, linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org, linux-fsdevel , Christoph Hellwig Subject: Re: Setting ->s_dev to a char device (Was: Re: [PATCH v2] ubifs: allow userspace to map mounts to volumes) Message-ID: <20170529143358.GA27938@axis.com> References: <1496042533-17024-1-git-send-email-rabin.vincent@axis.com> <6737a526-18ba-6d8c-f6c8-03f03d74b90a@nod.at> <20170529120818.GA6365@ZenIV.linux.org.uk> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20170529120818.GA6365@ZenIV.linux.org.uk> User-Agent: Mutt/1.5.23 (2014-03-12) X-TM-AS-GCONF: 00 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Mon, May 29, 2017 at 01:08:25PM +0100, Al Viro wrote: > Userspace sure as hell does. st_dev in stat(2) is a block device number; > moreover, there might _be_ a block device with the same number at the same > time - even mounted. Why not make ->show_options() print the currently > valid volume name, anyway? That would seem to be the obvious approach... The following patch works for me, if it's OK to show options that can't actually be used when mounting: 8<----------------------- From 19797334f9c87a2e0c90fe2c93f29cce397b6230 Mon Sep 17 00:00:00 2001 From: Rabin Vincent Date: Mon, 29 May 2017 16:08:44 +0200 Subject: [PATCH v3] ubifs: allow userspace to map mounts to volumes There currently appears to be no way for userspace to find out the underlying volume number for a mounted ubifs file system, since ubifs uses anonymous block devices. The volume name is present in /proc/mounts but UBI volumes can be renamed after the volume has been mounted. To remedy this, show the UBI number and UBI volume number as part of the options visible under /proc/mounts. # mount -t ubifs ubi:baz x # mount ubi:baz on /root/x type ubifs (rw,relatime,ubi=0,vol=2) # ubirename /dev/ubi0 baz bazz # mount ubi:baz on /root/x type ubifs (rw,relatime,ubi=0,vol=2) # ubinfo -d 0 -n 2 Volume ID: 2 (on ubi0) Type: dynamic Alignment: 1 Size: 67 LEBs (1063424 bytes, 1.0 MiB) State: OK Name: bazz Character device major/minor: 254:3 Signed-off-by: Rabin Vincent --- fs/ubifs/super.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c index cf4cc99..4b54186 100644 --- a/fs/ubifs/super.c +++ b/fs/ubifs/super.c @@ -446,6 +446,8 @@ static int ubifs_show_options(struct seq_file *s, struct dentry *root) ubifs_compr_name(c->mount_opts.compr_type)); } + seq_printf(s, ",ubi=%d,vol=%d", c->vi.ubi_num, c->vi.vol_id); + return 0; }