]>
git.ipfire.org Git - people/ms/systemd.git/blob - mount-setup.c
18d3911be45e9c8f7db174beccfaf6710b427691
1 /*-*- Mode: C; c-basic-offset: 8 -*-*/
4 This file is part of systemd.
6 Copyright 2010 Lennart Poettering
8 systemd is free software; you can redistribute it and/or modify it
9 under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 systemd is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with systemd; If not, see <http://www.gnu.org/licenses/>.
22 #include <sys/mount.h>
30 #include "mount-setup.h"
41 static const char *table
[] = {
42 "proc", "/proc", "proc", NULL
,
43 "sysfs", "/sys", "sysfs", NULL
,
44 "devtmps", "/dev", "devtmpfs", "mode=755",
45 "tmpfs", "/dev/shm", "tmpfs", "mode=1777",
46 "devpts", "/dev/pts", "devpts", NULL
,
47 "cgroup", "/cgroup/debug", "cgroup", "debug",
48 "debugfs", "/sys/kernel/debug", "debugfs", NULL
,
52 static int is_mount_point(const char *t
) {
56 if (lstat(t
, &a
) < 0) {
64 if (!(copy
= strdup(t
)))
67 if (lstat(dirname(copy
), &b
) < 0) {
74 return a
.st_dev
!= b
.st_dev
;
78 static int mount_one(const char *t
[]) {
83 if ((r
= is_mount_point(t
[MOUNT_WHERE
])) < 0)
89 /* The access mode here doesn't really matter too much, since
90 * the mounted file system will take precedence anyway. */
91 mkdir(t
[MOUNT_WHERE
], 0755);
93 log_debug("Mounting %s to %s of type %s with options %s.",
99 if (mount(t
[MOUNT_WHAT
],
103 t
[MOUNT_OPTIONS
]) < 0) {
104 log_error("Failed to mount %s: %s", t
[MOUNT_WHERE
], strerror(errno
));
111 int mount_setup(void) {
115 for (t
= table
; *t
; t
+= MOUNT_SKIP
)
116 if ((r
= mount_one(t
)) < 0)