[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
16/68: build: syscalls: Add device-in-use?.
From: |
guix-commits |
Subject: |
16/68: build: syscalls: Add device-in-use?. |
Date: |
Thu, 17 Jan 2019 08:05:11 -0500 (EST) |
civodul pushed a commit to branch master
in repository guix.
commit b08bea04978ee93696a2172c6c5fe2c08561a8a2
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.
- 59/68: installer: Rename "Ok" buttons to "OK"., (continued)
- 59/68: installer: Rename "Ok" buttons to "OK"., guix-commits, 2019/01/17
- 47/68: installer: Display an eventual backtrace in a page., guix-commits, 2019/01/17
- 26/68: installer: Add hostname., guix-commits, 2019/01/17
- 10/68: guix: self: Do not install (gnu system install)., guix-commits, 2019/01/17
- 25/68: installer: Add services page., guix-commits, 2019/01/17
- 11/68: gnu: installer: Launch the installer as kmscon login-program., guix-commits, 2019/01/17
- 13/68: installer: Move everything to the build side., guix-commits, 2019/01/17
- 15/68: tests: Rename %test-encrypted-os to %test-encrypted-root-os., guix-commits, 2019/01/17
- 17/68: services: herd: Allow to pass arguments to start-service., guix-commits, 2019/01/17
- 19/68: gnu: Add guile-parted., guix-commits, 2019/01/17
- 16/68: build: syscalls: Add device-in-use?.,
guix-commits <=
- 18/68: gnu: guile-newt: Update to revision 4., guix-commits, 2019/01/17
- 62/68: installer: keymap: Put English layout and international variant ahead., guix-commits, 2019/01/17
- 12/68: installer: Rewrite welcome page., guix-commits, 2019/01/17
- 64/68: syscalls: 'device-in-use?' does not create a port., guix-commits, 2019/01/17
- 14/68: installer: Fix locale installation., guix-commits, 2019/01/17
- 68/68: installer: Fix manual partitioning., guix-commits, 2019/01/17
- 66/68: installer: Adjust messages on the final page., guix-commits, 2019/01/17
- 65/68: syscalls: 'device-in-use?' returns #f upon EINVAL., guix-commits, 2019/01/17
- 67/68: installer: "formating" → "formatting"., guix-commits, 2019/01/17
- 63/68: installer: partition: Add encryption password confirmation., guix-commits, 2019/01/17