From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 78EAAA0032; Fri, 17 Jun 2022 19:32:38 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 051A9410E7; Fri, 17 Jun 2022 19:32:38 +0200 (CEST) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mails.dpdk.org (Postfix) with ESMTP id F2C3240F19 for ; Fri, 17 Jun 2022 19:32:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1655487157; x=1687023157; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=Hocmx3ieN1L5ISHpmTr41wVDxJJiOTX3QnN6yW3e+EY=; b=JS/7Mt9DB/xcbLTGdZJKwEbwolalvdJk9RHU9TYj+U8wPO7+MetAskwf Axwa9mIGUUViN4Vs8n5DWOp8MnWvHmweXzVbOB+OpRvyjPWtwBn4taiID 1gh8jBQ5AMtKcPeBW5tyvFSja9DfsH0xKDry7kM9c8WGniYM1yvtdiGRJ sNbgdjgM0o7qST3XRuWUK9Q2uzYRtKdhZxiSEGzTSYUmjl7PCaJ4wHgOh c1mnofnWnbZrivfbFuZF6aay+F/5oduIKdIv/PBTNj4Q28DYfFKpC8LLN iY6nwMaJSwKFRdLUYe/V7Z9IyecPiTuAtS3vwGNgTfUHlA+7qSNIUweh+ g==; X-IronPort-AV: E=McAfee;i="6400,9594,10380"; a="280573883" X-IronPort-AV: E=Sophos;i="5.92,306,1650956400"; d="scan'208";a="280573883" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jun 2022 08:53:25 -0700 X-IronPort-AV: E=Sophos;i="5.92,306,1650956400"; d="scan'208";a="763286678" Received: from bricha3-mobl.ger.corp.intel.com ([10.252.10.212]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-SHA; 17 Jun 2022 08:53:24 -0700 Date: Fri, 17 Jun 2022 16:53:21 +0100 From: Bruce Richardson To: Dmitry Kozlyuk Cc: dev@dpdk.org Subject: Re: [PATCH v2 2/4] usertools: add option to change mount point owner Message-ID: References: <20220607234949.2311884-1-dkozlyuk@nvidia.com> <20220617112508.3823291-1-dkozlyuk@nvidia.com> <20220617112508.3823291-3-dkozlyuk@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220617112508.3823291-3-dkozlyuk@nvidia.com> X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org On Fri, Jun 17, 2022 at 02:25:06PM +0300, Dmitry Kozlyuk wrote: > Per mount(8), the previous owner and mode of the mount point > become invisible as long as this filesystem remains mounted. > Because dpdk-hugepages.py must be run as root, > the new owner would be root. > This is undesirable if the hugepage directory is being set up > by the administrator for an unprivileged user. > HugeTLB filesystem has options to set the mount point owner. > Add --owner/-o option to apply this option when mounting. > The benefit of performing this in dpdk-hugepages.py > is that the user does not need to care about this detail > of mount command operation. > > Signed-off-by: Dmitry Kozlyuk > --- > usertools/dpdk-hugepages.py | 12 ++++++++++-- > 1 file changed, 10 insertions(+), 2 deletions(-) > > diff --git a/usertools/dpdk-hugepages.py b/usertools/dpdk-hugepages.py > index 8bab086a2f..5120518bcb 100755 > --- a/usertools/dpdk-hugepages.py > +++ b/usertools/dpdk-hugepages.py > @@ -170,7 +170,7 @@ def get_mountpoints(): > return mounted > > > -def mount_huge(pagesize, mountpoint): > +def mount_huge(pagesize, mountpoint, owner): > '''Mount the huge TLB file system''' > if mountpoint in get_mountpoints(): > print(mountpoint, "already mounted") > @@ -178,6 +178,9 @@ def mount_huge(pagesize, mountpoint): > cmd = "mount -t hugetlbfs" > if pagesize: > cmd += ' -o pagesize={}'.format(pagesize * 1024) > + if owner: > + uid, gid = owner.split(':', maxsplit=1) > + cmd += ' -o uid={},gid={}'.format(uid, gid) I'm not sure about forcing the user to always provide a "user:group" format parameter. How about: 1. checking initially for the presence of a ":" and if not present just working with the uid parameter? 2. alternatively, what about adding in separate parameters for user or group, so they can be specified independently? /Bruce