file-systems.scm 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655
  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 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. where both FILE1 and FILE2 are absolute file name. For example:
  214. (file-prefix? \"/gnu\" \"/gnu/store\")
  215. => #t
  216. (file-prefix? \"/gn\" \"/gnu/store\")
  217. => #f
  218. "
  219. (and (string-prefix? "/" file1)
  220. (string-prefix? "/" file2)
  221. (let loop ((file1 (string-tokenize file1 %not-slash))
  222. (file2 (string-tokenize file2 %not-slash)))
  223. (match file1
  224. (()
  225. #t)
  226. ((head1 tail1 ...)
  227. (match file2
  228. ((head2 tail2 ...)
  229. (and (string=? head1 head2) (loop tail1 tail2)))
  230. (()
  231. #f)))))))
  232. (define* (file-system-device->string device #:key uuid-type)
  233. "Return the string representations of the DEVICE field of a <file-system>
  234. record. When the device is a UUID, its representation is chosen depending on
  235. UUID-TYPE, a symbol such as 'dce or 'iso9660."
  236. (match device
  237. ((? file-system-label?)
  238. (file-system-label->string device))
  239. ((? uuid?)
  240. (if uuid-type
  241. (uuid->string (uuid-bytevector device) uuid-type)
  242. (uuid->string device)))
  243. ((? string?)
  244. device)))
  245. (define (file-system-options->alist string)
  246. "Translate the option string format of a <file-system> record into an
  247. association list of options or option/value pairs."
  248. (if string
  249. (let ((options (string-split string #\,)))
  250. (map (lambda (param)
  251. (let ((=index (string-index param #\=)))
  252. (if =index
  253. (cons (string-take param =index)
  254. (string-drop param (1+ =index)))
  255. param)))
  256. options))
  257. '()))
  258. (define (alist->file-system-options options)
  259. "Return the string representation of OPTIONS, an association list. The
  260. string obtained can be used as the option field of a <file-system> record."
  261. (if (null? options)
  262. #f
  263. (string-join (map (match-lambda
  264. ((key . value)
  265. (string-append key "=" value))
  266. (key
  267. key))
  268. options)
  269. ",")))
  270. (define (file-system-needed-for-boot? fs)
  271. "Return true if FS has the 'needed-for-boot?' flag set, or if it holds the
  272. store--e.g., if FS is the root file system."
  273. (or (%file-system-needed-for-boot? fs)
  274. (and (file-prefix? (file-system-mount-point fs) (%store-prefix))
  275. (not (memq 'bind-mount (file-system-flags fs))))))
  276. (define (file-system->spec fs)
  277. "Return a list corresponding to file-system FS that can be passed to the
  278. initrd code."
  279. (match fs
  280. (($ <file-system> device mount-point type flags options mount?
  281. mount-may-fail? needed-for-boot? check?)
  282. ;; Note: Add new fields towards the end for compatibility.
  283. (list (cond ((uuid? device)
  284. `(uuid ,(uuid-type device) ,(uuid-bytevector device)))
  285. ((file-system-label? device)
  286. `(file-system-label ,(file-system-label->string device)))
  287. (else device))
  288. mount-point type flags options mount-may-fail? check?))))
  289. (define (spec->file-system sexp)
  290. "Deserialize SEXP, a list, to the corresponding <file-system> object."
  291. (match sexp
  292. ((device mount-point type flags options mount-may-fail? check?
  293. _ ...) ;placeholder for new fields
  294. (file-system
  295. (device (match device
  296. (('uuid (? symbol? type) (? bytevector? bv))
  297. (bytevector->uuid bv type))
  298. (('file-system-label (? string? label))
  299. (file-system-label label))
  300. (_
  301. device)))
  302. (mount-point mount-point) (type type)
  303. (flags flags) (options options)
  304. (mount-may-fail? mount-may-fail?)
  305. (check? check?)))))
  306. (define (specification->file-system-mapping spec writable?)
  307. "Read the SPEC and return the corresponding <file-system-mapping>. SPEC is
  308. a string of the form \"SOURCE\" or \"SOURCE=TARGET\". The former specifies
  309. that SOURCE from the host should be mounted at SOURCE in the other system.
  310. The latter format specifies that SOURCE from the host should be mounted at
  311. TARGET in the other system."
  312. (let ((index (string-index spec #\=)))
  313. (if index
  314. (file-system-mapping
  315. (source (substring spec 0 index))
  316. (target (substring spec (+ 1 index)))
  317. (writable? writable?))
  318. (file-system-mapping
  319. (source spec)
  320. (target spec)
  321. (writable? writable?)))))
  322. ;;;
  323. ;;; Common file systems.
  324. ;;;
  325. (define %pseudo-file-system-types
  326. ;; List of know pseudo file system types. This is used when validating file
  327. ;; system definitions.
  328. '("binfmt_misc" "cgroup" "debugfs" "devpts" "devtmpfs" "efivarfs" "fusectl"
  329. "hugetlbfs" "overlay" "proc" "securityfs" "sysfs" "tmpfs"))
  330. (define %fuse-control-file-system
  331. ;; Control file system for Linux' file systems in user-space (FUSE).
  332. (file-system
  333. (device "fusectl")
  334. (mount-point "/sys/fs/fuse/connections")
  335. (type "fusectl")
  336. (check? #f)))
  337. (define %binary-format-file-system
  338. ;; Support for arbitrary executable binary format.
  339. (file-system
  340. (device "binfmt_misc")
  341. (mount-point "/proc/sys/fs/binfmt_misc")
  342. (type "binfmt_misc")
  343. (check? #f)))
  344. (define %debug-file-system
  345. (file-system
  346. (type "debugfs")
  347. (device "none")
  348. (mount-point "/sys/kernel/debug")
  349. (check? #f)
  350. (create-mount-point? #t)))
  351. (define %efivars-file-system
  352. ;; Support for EFI variables file system.
  353. (file-system
  354. (device "efivarfs")
  355. (mount-point "/sys/firmware/efi/efivars")
  356. (type "efivarfs")
  357. (mount-may-fail? #t)
  358. (needed-for-boot? #f)
  359. (check? #f)))
  360. (define %tty-gid
  361. ;; ID of the 'tty' group. Allocate it statically to make it easy to refer
  362. ;; to it from here and from the 'tty' group definitions.
  363. 996)
  364. (define %pseudo-terminal-file-system
  365. ;; The pseudo-terminal file system. It needs to be mounted so that
  366. ;; statfs(2) returns DEVPTS_SUPER_MAGIC like libc's getpt(3) expects (and
  367. ;; thus openpty(3) and its users, such as xterm.)
  368. (file-system
  369. (device "none")
  370. (mount-point "/dev/pts")
  371. (type "devpts")
  372. (check? #f)
  373. (needed-for-boot? #f)
  374. (create-mount-point? #t)
  375. (options (string-append "gid=" (number->string %tty-gid) ",mode=620"))))
  376. (define %shared-memory-file-system
  377. ;; Shared memory.
  378. (file-system
  379. (device "tmpfs")
  380. (mount-point "/dev/shm")
  381. (type "tmpfs")
  382. (check? #f)
  383. (flags '(no-suid no-dev))
  384. (options "size=50%") ;TODO: make size configurable
  385. (create-mount-point? #t)))
  386. (define %immutable-store
  387. ;; Read-only store to avoid users or daemons accidentally modifying it.
  388. ;; 'guix-daemon' has provisions to remount it read-write in its own name
  389. ;; space.
  390. (file-system
  391. (device (%store-prefix))
  392. (mount-point (%store-prefix))
  393. (type "none")
  394. (check? #f)
  395. (flags '(read-only bind-mount no-atime))))
  396. (define %control-groups
  397. (let ((parent (file-system
  398. (device "cgroup")
  399. (mount-point "/sys/fs/cgroup")
  400. (type "tmpfs")
  401. (check? #f))))
  402. (cons parent
  403. (map (lambda (subsystem)
  404. (file-system
  405. (device "cgroup")
  406. (mount-point (string-append "/sys/fs/cgroup/" subsystem))
  407. (type "cgroup")
  408. (check? #f)
  409. (options subsystem)
  410. (create-mount-point? #t)
  411. ;; This must be mounted after, and unmounted before the
  412. ;; parent directory.
  413. (dependencies (list parent))))
  414. '("cpuset" "cpu" "cpuacct" "memory" "devices" "freezer"
  415. "blkio" "perf_event" "pids")))))
  416. (define %elogind-file-systems
  417. ;; We don't use systemd, but these file systems are needed for elogind,
  418. ;; which was extracted from systemd.
  419. (append
  420. (list (file-system
  421. (device "none")
  422. (mount-point "/run/systemd")
  423. (type "tmpfs")
  424. (check? #f)
  425. (flags '(no-suid no-dev no-exec))
  426. (options "mode=0755")
  427. (create-mount-point? #t))
  428. (file-system
  429. (device "none")
  430. (mount-point "/run/user")
  431. (type "tmpfs")
  432. (check? #f)
  433. (flags '(no-suid no-dev no-exec))
  434. (options "mode=0755")
  435. (create-mount-point? #t))
  436. ;; Elogind uses cgroups to organize processes, allowing it to map PIDs
  437. ;; to sessions. Elogind's cgroup hierarchy isn't associated with any
  438. ;; resource controller ("subsystem").
  439. (file-system
  440. (device "cgroup")
  441. (mount-point "/sys/fs/cgroup/elogind")
  442. (type "cgroup")
  443. (check? #f)
  444. (options "none,name=elogind")
  445. (create-mount-point? #t)
  446. (dependencies (list (car %control-groups)))))
  447. %control-groups))
  448. (define %base-file-systems
  449. ;; List of basic file systems to be mounted. Note that /proc and /sys are
  450. ;; currently mounted by the initrd.
  451. (list %pseudo-terminal-file-system
  452. %debug-file-system
  453. %shared-memory-file-system
  454. %efivars-file-system
  455. %immutable-store))
  456. ;; File systems for Linux containers differ from %base-file-systems in that
  457. ;; they impose additional restrictions such as no-exec or need different
  458. ;; options to function properly.
  459. ;;
  460. ;; The file system flags and options conform to the libcontainer
  461. ;; specification:
  462. ;; https://github.com/docker/libcontainer/blob/master/SPEC.md#filesystem
  463. (define %container-file-systems
  464. (list
  465. ;; Pseudo-terminal file system.
  466. (file-system
  467. (device "none")
  468. (mount-point "/dev/pts")
  469. (type "devpts")
  470. (flags '(no-exec no-suid))
  471. (needed-for-boot? #t)
  472. (create-mount-point? #t)
  473. (check? #f)
  474. (options "newinstance,ptmxmode=0666,mode=620"))
  475. ;; Shared memory file system.
  476. (file-system
  477. (device "tmpfs")
  478. (mount-point "/dev/shm")
  479. (type "tmpfs")
  480. (flags '(no-exec no-suid no-dev))
  481. (options "mode=1777,size=65536k")
  482. (needed-for-boot? #t)
  483. (create-mount-point? #t)
  484. (check? #f))
  485. ;; Message queue file system.
  486. (file-system
  487. (device "mqueue")
  488. (mount-point "/dev/mqueue")
  489. (type "mqueue")
  490. (flags '(no-exec no-suid no-dev))
  491. (needed-for-boot? #t)
  492. (create-mount-point? #t)
  493. (check? #f))))
  494. ;;;
  495. ;;; Shared file systems, for VMs/containers.
  496. ;;;
  497. ;; Mapping of host file system SOURCE to mount point TARGET in the guest.
  498. (define-record-type* <file-system-mapping> file-system-mapping
  499. make-file-system-mapping
  500. file-system-mapping?
  501. (source file-system-mapping-source) ;string
  502. (target file-system-mapping-target) ;string
  503. (writable? file-system-mapping-writable? ;Boolean
  504. (default #f)))
  505. (define (file-system-mapping->bind-mount mapping)
  506. "Return a file system that realizes MAPPING, a <file-system-mapping>, using
  507. a bind mount."
  508. (match mapping
  509. (($ <file-system-mapping> source target writable?)
  510. (file-system
  511. (mount-point target)
  512. (device source)
  513. (type "none")
  514. (flags (if writable?
  515. '(bind-mount)
  516. '(bind-mount read-only)))
  517. (check? #f)
  518. (create-mount-point? #t)))))
  519. (define %store-mapping
  520. ;; Mapping of the host's store into the guest.
  521. (file-system-mapping
  522. (source (%store-prefix))
  523. (target (%store-prefix))
  524. (writable? #f)))
  525. (define %network-configuration-files
  526. ;; List of essential network configuration files.
  527. '("/etc/resolv.conf"
  528. "/etc/nsswitch.conf"
  529. "/etc/services"
  530. "/etc/hosts"))
  531. (define %network-file-mappings
  532. ;; List of file mappings for essential network files.
  533. (filter-map (lambda (file)
  534. (file-system-mapping
  535. (source file)
  536. (target file)
  537. ;; XXX: On some GNU/Linux systems, /etc/resolv.conf is a
  538. ;; symlink to a file in a tmpfs which, for an unknown reason,
  539. ;; cannot be bind mounted read-only within the container.
  540. (writable? (string=? file "/etc/resolv.conf"))))
  541. %network-configuration-files))
  542. (define (file-system-type-predicate type)
  543. "Return a predicate that, when passed a file system, returns #t if that file
  544. system has the given TYPE."
  545. (lambda (fs)
  546. (string=? (file-system-type fs) type)))
  547. ;;;
  548. ;;; Btrfs specific helpers.
  549. ;;;
  550. (define (btrfs-subvolume? fs)
  551. "Predicate to check if FS, a file-system object, is a Btrfs subvolume."
  552. (and-let* ((btrfs-file-system? (string= "btrfs" (file-system-type fs)))
  553. (option-keys (map (match-lambda
  554. ((key . value) key)
  555. (key key))
  556. (file-system-options->alist
  557. (file-system-options fs)))))
  558. (find (cut string-prefix? "subvol" <>) option-keys)))
  559. (define (btrfs-store-subvolume-file-name file-systems)
  560. "Return the subvolume file name within the Btrfs top level onto which the
  561. store is located, else #f."
  562. (define (prepend-slash/maybe s)
  563. (if (string=? "/" (string-take s 1))
  564. s
  565. (string-append "/" s)))
  566. (define (file-name-depth file-name)
  567. (length (string-tokenize file-name %not-slash)))
  568. (and-let* ((btrfs-subvolume-fs (filter btrfs-subvolume? file-systems))
  569. (btrfs-subvolume-fs*
  570. (sort btrfs-subvolume-fs
  571. (lambda (fs1 fs2)
  572. (> (file-name-depth (file-system-mount-point fs1))
  573. (file-name-depth (file-system-mount-point fs2))))))
  574. (store-subvolume-fs
  575. (find (lambda (fs) (file-prefix? (file-system-mount-point fs)
  576. (%store-prefix)))
  577. btrfs-subvolume-fs*))
  578. (options (file-system-options->alist
  579. (file-system-options store-subvolume-fs))))
  580. ;; XXX: Deriving the subvolume name based from a subvolume ID is not
  581. ;; supported, as we'd need to query the actual file system.
  582. (or (and=> (assoc-ref options "subvol") prepend-slash/maybe)
  583. (raise (condition
  584. (&message
  585. (message "The store is on a Btrfs subvolume, but the \
  586. subvolume name is unknown."))
  587. (&fix-hint
  588. (hint
  589. (G_ "Use the @code{subvol} Btrfs file system option."))))))))
  590. ;;; file-systems.scm ends here