file-systems.scm 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Ludovic Courtès <ludo@gnu.org>
  3. ;;; Copyright © 2020 Google LLC
  4. ;;; Copyright © 2020 Jakub Kądziołka <kuba@kadziolka.net>
  5. ;;; Copyright © 2020, 2021 Maxim Cournoyer <maxim.cournoyer@gmail.com>
  6. ;;;
  7. ;;; This file is part of GNU Guix.
  8. ;;;
  9. ;;; GNU Guix is free software; you can redistribute it and/or modify it
  10. ;;; under the terms of the GNU General Public License as published by
  11. ;;; the Free Software Foundation; either version 3 of the License, or (at
  12. ;;; your option) any later version.
  13. ;;;
  14. ;;; GNU Guix is distributed in the hope that it will be useful, but
  15. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  16. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. ;;; GNU General Public License for more details.
  18. ;;;
  19. ;;; You should have received a copy of the GNU General Public License
  20. ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
  21. (define-module (gnu system file-systems)
  22. #:use-module (ice-9 match)
  23. #:use-module (rnrs bytevectors)
  24. #:use-module (srfi srfi-1)
  25. #:use-module (srfi srfi-2)
  26. #:use-module (srfi srfi-9)
  27. #:use-module (srfi srfi-26)
  28. #:use-module (srfi srfi-35)
  29. #:use-module (srfi srfi-9 gnu)
  30. #:use-module (guix records)
  31. #:use-module ((guix diagnostics) #:select (&fix-hint))
  32. #:use-module (guix i18n)
  33. #:use-module (gnu system uuid)
  34. #:re-export (uuid ;backward compatibility
  35. string->uuid
  36. uuid->string)
  37. #:export (file-system
  38. file-system?
  39. file-system-device
  40. file-system-device->string
  41. file-system-title ;deprecated
  42. file-system-mount-point
  43. file-system-type
  44. file-system-needed-for-boot?
  45. file-system-flags
  46. file-system-options
  47. file-system-options->alist
  48. alist->file-system-options
  49. file-system-mount?
  50. file-system-mount-may-fail?
  51. file-system-check?
  52. file-system-create-mount-point?
  53. file-system-dependencies
  54. file-system-location
  55. file-system-type-predicate
  56. btrfs-subvolume?
  57. btrfs-store-subvolume-file-name
  58. file-system-label
  59. file-system-label?
  60. file-system-label->string
  61. file-system->spec
  62. spec->file-system
  63. specification->file-system-mapping
  64. %pseudo-file-system-types
  65. %fuse-control-file-system
  66. %binary-format-file-system
  67. %debug-file-system
  68. %efivars-file-system
  69. %shared-memory-file-system
  70. %pseudo-terminal-file-system
  71. %tty-gid
  72. %immutable-store
  73. %control-groups
  74. %elogind-file-systems
  75. %base-file-systems
  76. %container-file-systems
  77. <file-system-mapping>
  78. file-system-mapping
  79. file-system-mapping?
  80. file-system-mapping-source
  81. file-system-mapping-target
  82. file-system-mapping-writable?
  83. file-system-mapping->bind-mount
  84. %store-mapping
  85. %network-configuration-files
  86. %network-file-mappings))
  87. ;;; Commentary:
  88. ;;;
  89. ;;; Declaring file systems to be mounted.
  90. ;;;
  91. ;;; Note: this file system is used both in the Shepherd and on the "host
  92. ;;; side", so it must not include (gnu packages …) modules.
  93. ;;;
  94. ;;; Code:
  95. ;; File system declaration.
  96. (define-record-type* <file-system> %file-system
  97. make-file-system
  98. file-system?
  99. (device file-system-device) ; string | <uuid> | <file-system-label>
  100. (mount-point file-system-mount-point) ; string
  101. (type file-system-type) ; string
  102. (flags file-system-flags ; list of symbols
  103. (default '()))
  104. (options file-system-options ; string or #f
  105. (default #f))
  106. (mount? file-system-mount? ; Boolean
  107. (default #t))
  108. (mount-may-fail? file-system-mount-may-fail? ; Boolean
  109. (default #f))
  110. (needed-for-boot? %file-system-needed-for-boot? ; Boolean
  111. (default #f))
  112. (check? file-system-check? ; Boolean
  113. (default #t))
  114. (create-mount-point? file-system-create-mount-point? ; Boolean
  115. (default #f))
  116. (dependencies file-system-dependencies ; list of <file-system>
  117. (default '())) ; or <mapped-device>
  118. (location file-system-location
  119. (default (current-source-location))
  120. (innate)))
  121. ;; A file system label for use in the 'device' field.
  122. (define-record-type <file-system-label>
  123. (file-system-label label)
  124. file-system-label?
  125. (label file-system-label->string))
  126. (set-record-type-printer! <file-system-label>
  127. (lambda (obj port)
  128. (format port "#<file-system-label ~s>"
  129. (file-system-label->string obj))))
  130. (define-syntax report-deprecation
  131. (lambda (s)
  132. "Report the use of the now-deprecated 'title' field."
  133. (syntax-case s ()
  134. ((_ field)
  135. (let* ((source (syntax-source #'field))
  136. (file (and source (assq-ref source 'filename)))
  137. (line (and source
  138. (and=> (assq-ref source 'line) 1+)))
  139. (column (and source (assq-ref source 'column))))
  140. (format (current-error-port)
  141. "~a:~a:~a: warning: 'title' field is deprecated~%"
  142. file line column)
  143. #t)))))
  144. ;; Helper for 'process-file-system-declaration'.
  145. (define-syntax device-expression
  146. (syntax-rules (quote label uuid device)
  147. ((_ (quote label) dev)
  148. (file-system-label dev))
  149. ((_ (quote uuid) dev)
  150. (if (uuid? dev) dev (uuid dev)))
  151. ((_ (quote device) dev)
  152. dev)
  153. ((_ title dev)
  154. (case title
  155. ((label) (file-system-label dev))
  156. ((uuid) (uuid dev))
  157. (else dev)))))
  158. ;; Helper to interpret the now-deprecated 'title' field. Detect forms like
  159. ;; (title 'label), remove them, and adjust the 'device' field accordingly.
  160. ;; TODO: Remove this once 'title' has been deprecated long enough.
  161. (define-syntax process-file-system-declaration
  162. (syntax-rules (device title)
  163. ((_ () (rest ...) #f #f) ;no 'title' and no 'device' field
  164. (%file-system rest ...))
  165. ((_ () (rest ...) dev #f) ;no 'title' field
  166. (%file-system rest ... (device dev)))
  167. ((_ () (rest ...) dev titl) ;got a 'title' field
  168. (%file-system rest ...
  169. (device (device-expression titl dev))))
  170. ((_ ((title titl) rest ...) (previous ...) dev _)
  171. (begin
  172. (report-deprecation (title titl))
  173. (process-file-system-declaration (rest ...)
  174. (previous ...)
  175. dev titl)))
  176. ((_ ((device dev) rest ...) (previous ...) _ titl)
  177. (process-file-system-declaration (rest ...)
  178. (previous ...)
  179. dev titl))
  180. ((_ (field rest ...) (previous ...) dev titl)
  181. (process-file-system-declaration (rest ...)
  182. (previous ... field)
  183. dev titl))))
  184. (define-syntax-rule (file-system fields ...)
  185. (process-file-system-declaration (fields ...) () #f #f))
  186. (define (file-system-title fs) ;deprecated
  187. (match (file-system-device fs)
  188. ((? file-system-label?) 'label)
  189. ((? uuid?) 'uuid)
  190. ((? string?) 'device)))
  191. ;; Note: This module is used both on the build side and on the host side.
  192. ;; Arrange not to pull (guix store) and (guix config) because the latter
  193. ;; differs from user to user.
  194. (define (%store-prefix)
  195. "Return the store prefix."
  196. ;; Note: If we have (guix store database) in the search path and we do *not*
  197. ;; have (guix store) proper, 'resolve-module' returns an empty (guix store)
  198. ;; with one sub-module.
  199. (cond ((and=> (resolve-module '(guix store) #:ensure #f)
  200. (lambda (store)
  201. (module-variable store '%store-prefix)))
  202. =>
  203. (lambda (variable)
  204. ((variable-ref variable))))
  205. ((getenv "NIX_STORE")
  206. => identity)
  207. (else
  208. "/gnu/store")))
  209. (define %not-slash
  210. (char-set-complement (char-set #\/)))
  211. (define (file-prefix? file1 file2)
  212. "Return #t if FILE1 denotes the name of a file that is a parent of FILE2.
  213. FILE1 and FILE2 must both be either absolute or relative file names, else #f
  214. is returned.
  215. For example:
  216. (file-prefix? \"/gnu\" \"/gnu/store\")
  217. => #t
  218. (file-prefix? \"/gn\" \"/gnu/store\")
  219. => #f
  220. "
  221. (define (absolute? file)
  222. (string-prefix? "/" file))
  223. (if (or (every absolute? (list file1 file2))
  224. (every (negate absolute?) (list file1 file2)))
  225. (let loop ((file1 (string-tokenize file1 %not-slash))
  226. (file2 (string-tokenize file2 %not-slash)))
  227. (match file1
  228. (()
  229. #t)
  230. ((head1 tail1 ...)
  231. (match file2
  232. ((head2 tail2 ...)
  233. (and (string=? head1 head2) (loop tail1 tail2)))
  234. (()
  235. #f)))))
  236. ;; FILE1 and FILE2 are a mix of absolute and relative file names.
  237. #f))
  238. (define (file-name-depth file-name)
  239. (length (string-tokenize file-name %not-slash)))
  240. (define* (file-system-device->string device #:key uuid-type)
  241. "Return the string representations of the DEVICE field of a <file-system>
  242. record. When the device is a UUID, its representation is chosen depending on
  243. UUID-TYPE, a symbol such as 'dce or 'iso9660."
  244. (match device
  245. ((? file-system-label?)
  246. (file-system-label->string device))
  247. ((? uuid?)
  248. (if uuid-type
  249. (uuid->string (uuid-bytevector device) uuid-type)
  250. (uuid->string device)))
  251. ((? string?)
  252. device)))
  253. (define (file-system-options->alist string)
  254. "Translate the option string format of a <file-system> record into an
  255. association list of options or option/value pairs."
  256. (if string
  257. (let ((options (string-split string #\,)))
  258. (map (lambda (param)
  259. (let ((=index (string-index param #\=)))
  260. (if =index
  261. (cons (string-take param =index)
  262. (string-drop param (1+ =index)))
  263. param)))
  264. options))
  265. '()))
  266. (define (alist->file-system-options options)
  267. "Return the string representation of OPTIONS, an association list. The
  268. string obtained can be used as the option field of a <file-system> record."
  269. (if (null? options)
  270. #f
  271. (string-join (map (match-lambda
  272. ((key . value)
  273. (string-append key "=" value))
  274. (key
  275. key))
  276. options)
  277. ",")))
  278. (define (file-system-needed-for-boot? fs)
  279. "Return true if FS has the 'needed-for-boot?' flag set, or if it holds the
  280. store--e.g., if FS is the root file system."
  281. (or (%file-system-needed-for-boot? fs)
  282. (and (file-prefix? (file-system-mount-point fs) (%store-prefix))
  283. (not (memq 'bind-mount (file-system-flags fs))))))
  284. (define (file-system->spec fs)
  285. "Return a list corresponding to file-system FS that can be passed to the
  286. initrd code."
  287. (match fs
  288. (($ <file-system> device mount-point type flags options mount?
  289. mount-may-fail? needed-for-boot? check?)
  290. ;; Note: Add new fields towards the end for compatibility.
  291. (list (cond ((uuid? device)
  292. `(uuid ,(uuid-type device) ,(uuid-bytevector device)))
  293. ((file-system-label? device)
  294. `(file-system-label ,(file-system-label->string device)))
  295. (else device))
  296. mount-point type flags options mount-may-fail? check?))))
  297. (define (spec->file-system sexp)
  298. "Deserialize SEXP, a list, to the corresponding <file-system> object."
  299. (match sexp
  300. ((device mount-point type flags options mount-may-fail? check?
  301. _ ...) ;placeholder for new fields
  302. (file-system
  303. (device (match device
  304. (('uuid (? symbol? type) (? bytevector? bv))
  305. (bytevector->uuid bv type))
  306. (('file-system-label (? string? label))
  307. (file-system-label label))
  308. (_
  309. device)))
  310. (mount-point mount-point) (type type)
  311. (flags flags) (options options)
  312. (mount-may-fail? mount-may-fail?)
  313. (check? check?)))))
  314. (define (specification->file-system-mapping spec writable?)
  315. "Read the SPEC and return the corresponding <file-system-mapping>. SPEC is
  316. a string of the form \"SOURCE\" or \"SOURCE=TARGET\". The former specifies
  317. that SOURCE from the host should be mounted at SOURCE in the other system.
  318. The latter format specifies that SOURCE from the host should be mounted at
  319. TARGET in the other system."
  320. (let ((index (string-index spec #\=)))
  321. (if index
  322. (file-system-mapping
  323. (source (substring spec 0 index))
  324. (target (substring spec (+ 1 index)))
  325. (writable? writable?))
  326. (file-system-mapping
  327. (source spec)
  328. (target spec)
  329. (writable? writable?)))))
  330. ;;;
  331. ;;; Common file systems.
  332. ;;;
  333. (define %pseudo-file-system-types
  334. ;; List of know pseudo file system types. This is used when validating file
  335. ;; system definitions.
  336. '("binfmt_misc" "cgroup" "debugfs" "devpts" "devtmpfs" "efivarfs" "fusectl"
  337. "hugetlbfs" "overlay" "proc" "securityfs" "sysfs" "tmpfs"))
  338. (define %fuse-control-file-system
  339. ;; Control file system for Linux' file systems in user-space (FUSE).
  340. (file-system
  341. (device "fusectl")
  342. (mount-point "/sys/fs/fuse/connections")
  343. (type "fusectl")
  344. (check? #f)))
  345. (define %binary-format-file-system
  346. ;; Support for arbitrary executable binary format.
  347. (file-system
  348. (device "binfmt_misc")
  349. (mount-point "/proc/sys/fs/binfmt_misc")
  350. (type "binfmt_misc")
  351. (check? #f)))
  352. (define %debug-file-system
  353. (file-system
  354. (type "debugfs")
  355. (device "none")
  356. (mount-point "/sys/kernel/debug")
  357. (check? #f)
  358. (create-mount-point? #t)))
  359. (define %efivars-file-system
  360. ;; Support for EFI variables file system.
  361. (file-system
  362. (device "efivarfs")
  363. (mount-point "/sys/firmware/efi/efivars")
  364. (type "efivarfs")
  365. (mount-may-fail? #t)
  366. (needed-for-boot? #f)
  367. (check? #f)))
  368. (define %tty-gid
  369. ;; ID of the 'tty' group. Allocate it statically to make it easy to refer
  370. ;; to it from here and from the 'tty' group definitions.
  371. 996)
  372. (define %pseudo-terminal-file-system
  373. ;; The pseudo-terminal file system. It needs to be mounted so that
  374. ;; statfs(2) returns DEVPTS_SUPER_MAGIC like libc's getpt(3) expects (and
  375. ;; thus openpty(3) and its users, such as xterm.)
  376. (file-system
  377. (device "none")
  378. (mount-point "/dev/pts")
  379. (type "devpts")
  380. (check? #f)
  381. (needed-for-boot? #f)
  382. (create-mount-point? #t)
  383. (options (string-append "gid=" (number->string %tty-gid) ",mode=620"))))
  384. (define %shared-memory-file-system
  385. ;; Shared memory.
  386. (file-system
  387. (device "tmpfs")
  388. (mount-point "/dev/shm")
  389. (type "tmpfs")
  390. (check? #f)
  391. (flags '(no-suid no-dev))
  392. (options "size=50%") ;TODO: make size configurable
  393. (create-mount-point? #t)))
  394. (define %immutable-store
  395. ;; Read-only store to avoid users or daemons accidentally modifying it.
  396. ;; 'guix-daemon' has provisions to remount it read-write in its own name
  397. ;; space.
  398. (file-system
  399. (device (%store-prefix))
  400. (mount-point (%store-prefix))
  401. (type "none")
  402. (check? #f)
  403. (flags '(read-only bind-mount no-atime))))
  404. (define %control-groups
  405. (let ((parent (file-system
  406. (device "cgroup")
  407. (mount-point "/sys/fs/cgroup")
  408. (type "tmpfs")
  409. (check? #f))))
  410. (cons parent
  411. (map (lambda (subsystem)
  412. (file-system
  413. (device "cgroup")
  414. (mount-point (string-append "/sys/fs/cgroup/" subsystem))
  415. (type "cgroup")
  416. (check? #f)
  417. (options subsystem)
  418. (create-mount-point? #t)
  419. ;; This must be mounted after, and unmounted before the
  420. ;; parent directory.
  421. (dependencies (list parent))))
  422. '("cpuset" "cpu" "cpuacct" "memory" "devices" "freezer"
  423. "blkio" "perf_event" "pids")))))
  424. (define %elogind-file-systems
  425. ;; We don't use systemd, but these file systems are needed for elogind,
  426. ;; which was extracted from systemd.
  427. (append
  428. (list (file-system
  429. (device "none")
  430. (mount-point "/run/systemd")
  431. (type "tmpfs")
  432. (check? #f)
  433. (flags '(no-suid no-dev no-exec))
  434. (options "mode=0755")
  435. (create-mount-point? #t))
  436. (file-system
  437. (device "none")
  438. (mount-point "/run/user")
  439. (type "tmpfs")
  440. (check? #f)
  441. (flags '(no-suid no-dev no-exec))
  442. (options "mode=0755")
  443. (create-mount-point? #t))
  444. ;; Elogind uses cgroups to organize processes, allowing it to map PIDs
  445. ;; to sessions. Elogind's cgroup hierarchy isn't associated with any
  446. ;; resource controller ("subsystem").
  447. (file-system
  448. (device "cgroup")
  449. (mount-point "/sys/fs/cgroup/elogind")
  450. (type "cgroup")
  451. (check? #f)
  452. (options "none,name=elogind")
  453. (create-mount-point? #t)
  454. (dependencies (list (car %control-groups)))))
  455. %control-groups))
  456. (define %base-file-systems
  457. ;; List of basic file systems to be mounted. Note that /proc and /sys are
  458. ;; currently mounted by the initrd.
  459. (list %pseudo-terminal-file-system
  460. %debug-file-system
  461. %shared-memory-file-system
  462. %efivars-file-system
  463. %immutable-store))
  464. ;; File systems for Linux containers differ from %base-file-systems in that
  465. ;; they impose additional restrictions such as no-exec or need different
  466. ;; options to function properly.
  467. ;;
  468. ;; The file system flags and options conform to the libcontainer
  469. ;; specification:
  470. ;; https://github.com/docker/libcontainer/blob/master/SPEC.md#filesystem
  471. (define %container-file-systems
  472. (list
  473. ;; Pseudo-terminal file system.
  474. (file-system
  475. (device "none")
  476. (mount-point "/dev/pts")
  477. (type "devpts")
  478. (flags '(no-exec no-suid))
  479. (needed-for-boot? #t)
  480. (create-mount-point? #t)
  481. (check? #f)
  482. (options "newinstance,ptmxmode=0666,mode=620"))
  483. ;; Shared memory file system.
  484. (file-system
  485. (device "tmpfs")
  486. (mount-point "/dev/shm")
  487. (type "tmpfs")
  488. (flags '(no-exec no-suid no-dev))
  489. (options "mode=1777,size=65536k")
  490. (needed-for-boot? #t)
  491. (create-mount-point? #t)
  492. (check? #f))
  493. ;; Message queue file system.
  494. (file-system
  495. (device "mqueue")
  496. (mount-point "/dev/mqueue")
  497. (type "mqueue")
  498. (flags '(no-exec no-suid no-dev))
  499. (needed-for-boot? #t)
  500. (create-mount-point? #t)
  501. (check? #f))))
  502. ;;;
  503. ;;; Shared file systems, for VMs/containers.
  504. ;;;
  505. ;; Mapping of host file system SOURCE to mount point TARGET in the guest.
  506. (define-record-type* <file-system-mapping> file-system-mapping
  507. make-file-system-mapping
  508. file-system-mapping?
  509. (source file-system-mapping-source) ;string
  510. (target file-system-mapping-target) ;string
  511. (writable? file-system-mapping-writable? ;Boolean
  512. (default #f)))
  513. (define (file-system-mapping->bind-mount mapping)
  514. "Return a file system that realizes MAPPING, a <file-system-mapping>, using
  515. a bind mount."
  516. (match mapping
  517. (($ <file-system-mapping> source target writable?)
  518. (file-system
  519. (mount-point target)
  520. (device source)
  521. (type "none")
  522. (flags (if writable?
  523. '(bind-mount)
  524. '(bind-mount read-only)))
  525. (check? #f)
  526. (create-mount-point? #t)))))
  527. (define %store-mapping
  528. ;; Mapping of the host's store into the guest.
  529. (file-system-mapping
  530. (source (%store-prefix))
  531. (target (%store-prefix))
  532. (writable? #f)))
  533. (define %network-configuration-files
  534. ;; List of essential network configuration files.
  535. '("/etc/resolv.conf"
  536. "/etc/nsswitch.conf"
  537. "/etc/services"
  538. "/etc/hosts"))
  539. (define %network-file-mappings
  540. ;; List of file mappings for essential network files.
  541. (filter-map (lambda (file)
  542. (file-system-mapping
  543. (source file)
  544. (target file)
  545. ;; XXX: On some GNU/Linux systems, /etc/resolv.conf is a
  546. ;; symlink to a file in a tmpfs which, for an unknown reason,
  547. ;; cannot be bind mounted read-only within the container.
  548. (writable? (string=? file "/etc/resolv.conf"))))
  549. %network-configuration-files))
  550. (define (file-system-type-predicate type)
  551. "Return a predicate that, when passed a file system, returns #t if that file
  552. system has the given TYPE."
  553. (lambda (fs)
  554. (string=? (file-system-type fs) type)))
  555. ;;;
  556. ;;; Btrfs specific helpers.
  557. ;;;
  558. (define (btrfs-subvolume? fs)
  559. "Predicate to check if FS, a file-system object, is a Btrfs subvolume."
  560. (and-let* ((btrfs-file-system? (string= "btrfs" (file-system-type fs)))
  561. (option-keys (map (match-lambda
  562. ((key . value) key)
  563. (key key))
  564. (file-system-options->alist
  565. (file-system-options fs)))))
  566. (find (cut string-prefix? "subvol" <>) option-keys)))
  567. (define (btrfs-store-subvolume-file-name file-systems)
  568. "Return the subvolume file name within the Btrfs top level onto which the
  569. store is located, else #f."
  570. (define (prepend-slash/maybe s)
  571. (if (string=? "/" (string-take s 1))
  572. s
  573. (string-append "/" s)))
  574. (and-let* ((btrfs-subvolume-fs (filter btrfs-subvolume? file-systems))
  575. (btrfs-subvolume-fs*
  576. (sort btrfs-subvolume-fs
  577. (lambda (fs1 fs2)
  578. (> (file-name-depth (file-system-mount-point fs1))
  579. (file-name-depth (file-system-mount-point fs2))))))
  580. (store-subvolume-fs
  581. (find (lambda (fs) (file-prefix? (file-system-mount-point fs)
  582. (%store-prefix)))
  583. btrfs-subvolume-fs*))
  584. (options (file-system-options->alist
  585. (file-system-options store-subvolume-fs))))
  586. ;; XXX: Deriving the subvolume name based from a subvolume ID is not
  587. ;; supported, as we'd need to query the actual file system.
  588. (or (and=> (assoc-ref options "subvol") prepend-slash/maybe)
  589. (raise (condition
  590. (&message
  591. (message "The store is on a Btrfs subvolume, but the \
  592. subvolume name is unknown."))
  593. (&fix-hint
  594. (hint
  595. (G_ "Use the @code{subvol} Btrfs file system option."))))))))
  596. ;;; file-systems.scm ends here