file-systems: Use a second 'mount' call for read-only bind mounts.
[jackhill/guix/guix.git] / gnu / system / file-systems.scm
CommitLineData
c5df1839
LC
1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2013, 2014 Ludovic Courtès <ludo@gnu.org>
3;;;
4;;; This file is part of GNU Guix.
5;;;
6;;; GNU Guix is free software; you can redistribute it and/or modify it
7;;; under the terms of the GNU General Public License as published by
8;;; the Free Software Foundation; either version 3 of the License, or (at
9;;; your option) any later version.
10;;;
11;;; GNU Guix is distributed in the hope that it will be useful, but
12;;; WITHOUT ANY WARRANTY; without even the implied warranty of
13;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14;;; GNU General Public License for more details.
15;;;
16;;; You should have received a copy of the GNU General Public License
17;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
18
19(define-module (gnu system file-systems)
722554a3 20 #:use-module (guix gexp)
c5df1839
LC
21 #:use-module (guix records)
22 #:export (<file-system>
23 file-system
24 file-system?
25 file-system-device
d4c87617 26 file-system-title
c5df1839
LC
27 file-system-mount-point
28 file-system-type
29 file-system-needed-for-boot?
30 file-system-flags
31 file-system-options
4e469051
LC
32 file-system-check?
33 file-system-create-mount-point?
c5df1839
LC
34
35 %fuse-control-file-system
a69576ea 36 %binary-format-file-system
705f8b68
MW
37 %shared-memory-file-system
38 %pseudo-terminal-file-system
a69576ea
LC
39 %devtmpfs-file-system
40
5dae0186
LC
41 %base-file-systems
42
43 mapped-device
44 mapped-device?
45 mapped-device-source
46 mapped-device-target
722554a3
LC
47 mapped-device-type
48
49 mapped-device-kind
50 mapped-device-kind?
51 mapped-device-kind-open
52 mapped-device-kind-close))
c5df1839
LC
53
54;;; Commentary:
55;;;
56;;; Declaring file systems to be mounted.
57;;;
58;;; Code:
59
60;; File system declaration.
61(define-record-type* <file-system> file-system
62 make-file-system
63 file-system?
64 (device file-system-device) ; string
d4c87617
LC
65 (title file-system-title ; 'device | 'label | 'uuid
66 (default 'device))
c5df1839
LC
67 (mount-point file-system-mount-point) ; string
68 (type file-system-type) ; string
69 (flags file-system-flags ; list of symbols
70 (default '()))
71 (options file-system-options ; string or #f
72 (default #f))
4d6b879c 73 (needed-for-boot? %file-system-needed-for-boot? ; Boolean
c5df1839
LC
74 (default #f))
75 (check? file-system-check? ; Boolean
4e469051
LC
76 (default #t))
77 (create-mount-point? file-system-create-mount-point? ; Boolean
78 (default #f)))
c5df1839 79
4d6b879c
LC
80(define-inlinable (file-system-needed-for-boot? fs)
81 "Return true if FS has the 'needed-for-boot?' flag set, or if it's the root
82file system."
83 (or (%file-system-needed-for-boot? fs)
84 (string=? "/" (file-system-mount-point fs))))
85
c5df1839
LC
86(define %fuse-control-file-system
87 ;; Control file system for Linux' file systems in user-space (FUSE).
88 (file-system
89 (device "fusectl")
90 (mount-point "/sys/fs/fuse/connections")
91 (type "fusectl")
92 (check? #f)))
93
94(define %binary-format-file-system
95 ;; Support for arbitrary executable binary format.
96 (file-system
97 (device "binfmt_misc")
98 (mount-point "/proc/sys/fs/binfmt_misc")
99 (type "binfmt_misc")
100 (check? #f)))
101
a69576ea
LC
102(define %devtmpfs-file-system
103 ;; /dev as a 'devtmpfs' file system, needed for udev.
104 (file-system
105 (device "none")
106 (mount-point "/dev")
107 (type "devtmpfs")
7f239fd3
LC
108 (check? #f)
109
110 ;; Mount it from the initrd so /dev/pts & co. can then be mounted over it.
111 (needed-for-boot? #t)))
112
113(define %tty-gid
114 ;; ID of the 'tty' group. Allocate it statically to make it easy to refer
115 ;; to it from here and from the 'tty' group definitions.
c8fa3426 116 996)
7f239fd3
LC
117
118(define %pseudo-terminal-file-system
119 ;; The pseudo-terminal file system. It needs to be mounted so that
120 ;; statfs(2) returns DEVPTS_SUPER_MAGIC like libc's getpt(3) expects (and
121 ;; thus openpty(3) and its users, such as xterm.)
122 (file-system
123 (device "none")
124 (mount-point "/dev/pts")
125 (type "devpts")
126 (check? #f)
127 (needed-for-boot? #f)
128 (create-mount-point? #t)
129 (options (string-append "gid=" (number->string %tty-gid) ",mode=620"))))
a69576ea 130
db17ae5c
LC
131(define %shared-memory-file-system
132 ;; Shared memory.
133 (file-system
134 (device "tmpfs")
135 (mount-point "/dev/shm")
136 (type "tmpfs")
137 (check? #f)
138 (flags '(no-suid no-dev))
139 (options "size=50%") ;TODO: make size configurable
140 (create-mount-point? #t)))
141
a69576ea
LC
142(define %base-file-systems
143 ;; List of basic file systems to be mounted. Note that /proc and /sys are
144 ;; currently mounted by the initrd.
7f239fd3 145 (list %devtmpfs-file-system
db17ae5c
LC
146 %pseudo-terminal-file-system
147 %shared-memory-file-system))
a69576ea 148
5dae0186
LC
149
150\f
151;;;
152;;; Mapped devices, for Linux's device-mapper.
153;;;
154
155(define-record-type* <mapped-device> mapped-device
156 make-mapped-device
157 mapped-device?
158 (source mapped-device-source) ;string
159 (target mapped-device-target) ;string
9cb426b8 160 (type mapped-device-type)) ;<mapped-device-kind>
722554a3
LC
161
162(define-record-type* <mapped-device-type> mapped-device-kind
163 make-mapped-device-kind
164 mapped-device-kind?
165 (open mapped-device-kind-open) ;source target -> gexp
166 (close mapped-device-kind-close ;source target -> gexp
167 (default (const #~(const #f)))))
5dae0186 168
c5df1839 169;;; file-systems.scm ends here