From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 63FD4138359 for ; Thu, 29 Oct 2020 16:16:41 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 9C54DE095F; Thu, 29 Oct 2020 16:16:40 +0000 (UTC) Received: from mail-qv1-f54.google.com (mail-qv1-f54.google.com [209.85.219.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 95823E095F for ; Thu, 29 Oct 2020 16:16:40 +0000 (UTC) Received: by mail-qv1-f54.google.com with SMTP id t20so1542389qvv.8 for ; Thu, 29 Oct 2020 09:16:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=swiDd1mtaTu9tNKD3mpBGQWAluqmHObj48XI53QoYVc=; b=kQrUMbsM8aYgZAFRvKEacXghI9EZQXjCPiSmh5h1Glife9h1QCfeFLJ/Q3FuiqJezQ zTe2kVIc0KIlpy+2mBtWkBpVSnCVa0UzS+AL0ckdeKCj/U7eCvCOqRMCq8bIKydoADzA XjbNo2wh0HJqNfSMb09P5mRw8HVENt8TLuURZJTG4qrajnxEbhpq0d9nz9YRmEhW+kTC XYr/mrJx1/FbJUz5YO/04bVFVC5i+Xa6aFcr9zw29qBynvK7m064uB4aEjjiDxLcYfOM CfmyQ9wFoDh31CMjI11zunaLDAs63YZ4gMRUcNsBW+ugwSDGWnqrw8mYuF9RIL3S70MS rKyw== X-Gm-Message-State: AOAM5337G9xWllQPmdZAT2l1Psn8wKh00JOyIZLaRfdSm4oV/WGbECHZ Cjvh+ZEMFJdmJzhGgLOV/lBbdCDCmKQ= X-Google-Smtp-Source: ABdhPJy0fKHHWJQPNe7Q4YU0l23laWsyq9sONmEBYOvtrbGxKbeUYlPszsig2kF9LNxM64UNPlpMFw== X-Received: by 2002:a05:6214:17d3:: with SMTP id cu19mr5341727qvb.12.1603988199439; Thu, 29 Oct 2020 09:16:39 -0700 (PDT) Received: from localhost (2606-a000-131c-10bb-0000-0000-0000-1fc3.inf6.spectrum.com. [2606:a000:131c:10bb::1fc3]) by smtp.gmail.com with ESMTPSA id s17sm1302945qkg.67.2020.10.29.09.16.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Oct 2020 09:16:38 -0700 (PDT) From: Matt Turner To: gentoo-catalyst@lists.gentoo.org Cc: Matt Turner Subject: [gentoo-catalyst] [PATCH 02/12] catalyst: Rewrite ismount() to use libmount Date: Thu, 29 Oct 2020 12:16:22 -0400 Message-Id: <20201029161632.146732-2-mattst88@gentoo.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201029161632.146732-1-mattst88@gentoo.org> References: <20201029161632.146732-1-mattst88@gentoo.org> Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-catalyst@lists.gentoo.org Reply-to: gentoo-catalyst@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Archives-Salt: 8797adf4-fe36-455e-8c61-b36192c81060 X-Archives-Hash: 2a40d499b8493774f402b45c2bf1678b libmount is provided by util-linux, so this adds a dependency on sys-apps/util-linux[python]. A later patch will make more extensive use of this API. Signed-off-by: Matt Turner --- README | 2 +- catalyst/support.py | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/README b/README index 1cceb63e..594de9e1 100644 --- a/README +++ b/README @@ -17,7 +17,7 @@ simple and reproducable manner. Use at your own risk. Requirements ======================= -- Python 3.6 or greater +- Python 3.8 or greater - A generic stage3 tarball for your architecture - A squashfs ebuild repository snapshot - Or an ebuild git repo with sys-fs/squashfs-tools-ng and dev-vcs/git diff --git a/catalyst/support.py b/catalyst/support.py index 4458ed20..ddbd9ab9 100644 --- a/catalyst/support.py +++ b/catalyst/support.py @@ -8,6 +8,8 @@ import time from pathlib import Path from subprocess import Popen +import libmount + from catalyst import log BASH_BINARY = "/bin/bash" @@ -182,15 +184,13 @@ def read_makeconf(mymakeconffile): def ismount(path): """Like os.path.ismount, but also support bind mounts""" - if os.path.ismount(path): + path = Path(path) + if path.is_mount(): return True - a = os.popen("mount") - mylines = a.readlines() - a.close() - for line in mylines: - mysplit = line.split() - if Path(path) == Path(mysplit[2]): + cxt = libmount.Context() + while (fs := cxt.mtab.next_fs()) is not None: + if path == Path(fs.target): return True return False -- 2.26.2