[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
15/67: build: syscalls: Add device-in-use?.
From: |
guix-commits |
Subject: |
15/67: build: syscalls: Add device-in-use?. |
Date: |
Wed, 16 Jan 2019 19:00:37 -0500 (EST) |
civodul pushed a commit to branch wip-newt-installer
in repository guix.
commit e584de7e70513803f98817651ac2f812d4a75f1f
Author: Mathieu Othacehe <address@hidden>
Date: Wed Dec 5 14:08:35 2018 +0900
build: syscalls: Add device-in-use?.
This new procedure uses BLKRRPART to determine whether or not a device is
busy. It is useful when a device does not appear as mounted but is maybe
used
by the kernel. This is the case with overlayfs lowerdir backend device for
example.
* guix/build/syscalls.scm (device-in-use?): New exported procedure.
---
guix/build/syscalls.scm | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/guix/build/syscalls.scm b/guix/build/syscalls.scm
index d75c11a..6f2a061 100644
--- a/guix/build/syscalls.scm
+++ b/guix/build/syscalls.scm
@@ -73,6 +73,7 @@
file-system-mount-flags
statfs
free-disk-space
+ device-in-use?
processes
mkdtemp!
@@ -684,6 +685,27 @@ mounted at FILE."
(define AT_NO_AUTOMOUNT #x800)
(define AT_EMPTY_PATH #x1000)
+(define-syntax BLKRRPART ;<sys/mount.h>
+ (identifier-syntax #x125F))
+
+(define* (device-in-use? device)
+ "Return #t if the block DEVICE is in use, #f otherwise. This is inspired
+from fdisk_device_is_used function of util-linux. This is particulary useful
+for devices that do not appear in /proc/self/mounts like overlayfs lowerdir
+backend device."
+ (let*-values (((port) (open-file device "rb"))
+ ((ret err) (%ioctl (fileno port) BLKRRPART %null-pointer)))
+ (close-port port)
+ (cond
+ ((= ret 0)
+ #f)
+ ((= err EBUSY)
+ #t)
+ (else
+ (throw 'system-error "ioctl" "~A"
+ (list (strerror err))
+ (list err))))))
+
;;;
;;; Containers.
- branch wip-newt-installer created (now e12a60d), guix-commits, 2019/01/16
- 01/67: guile: newt: Update revision to 3., guix-commits, 2019/01/16
- 06/67: installer: newt: Locate the logo within local-file., guix-commits, 2019/01/16
- 02/67: services: kmscon: Remove virtual-terminal requirement., guix-commits, 2019/01/16
- 09/67: guix: self: Do not install (gnu system install)., guix-commits, 2019/01/16
- 16/67: services: herd: Allow to pass arguments to start-service., guix-commits, 2019/01/16
- 11/67: installer: Rewrite welcome page., guix-commits, 2019/01/16
- 15/67: build: syscalls: Add device-in-use?.,
guix-commits <=
- 21/67: installer: Add new utils., guix-commits, 2019/01/16
- 20/67: installer: Remove "selection" from all titles., guix-commits, 2019/01/16
- 28/67: installer: Fix ethernet connection., guix-commits, 2019/01/16
- 10/67: gnu: installer: Launch the installer as kmscon login-program., guix-commits, 2019/01/16
- 19/67: file-systems: Export read-partition-label and read-partition-uuid., guix-commits, 2019/01/16
- 14/67: tests: Rename %test-encrypted-os to %test-encrypted-root-os., guix-commits, 2019/01/16
- 18/67: gnu: Add guile-parted., guix-commits, 2019/01/16
- 33/67: installer: Reorder local.mk., guix-commits, 2019/01/16
- 05/67: installer: newt: Use scheme-modules* instead of scheme-modules., guix-commits, 2019/01/16
- 17/67: gnu: guile-newt: Update to revision 4., guix-commits, 2019/01/16