1
0
mirror of https://github.com/systemd/systemd synced 2026-04-06 23:24:52 +02:00

Compare commits

..

No commits in common. "2ec0c4f94de7091c2f4fdf76742bb793d64de781" and "947796eac385651f6a66fc0ce925a301b49f6fa4" have entirely different histories.

36 changed files with 110 additions and 634 deletions

View File

@ -1089,13 +1089,6 @@ ieee1394:ven000001F2mo*sp000001F2ver00000035
IEEE1394_UNIT_FUNCTION_MIDI=1 IEEE1394_UNIT_FUNCTION_MIDI=1
IEEE1394_UNIT_FUNCTION_AUDIO=1 IEEE1394_UNIT_FUNCTION_AUDIO=1
ieee1394:node:ven0x0001f2units0x0001f2:0x000039
ieee1394:ven000001F2mo*sp000001F2ver00000039
ID_VENDOR_FROM_DATABASE=MOTU
ID_MODEL_FROM_DATABASE=Track 16
IEEE1394_UNIT_FUNCTION_MIDI=1
IEEE1394_UNIT_FUNCTION_AUDIO=1
ieee1394:node:ven0x0001f2units0x0001f2:0x000045 ieee1394:node:ven0x0001f2units0x0001f2:0x000045
ieee1394:ven000001F2mo*sp000001F2ver00000045 ieee1394:ven000001F2mo*sp000001F2ver00000045
ID_VENDOR_FROM_DATABASE=MOTU ID_VENDOR_FROM_DATABASE=MOTU

View File

@ -44,8 +44,9 @@
url="https://www.kernel.org/doc/html/latest/admin-guide/binfmt-misc.html">binfmt-misc.rst</ulink> documentation url="https://www.kernel.org/doc/html/latest/admin-guide/binfmt-misc.html">binfmt-misc.rst</ulink> documentation
file for more information on registration of additional binary formats and how to write rules.</para> file for more information on registration of additional binary formats and how to write rules.</para>
<para>Empty lines and lines beginning with <literal>;</literal> and <literal>#</literal> are ignored. <para>Empty lines and lines beginning with ; and # are ignored.
Note that this means you may not use those symbols as the delimiter in binary format rules.</para> Note that this means you may not use ; and # as delimiter in
binary format rules.</para>
</refsect1> </refsect1>
<xi:include href="standard-conf.xml" xpointer="confd" /> <xi:include href="standard-conf.xml" xpointer="confd" />

View File

@ -52,12 +52,7 @@
systems and swap devices, and after checking that the block device does not already systems and swap devices, and after checking that the block device does not already
contain a file system or other content, it will execute binaries specific to contain a file system or other content, it will execute binaries specific to
each filesystem type (<filename>/sbin/mkfs.<replaceable>type</replaceable></filename> each filesystem type (<filename>/sbin/mkfs.<replaceable>type</replaceable></filename>
or <filename>/sbin/mkswap</filename>). For certain file system types (currently or <filename>/sbin/mkswap</filename>).</para>
ext2/ext3/<citerefentry project='man-pages'><refentrytitle>ext4</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
<citerefentry project='url'><refentrytitle url='https://btrfs.wiki.kernel.org/index.php/Manpage/btrfs(5)'>btrfs</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
<citerefentry project='man-pages'><refentrytitle>xfs</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
f2fs, vfat) and for swap devices, it will configure reasonable defaults and set
the file system label and UUID based on the device name.</para>
<para><filename>systemd-growfs</filename> knows very little about specific file <para><filename>systemd-growfs</filename> knows very little about specific file
systems and swap devices, and will instruct the kernel to grow the mounted systems and swap devices, and will instruct the kernel to grow the mounted

View File

@ -348,6 +348,7 @@ possible_common_cc_flags = [
'-Werror=shift-count-overflow', '-Werror=shift-count-overflow',
'-Werror=shift-overflow=2', '-Werror=shift-overflow=2',
'-Werror=undef', '-Werror=undef',
'-Werror=unused-function',
'-Wfloat-equal', '-Wfloat-equal',
'-Wimplicit-fallthrough=5', '-Wimplicit-fallthrough=5',
'-Winit-self', '-Winit-self',
@ -362,7 +363,6 @@ possible_common_cc_flags = [
'-Wstrict-aliasing=2', '-Wstrict-aliasing=2',
'-Wstrict-prototypes', '-Wstrict-prototypes',
'-Wsuggest-attribute=noreturn', '-Wsuggest-attribute=noreturn',
'-Wunused-function',
'-Wwrite-strings', '-Wwrite-strings',
# negative arguments are correctly detected starting with meson 0.46. # negative arguments are correctly detected starting with meson 0.46.

View File

@ -1850,9 +1850,8 @@ static void filesystem_set_remove(Set *s, const FilesystemSet *set) {
} }
} }
static void dump_filesystem_set(const FilesystemSet *set) { static void dump_filesystem(const FilesystemSet *set) {
const char *filesystem; const char *filesystem;
int r;
if (!set) if (!set)
return; return;
@ -1864,38 +1863,8 @@ static void dump_filesystem_set(const FilesystemSet *set) {
ansi_normal(), ansi_normal(),
set->help); set->help);
NULSTR_FOREACH(filesystem, set->value) { NULSTR_FOREACH(filesystem, set->value)
const statfs_f_type_t *magic; printf(" %s%s%s\n", filesystem[0] == '@' ? ansi_underline() : "", filesystem, ansi_normal());
if (filesystem[0] == '@') {
printf(" %s%s%s\n", ansi_underline(), filesystem, ansi_normal());
continue;
}
r = fs_type_from_string(filesystem, &magic);
assert_se(r >= 0);
printf(" %s", filesystem);
for (size_t i = 0; magic[i] != 0; i++) {
const char *primary;
if (i == 0)
printf(" %s(magic: ", ansi_grey());
else
printf(", ");
printf("0x%llx", (unsigned long long) magic[i]);
primary = fs_type_to_string(magic[i]);
if (primary && !streq(primary, filesystem))
printf("[%s]", primary);
if (magic[i+1] == 0)
printf(")%s", ansi_normal());
}
printf("\n");
}
} }
static int dump_filesystems(int argc, char *argv[], void *userdata) { static int dump_filesystems(int argc, char *argv[], void *userdata) {
@ -1923,7 +1892,7 @@ static int dump_filesystems(int argc, char *argv[], void *userdata) {
if (!first) if (!first)
puts(""); puts("");
dump_filesystem_set(set); dump_filesystem(set);
filesystem_set_remove(kernel, set); filesystem_set_remove(kernel, set);
if (i != FILESYSTEM_SET_KNOWN) if (i != FILESYSTEM_SET_KNOWN)
filesystem_set_remove(known, set); filesystem_set_remove(known, set);
@ -1944,29 +1913,8 @@ static int dump_filesystems(int argc, char *argv[], void *userdata) {
strv_sort(l); strv_sort(l);
STRV_FOREACH(filesystem, l) { STRV_FOREACH(filesystem, l)
const statfs_f_type_t *magic;
bool is_primary = false;
assert(fs_type_from_string(*filesystem, &magic) >= 0);
for (size_t i = 0; magic[i] != 0; i++) {
const char *primary;
primary = fs_type_to_string(magic[i]);
assert(primary);
if (streq(primary, *filesystem))
is_primary = true;
}
if (!is_primary) {
log_debug("Skipping ungrouped file system '%s', because it's an alias for another one.", *filesystem);
continue;
}
printf("# %s\n", *filesystem); printf("# %s\n", *filesystem);
}
} }
if (k < 0) { if (k < 0) {
@ -2008,7 +1956,7 @@ static int dump_filesystems(int argc, char *argv[], void *userdata) {
"Filesystem set \"%s\" not found.", *name); "Filesystem set \"%s\" not found.", *name);
} }
dump_filesystem_set(set); dump_filesystem(set);
first = false; first = false;
} }
} }

View File

@ -13,7 +13,7 @@ static inline void _reset_errno_(int *saved_errno) {
errno = *saved_errno; errno = *saved_errno;
} }
#define PROTECT_ERRNO \ #define PROTECT_ERRNO \
_cleanup_(_reset_errno_) _unused_ int _saved_errno_ = errno _cleanup_(_reset_errno_) _unused_ int _saved_errno_ = errno
#define UNPROTECT_ERRNO \ #define UNPROTECT_ERRNO \

View File

@ -34,11 +34,8 @@ binfmt_misc, {BINFMTFS_MAGIC}
bpf, {BPF_FS_MAGIC} bpf, {BPF_FS_MAGIC}
btrfs, {BTRFS_SUPER_MAGIC} btrfs, {BTRFS_SUPER_MAGIC}
btrfs_test_fs, {BTRFS_TEST_MAGIC} btrfs_test_fs, {BTRFS_TEST_MAGIC}
# cpuset's magic got reassigned to cgroupfs
cpuset, {CGROUP_SUPER_MAGIC}
ceph, {CEPH_SUPER_MAGIC} ceph, {CEPH_SUPER_MAGIC}
cgroup2, {CGROUP2_SUPER_MAGIC} cgroup2, {CGROUP2_SUPER_MAGIC}
# note that the cgroupfs magic got reassigned from cpuset
cgroup, {CGROUP_SUPER_MAGIC} cgroup, {CGROUP_SUPER_MAGIC}
cifs, {CIFS_MAGIC_NUMBER} cifs, {CIFS_MAGIC_NUMBER}
coda, {CODA_SUPER_MAGIC} coda, {CODA_SUPER_MAGIC}
@ -48,24 +45,19 @@ dax, {DAXFS_MAGIC}
debugfs, {DEBUGFS_MAGIC} debugfs, {DEBUGFS_MAGIC}
devmem, {DEVMEM_MAGIC} devmem, {DEVMEM_MAGIC}
devpts, {DEVPTS_SUPER_MAGIC} devpts, {DEVPTS_SUPER_MAGIC}
# devtmpfs is just a special instance of tmpfs, hence it reports its magic
devtmpfs, {TMPFS_MAGIC}
dmabuf, {DMA_BUF_MAGIC} dmabuf, {DMA_BUF_MAGIC}
ecryptfs, {ECRYPTFS_SUPER_MAGIC} ecryptfs, {ECRYPTFS_SUPER_MAGIC}
efivarfs, {EFIVARFS_MAGIC} efivarfs, {EFIVARFS_MAGIC}
efs, {EFS_SUPER_MAGIC} efs, {EFS_SUPER_MAGIC}
erofs, {EROFS_SUPER_MAGIC_V1} erofs, {EROFS_SUPER_MAGIC_V1}
# ext2 + ext3 + ext4 use the same magic
ext2, {EXT2_SUPER_MAGIC} ext2, {EXT2_SUPER_MAGIC}
ext3, {EXT3_SUPER_MAGIC} ext3, {EXT3_SUPER_MAGIC}
ext4, {EXT4_SUPER_MAGIC} ext4, {EXT4_SUPER_MAGIC}
exfat, {EXFAT_SUPER_MAGIC} exfat, {EXFAT_SUPER_MAGIC}
f2fs, {F2FS_SUPER_MAGIC} f2fs, {F2FS_SUPER_MAGIC}
# fuseblk is so closely related to fuse that it shares the same magic
fuseblk, {FUSE_SUPER_MAGIC} fuseblk, {FUSE_SUPER_MAGIC}
fuse, {FUSE_SUPER_MAGIC} fuse, {FUSE_SUPER_MAGIC}
fusectl, {FUSE_CTL_SUPER_MAGIC} fusectl, {FUSE_CTL_SUPER_MAGIC}
# gfs is an old version of gfs2 and reuses the magic
gfs, {GFS2_MAGIC} gfs, {GFS2_MAGIC}
gfs2, {GFS2_MAGIC} gfs2, {GFS2_MAGIC}
hostfs, {HOSTFS_SUPER_MAGIC} hostfs, {HOSTFS_SUPER_MAGIC}
@ -75,18 +67,13 @@ iso9660, {ISOFS_SUPER_MAGIC}
jffs2, {JFFS2_SUPER_MAGIC} jffs2, {JFFS2_SUPER_MAGIC}
minix, {MINIX_SUPER_MAGIC, MINIX_SUPER_MAGIC2, MINIX2_SUPER_MAGIC, MINIX2_SUPER_MAGIC2, MINIX3_SUPER_MAGIC} minix, {MINIX_SUPER_MAGIC, MINIX_SUPER_MAGIC2, MINIX2_SUPER_MAGIC, MINIX2_SUPER_MAGIC2, MINIX3_SUPER_MAGIC}
mqueue, {MQUEUE_MAGIC} mqueue, {MQUEUE_MAGIC}
# msdos is an older legacy version of vfat, shares the magic
msdos, {MSDOS_SUPER_MAGIC} msdos, {MSDOS_SUPER_MAGIC}
# ncp/ncpfs have been removed from the kernel, but ncpfs was the offical name
ncp, {NCP_SUPER_MAGIC} ncp, {NCP_SUPER_MAGIC}
ncpfs, {NCP_SUPER_MAGIC} ncpfs, {NCP_SUPER_MAGIC}
# nfs is the old version of nfs4, and they share the same magic
nfs, {NFS_SUPER_MAGIC} nfs, {NFS_SUPER_MAGIC}
nfs4, {NFS_SUPER_MAGIC} nfs4, {NFS_SUPER_MAGIC}
nilfs2, {NILFS_SUPER_MAGIC} nilfs2, {NILFS_SUPER_MAGIC}
nsfs, {NSFS_MAGIC} nsfs, {NSFS_MAGIC}
ntfs, {NTFS_SB_MAGIC}
ntfs3, {NTFS3_SUPER_MAGIC}
ocfs2, {OCFS2_SUPER_MAGIC} ocfs2, {OCFS2_SUPER_MAGIC}
openpromfs, {OPENPROM_SUPER_MAGIC} openpromfs, {OPENPROM_SUPER_MAGIC}
orangefs, {ORANGEFS_DEVREQ_MAGIC} orangefs, {ORANGEFS_DEVREQ_MAGIC}
@ -95,33 +82,27 @@ pipefs, {PIPEFS_MAGIC}
ppc-cmm, {PPC_CMM_MAGIC} ppc-cmm, {PPC_CMM_MAGIC}
proc, {PROC_SUPER_MAGIC} proc, {PROC_SUPER_MAGIC}
pstore, {PSTOREFS_MAGIC} pstore, {PSTOREFS_MAGIC}
# pvfs2 is the old version of orangefs
pvfs2, {ORANGEFS_DEVREQ_MAGIC} pvfs2, {ORANGEFS_DEVREQ_MAGIC}
qnx4, {QNX4_SUPER_MAGIC} qnx4, {QNX4_SUPER_MAGIC}
qnx6, {QNX6_SUPER_MAGIC} qnx6, {QNX6_SUPER_MAGIC}
ramfs, {RAMFS_MAGIC} ramfs, {RAMFS_MAGIC}
resctrl, {RDTGROUP_SUPER_MAGIC} resctrl, {RDTGROUP_SUPER_MAGIC}
reiserfs, {REISERFS_SUPER_MAGIC} reiserfs, {REISERFS_SUPER_MAGIC}
rpc_pipefs, {RPC_PIPEFS_SUPER_MAGIC}
secretmem, {SECRETMEM_MAGIC} secretmem, {SECRETMEM_MAGIC}
securityfs, {SECURITYFS_MAGIC} securityfs, {SECURITYFS_MAGIC}
selinuxfs, {SELINUX_MAGIC} selinuxfs, {SELINUX_MAGIC}
shiftfs, {SHIFTFS_MAGIC} shiftfs, {SHIFTFS_MAGIC}
smackfs, {SMACK_MAGIC} smackfs, {SMACK_MAGIC}
# smb3 is an alias for cifs smb3, {SMB_SUPER_MAGIC}
smb3, {CIFS_MAGIC_NUMBER}
# smbfs was removed from the kernel in 2010, the magic remains
smbfs, {SMB_SUPER_MAGIC} smbfs, {SMB_SUPER_MAGIC}
sockfs, {SOCKFS_MAGIC} sockfs, {SOCKFS_MAGIC}
squashfs, {SQUASHFS_MAGIC} squashfs, {SQUASHFS_MAGIC}
sysfs, {SYSFS_MAGIC} sysfs, {SYSFS_MAGIC}
# note that devtmpfs shares the same magic with tmpfs, given it is just a special named instance of it.
tmpfs, {TMPFS_MAGIC} tmpfs, {TMPFS_MAGIC}
tracefs, {TRACEFS_MAGIC} tracefs, {TRACEFS_MAGIC}
udf, {UDF_SUPER_MAGIC} udf, {UDF_SUPER_MAGIC}
usbdevfs, {USBDEVICE_SUPER_MAGIC} usbdevfs, {USBDEVICE_SUPER_MAGIC}
vboxsf, {VBOXSF_SUPER_MAGIC} vboxsf, {VBOXSF_SUPER_MAGIC}
# note that msdos shares the same magic (and is the older version)
vfat, {MSDOS_SUPER_MAGIC} vfat, {MSDOS_SUPER_MAGIC}
v9fs, {V9FS_MAGIC} v9fs, {V9FS_MAGIC}
xenfs, {XENFS_SUPER_MAGIC} xenfs, {XENFS_SUPER_MAGIC}

View File

@ -1,17 +1,6 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* SPDX-License-Identifier: LGPL-2.1-or-later */
#include "filesystems-gperf.h" #include "filesystems-gperf.h"
#include "stat-util.h"
const char *fs_type_to_string(statfs_f_type_t magic) {
switch (magic) {
#include "filesystem-switch-case.h"
}
return NULL;
}
int fs_type_from_string(const char *name, const statfs_f_type_t **ret) { int fs_type_from_string(const char *name, const statfs_f_type_t **ret) {
const struct FilesystemMagic *fs_magic; const struct FilesystemMagic *fs_magic;
@ -24,6 +13,7 @@ int fs_type_from_string(const char *name, const statfs_f_type_t **ret) {
return -EINVAL; return -EINVAL;
*ret = fs_magic->magic; *ret = fs_magic->magic;
return 0; return 0;
} }
@ -57,37 +47,18 @@ const FilesystemSet filesystem_sets[_FILESYSTEM_SET_MAX] = {
"cgroup\0" "cgroup\0"
"cgroup2\0" "cgroup2\0"
"devpts\0" "devpts\0"
"devtmpfs\0"
"mqueue\0" "mqueue\0"
"proc\0" "proc\0"
"sysfs\0" "sysfs\0"
}, },
[FILESYSTEM_SET_ANONYMOUS] = {
.name = "@anonymous",
.help = "Anonymous inodes",
.value =
"anon_inodefs\0"
"pipefs\0"
"sockfs\0"
},
[FILESYSTEM_SET_APPLICATION] = {
.name = "@application",
.help = "Application virtual filesystems",
.value =
"autofs\0"
"fuse\0"
"overlay\0"
},
[FILESYSTEM_SET_AUXILIARY_API] = { [FILESYSTEM_SET_AUXILIARY_API] = {
.name = "@auxiliary-api", .name = "@auxiliary-api",
.help = "Auxiliary filesystem API", .help = "Auxiliary filesystem API",
.value = .value =
"binfmt_misc\0"
"configfs\0" "configfs\0"
"efivarfs\0" "efivarfs\0"
"fusectl\0" "fusectl\0"
"hugetlbfs\0" "hugetlbfs\0"
"rpc_pipefs\0"
"securityfs\0" "securityfs\0"
}, },
[FILESYSTEM_SET_COMMON_BLOCK] = { [FILESYSTEM_SET_COMMON_BLOCK] = {
@ -95,14 +66,7 @@ const FilesystemSet filesystem_sets[_FILESYSTEM_SET_MAX] = {
.help = "Common block device filesystems", .help = "Common block device filesystems",
.value = .value =
"btrfs\0" "btrfs\0"
"erofs\0"
"exfat\0"
"ext4\0" "ext4\0"
"f2fs\0"
"iso9660\0"
"ntfs3\0"
"squashfs\0"
"udf\0"
"vfat\0" "vfat\0"
"xfs\0" "xfs\0"
}, },
@ -119,16 +83,14 @@ const FilesystemSet filesystem_sets[_FILESYSTEM_SET_MAX] = {
.help = "Well-known network filesystems", .help = "Well-known network filesystems",
.value = .value =
"afs\0" "afs\0"
"ceph\0"
"cifs\0" "cifs\0"
"gfs\0" "gfs\0"
"gfs2\0" "gfs2\0"
"ncp\0"
"ncpfs\0" "ncpfs\0"
"ncp\0"
"nfs\0" "nfs\0"
"nfs4\0" "nfs4\0"
"ocfs2\0" "ocfs2\0"
"orangefs\0"
"pvfs2\0" "pvfs2\0"
"smb3\0" "smb3\0"
"smbfs\0" "smbfs\0"
@ -142,14 +104,6 @@ const FilesystemSet filesystem_sets[_FILESYSTEM_SET_MAX] = {
"pstore\0" "pstore\0"
"tracefs\0" "tracefs\0"
}, },
[FILESYSTEM_SET_SECURITY] = {
.name = "@security",
.help = "Security/MAC API VFS",
.value =
"apparmorfs\0"
"selinuxfs\0"
"smackfs\0"
},
[FILESYSTEM_SET_TEMPORARY] = { [FILESYSTEM_SET_TEMPORARY] = {
.name = "@temporary", .name = "@temporary",
.help = "Temporary filesystems", .help = "Temporary filesystems",

View File

@ -10,14 +10,11 @@
typedef enum FilesystemGroups { typedef enum FilesystemGroups {
/* Please leave BASIC_API first and KNOWN last, but sort the rest alphabetically */ /* Please leave BASIC_API first and KNOWN last, but sort the rest alphabetically */
FILESYSTEM_SET_BASIC_API, FILESYSTEM_SET_BASIC_API,
FILESYSTEM_SET_ANONYMOUS,
FILESYSTEM_SET_APPLICATION,
FILESYSTEM_SET_AUXILIARY_API, FILESYSTEM_SET_AUXILIARY_API,
FILESYSTEM_SET_COMMON_BLOCK, FILESYSTEM_SET_COMMON_BLOCK,
FILESYSTEM_SET_HISTORICAL_BLOCK, FILESYSTEM_SET_HISTORICAL_BLOCK,
FILESYSTEM_SET_NETWORK, FILESYSTEM_SET_NETWORK,
FILESYSTEM_SET_PRIVILEGED_API, FILESYSTEM_SET_PRIVILEGED_API,
FILESYSTEM_SET_SECURITY,
FILESYSTEM_SET_TEMPORARY, FILESYSTEM_SET_TEMPORARY,
FILESYSTEM_SET_KNOWN, FILESYSTEM_SET_KNOWN,
_FILESYSTEM_SET_MAX, _FILESYSTEM_SET_MAX,
@ -34,7 +31,6 @@ extern const FilesystemSet filesystem_sets[];
const FilesystemSet *filesystem_set_find(const char *name); const FilesystemSet *filesystem_set_find(const char *name);
const char *fs_type_to_string(statfs_f_type_t magic);
int fs_type_from_string(const char *name, const statfs_f_type_t **ret); int fs_type_from_string(const char *name, const statfs_f_type_t **ret);
int fs_in_group(const struct statfs *s, enum FilesystemGroups fs_group); int fs_in_group(const struct statfs *s, enum FilesystemGroups fs_group);

View File

@ -6,9 +6,6 @@ import sys
keywords_section = False keywords_section = False
for line in open(sys.argv[1]): for line in open(sys.argv[1]):
if line[0] == '#':
continue
if keywords_section: if keywords_section:
print('"{}\\0"'.format(line.split(',')[0].strip())) print('"{}\\0"'.format(line.split(',')[0].strip()))
elif line.startswith('%%'): elif line.startswith('%%'):

View File

@ -1,63 +0,0 @@
#!/usr/bin/env python3
# SPDX-License-Identifier: LGPL-2.1-or-later
import sys
def filter_fsname(name):
# File system magics are sometimes not unique, because file systems got new
# revisions or got renamed. Let's prefer newer over older here, and thus
# ignore the old names. Specifically:
#
# → cgroupfs took over the magic of cpuset
# → devtmpfs is not a file system of its own, but just a "named superblock" of tmpfs
# → ext4 is the newest revision of ext2 + ext3
# → fuseblk is closely related to fuse, so close that they share a single magic, but the latter is more common
# → gfs2 is the newest revision of gfs
# → vfat is the newest revision of msdos
# → ncpfs (not ncp) was the last name of the netware `file_system_type` name before it was removed in 2018
# → nfs4 is the newest revision of nfs
# → orangefs is the new name of pvfs2
# → smb3 is an alias for cifs
return name in (
"cpuset",
"devtmpfs",
"ext2",
"ext3",
"fuseblk",
"gfs",
"msdos",
"ncp",
"nfs",
"pvfs2",
"smb3",
)
gperf_file = sys.argv[1]
keywords_section = False
for line in open(gperf_file):
if line[0] == "#":
continue
if keywords_section:
name, ids = line.split(",", 1)
name = name.strip()
if filter_fsname(name):
continue
ids = ids.strip()
assert ids[0] == "{"
assert ids[-1] == "}"
ids = ids[1:-1]
for id in ids.split(","):
print(f"case (statfs_f_type_t) {id.strip()}:")
print(f' return "{name}";')
if line.startswith("%%"):
keywords_section = True

View File

@ -383,8 +383,8 @@ filesystem_includes = ['linux/magic.h',
check_filesystems = find_program('check-filesystems.sh') check_filesystems = find_program('check-filesystems.sh')
r = run_command([check_filesystems, cpp, 'filesystems-gperf.gperf'] + filesystem_includes) r = run_command([check_filesystems, cpp, 'filesystems-gperf.gperf'] + filesystem_includes)
if r.returncode() != 0 if r.returncode() != 0
error('found unknown filesystem(s) defined in kernel headers:\n\n' + r.stdout()) error('found unknown filesystem(s) defined in kernel headers:\n\n' + r.stdout())
r.stdout() r.stdout()
endif endif
filesystems_gperf_h = custom_target( filesystems_gperf_h = custom_target(
@ -403,17 +403,7 @@ filesystem_list_h = custom_target(
'@INPUT@'], '@INPUT@'],
capture : true) capture : true)
generate_filesystem_switch_case_h = find_program('generate-filesystem-switch-case.py') basic_sources += [filesystem_list_h, filesystems_gperf_h]
fname = 'filesystem-switch-case.h'
filesystem_switch_case_h = custom_target(
fname,
input : 'filesystems-gperf.gperf',
output : 'filesystem-switch-case.h',
command : [generate_filesystem_switch_case_h,
'@INPUT@'],
capture : true)
basic_sources += [filesystem_list_h, filesystem_switch_case_h, filesystems_gperf_h]
libbasic = static_library( libbasic = static_library(
'basic', 'basic',

View File

@ -172,18 +172,3 @@
#ifndef EXFAT_SUPER_MAGIC #ifndef EXFAT_SUPER_MAGIC
#define EXFAT_SUPER_MAGIC 0x2011BAB0UL #define EXFAT_SUPER_MAGIC 0x2011BAB0UL
#endif #endif
/* Not exposed yet, internally actually called RPCAUTH_GSSMAGIC. Defined in net/sunrpc/rpc_pipe.c */
#ifndef RPC_PIPEFS_SUPER_MAGIC
#define RPC_PIPEFS_SUPER_MAGIC 0x67596969
#endif
/* Not exposed yet, defined at fs/ntfs/ntfs.h */
#ifndef NTFS_SB_MAGIC
#define NTFS_SB_MAGIC 0x5346544e
#endif
/* Not exposed yet, encoded literally in fs/ntfs3/super.c. */
#ifndef NTFS3_SUPER_MAGIC
#define NTFS3_SUPER_MAGIC 0x7366746e
#endif

View File

@ -373,6 +373,7 @@ bool fstype_is_network(const char *fstype) {
/* Filesystems not present in the internal database */ /* Filesystems not present in the internal database */
return STR_IN_SET(fstype, return STR_IN_SET(fstype,
"ceph",
"davfs", "davfs",
"glusterfs", "glusterfs",
"lustre", "lustre",
@ -411,8 +412,8 @@ bool fstype_is_ro(const char *fstype) {
/* All Linux file systems that are necessarily read-only */ /* All Linux file systems that are necessarily read-only */
return STR_IN_SET(fstype, return STR_IN_SET(fstype,
"DM_verity_hash", "DM_verity_hash",
"erofs",
"iso9660", "iso9660",
"erofs",
"squashfs"); "squashfs");
} }

View File

@ -124,9 +124,11 @@ int utf8_encoded_to_unichar(const char *str, char32_t *ret_unichar) {
} }
bool utf8_is_printable_newline(const char* str, size_t length, bool allow_newline) { bool utf8_is_printable_newline(const char* str, size_t length, bool allow_newline) {
const char *p;
assert(str); assert(str);
for (const char *p = str; length > 0;) { for (p = str; length > 0;) {
int encoded_len, r; int encoded_len, r;
char32_t val; char32_t val;
@ -287,12 +289,14 @@ char *utf8_escape_non_printable_full(const char *str, size_t console_width, bool
} }
char *ascii_is_valid(const char *str) { char *ascii_is_valid(const char *str) {
const char *p;
/* Check whether the string consists of valid ASCII bytes, /* Check whether the string consists of valid ASCII bytes,
* i.e values between 0 and 127, inclusive. */ * i.e values between 0 and 127, inclusive. */
assert(str); assert(str);
for (const char *p = str; *p; p++) for (p = str; *p; p++)
if ((unsigned char) *p >= 128) if ((unsigned char) *p >= 128)
return NULL; return NULL;
@ -312,37 +316,6 @@ char *ascii_is_valid_n(const char *str, size_t len) {
return (char*) str; return (char*) str;
} }
int utf8_to_ascii(const char *str, char replacement_char, char **ret) {
/* Convert to a string that has only ASCII chars, replacing anything that is not ASCII
* by replacement_char. */
_cleanup_free_ char *ans = new(char, strlen(str) + 1);
if (!ans)
return -ENOMEM;
char *q = ans;
for (const char *p = str; *p; q++) {
int l;
l = utf8_encoded_valid_unichar(p, SIZE_MAX);
if (l < 0) /* Non-UTF-8, let's not even try to propagate the garbage */
return l;
if (l == 1)
*q = *p;
else
/* non-ASCII, we need to replace it */
*q = replacement_char;
p += l;
}
*q = '\0';
*ret = TAKE_PTR(ans);
return 0;
}
/** /**
* utf8_encode_unichar() - Encode single UCS-4 character as UTF-8 * utf8_encode_unichar() - Encode single UCS-4 character as UTF-8
* @out_utf8: output buffer of at least 4 bytes or NULL * @out_utf8: output buffer of at least 4 bytes or NULL

View File

@ -21,8 +21,6 @@ static inline char *utf8_is_valid(const char *s) {
char *ascii_is_valid(const char *s) _pure_; char *ascii_is_valid(const char *s) _pure_;
char *ascii_is_valid_n(const char *str, size_t len); char *ascii_is_valid_n(const char *str, size_t len);
int utf8_to_ascii(const char *str, char replacement_char, char **ret);
bool utf8_is_printable_newline(const char* str, size_t length, bool allow_newline) _pure_; bool utf8_is_printable_newline(const char* str, size_t length, bool allow_newline) _pure_;
#define utf8_is_printable(str, length) utf8_is_printable_newline(str, length, true) #define utf8_is_printable(str, length) utf8_is_printable_newline(str, length, true)

View File

@ -17,7 +17,6 @@
#include "errno-util.h" #include "errno-util.h"
#include "fd-util.h" #include "fd-util.h"
#include "fileio.h" #include "fileio.h"
#include "filesystems.h"
#include "fs-util.h" #include "fs-util.h"
#include "home-util.h" #include "home-util.h"
#include "homed-home-bus.h" #include "homed-home-bus.h"
@ -2467,6 +2466,19 @@ int home_get_disk_status(
ret_access_mode); ret_access_mode);
} }
static const char *fstype_magic_to_name(statfs_f_type_t magic) {
/* For now, let's only translate the magic values of the file systems we actually are able to manage */
if (F_TYPE_EQUAL(magic, EXT4_SUPER_MAGIC))
return "ext4";
if (F_TYPE_EQUAL(magic, XFS_SUPER_MAGIC))
return "xfs";
if (F_TYPE_EQUAL(magic, BTRFS_SUPER_MAGIC))
return "btrfs";
return NULL;
}
int home_augment_status( int home_augment_status(
Home *h, Home *h,
UserRecordLoadFlags flags, UserRecordLoadFlags flags,
@ -2506,7 +2518,7 @@ int home_augment_status(
if (r < 0) if (r < 0)
return r; return r;
fstype = fs_type_to_string(magic); fstype = fstype_magic_to_name(magic);
if (disk_floor == UINT64_MAX || (disk_usage != UINT64_MAX && disk_floor < disk_usage)) if (disk_floor == UINT64_MAX || (disk_usage != UINT64_MAX && disk_floor < disk_usage))
disk_floor = disk_usage; disk_floor = disk_usage;

View File

@ -13,8 +13,6 @@
#endif #endif
#include "sd-daemon.h" #include "sd-daemon.h"
#include "sd-device.h"
#include "sd-event.h"
#include "blkid-util.h" #include "blkid-util.h"
#include "blockdev-util.h" #include "blockdev-util.h"
@ -47,7 +45,6 @@
#include "strv.h" #include "strv.h"
#include "sync-util.h" #include "sync-util.h"
#include "tmpfile-util.h" #include "tmpfile-util.h"
#include "udev-util.h"
#include "user-util.h" #include "user-util.h"
/* Round down to the nearest 4K size. Given that newer hardware generally prefers 4K sectors, let's align our /* Round down to the nearest 4K size. Given that newer hardware generally prefers 4K sectors, let's align our
@ -1509,7 +1506,6 @@ int home_deactivate_luks(UserRecord *h, HomeSetup *setup) {
} }
} }
(void) wait_for_block_device_gone(setup, USEC_PER_SEC * 30);
setup->undo_dm = false; setup->undo_dm = false;
if (user_record_luks_offline_discard(h)) if (user_record_luks_offline_discard(h))
@ -3200,127 +3196,3 @@ int home_unlock_luks(UserRecord *h, HomeSetup *setup, const PasswordCache *cache
log_info("LUKS device resumed."); log_info("LUKS device resumed.");
return 0; return 0;
} }
static int device_is_gone(HomeSetup *setup) {
_cleanup_(sd_device_unrefp) sd_device *d = NULL;
struct stat st;
int r;
assert(setup);
if (!setup->dm_node)
return true;
if (stat(setup->dm_node, &st) < 0) {
if (errno != ENOENT)
return log_error_errno(errno, "Failed to stat block device node %s: %m", setup->dm_node);
return true;
}
r = sd_device_new_from_stat_rdev(&d, &st);
if (r < 0) {
if (r != -ENODEV)
return log_error_errno(errno, "Failed to allocate device object from block device node %s: %m", setup->dm_node);
return true;
}
return false;
}
static int device_monitor_handler(sd_device_monitor *monitor, sd_device *device, void *userdata) {
HomeSetup *setup = userdata;
int r;
assert(setup);
if (!device_for_action(device, SD_DEVICE_REMOVE))
return 0;
/* We don't really care for the device object passed to us, we just check if the device node still
* exists */
r = device_is_gone(setup);
if (r < 0)
return r;
if (r > 0) /* Yay! we are done! */
(void) sd_event_exit(sd_device_monitor_get_event(monitor), 0);
return 0;
}
int wait_for_block_device_gone(HomeSetup *setup, usec_t timeout_usec) {
_cleanup_(sd_device_monitor_unrefp) sd_device_monitor *m = NULL;
_cleanup_(sd_event_unrefp) sd_event *event = NULL;
int r;
assert(setup);
/* So here's the thing: we enable "deferred deactivation" on our dm-crypt volumes. This means they
* are automatically torn down once not used anymore (i.e. once unmounted). Which is great. It also
* means that when we deactivate a home directory and try to tear down the volume that backs it, it
* possibly is aleady torn down or in the process of being torn down, since we race against the
* automatic tearing down. Which is fine, we handle errors from that. However, we lose the ability to
* naturally wait for the tear down operation to complete: if we are not the ones who tear down the
* device we are also not the ones who naturally block on that operation. Hence let's add some code
* to actively wait for the device to go away, via sd-device. We'll call this whenever tearing down a
* LUKS device, to ensure the device is really really gone before we proceed. Net effect: "homectl
* deactivate foo && homectl activate foo" will work reliably, i.e. deactivation immediately followed
* by activation will work. Also, by the time deactivation completes we can guarantee that all data
* is sync'ed down to the lowest block layer as all higher levels are fully and entirely
* destructed. */
if (!setup->dm_name)
return 0;
assert(setup->dm_node);
log_debug("Waiting until %s disappears.", setup->dm_node);
r = sd_event_new(&event);
if (r < 0)
return log_error_errno(r, "Failed to allocate event loop: %m");
r = sd_device_monitor_new(&m);
if (r < 0)
return log_error_errno(r, "Failed to allocate device monitor: %m");
r = sd_device_monitor_filter_add_match_subsystem_devtype(m, "block", "disk");
if (r < 0)
return log_error_errno(r, "Failed to configure device monitor match: %m");
r = sd_device_monitor_attach_event(m, event);
if (r < 0)
return log_error_errno(r, "Failed to attach device monitor to event loop: %m");
r = sd_device_monitor_start(m, device_monitor_handler, setup);
if (r < 0)
return log_error_errno(r, "Failed to start device monitor: %m");
r = device_is_gone(setup);
if (r < 0)
return r;
if (r > 0) {
log_debug("%s has already disappeared before entering wait loop.", setup->dm_node);
return 0; /* gone already */
}
if (timeout_usec != USEC_INFINITY) {
r = sd_event_add_time_relative(event, NULL, CLOCK_MONOTONIC, timeout_usec, 0, NULL, NULL);
if (r < 0)
return log_error_errno(r, "Failed to add timer event: %m");
}
r = sd_event_loop(event);
if (r < 0)
return log_error_errno(r, "Failed to run event loop: %m");
r = device_is_gone(setup);
if (r < 0)
return r;
if (r == 0)
return log_error_errno(r, "Device %s still around.", setup->dm_node);
log_debug("Successfully waited until device %s disappeared.", setup->dm_node);
return 0;
}

View File

@ -43,5 +43,3 @@ int run_fallocate(int backing_fd, const struct stat *st);
int run_fallocate_by_path(const char *backing_path); int run_fallocate_by_path(const char *backing_path);
int run_mark_dirty(int fd, bool b); int run_mark_dirty(int fd, bool b);
int run_mark_dirty_by_path(const char *path, bool b); int run_mark_dirty_by_path(const char *path, bool b);
int wait_for_block_device_gone(HomeSetup *setup, usec_t timeout_usec);

View File

@ -8,7 +8,6 @@
#include "copy.h" #include "copy.h"
#include "fd-util.h" #include "fd-util.h"
#include "fileio.h" #include "fileio.h"
#include "filesystems.h"
#include "fs-util.h" #include "fs-util.h"
#include "home-util.h" #include "home-util.h"
#include "homework-cifs.h" #include "homework-cifs.h"
@ -326,10 +325,6 @@ int home_setup_undo_dm(HomeSetup *setup, int level) {
if (r < 0) if (r < 0)
return log_full_errno(level, r, "Failed to deactivate LUKS device: %m"); return log_full_errno(level, r, "Failed to deactivate LUKS device: %m");
/* In case the device was already remove asynchronously by an early unmount via the deferred
* remove logic, let's wait for it */
(void) wait_for_block_device_gone(setup, USEC_PER_SEC * 30);
setup->undo_dm = false; setup->undo_dm = false;
ret = 1; ret = 1;
} else } else
@ -709,7 +704,14 @@ static const char *file_system_type_fd(int fd) {
return NULL; return NULL;
} }
return fs_type_to_string(sfs.f_type); if (is_fs_type(&sfs, XFS_SB_MAGIC))
return "xfs";
if (is_fs_type(&sfs, EXT4_SUPER_MAGIC))
return "ext4";
if (is_fs_type(&sfs, BTRFS_SUPER_MAGIC))
return "btrfs";
return NULL;
} }
int home_extend_embedded_identity(UserRecord *h, UserRecord *used, HomeSetup *setup) { int home_extend_embedded_identity(UserRecord *h, UserRecord *used, HomeSetup *setup) {

View File

@ -12,8 +12,8 @@
#include "user-record-util.h" #include "user-record-util.h"
typedef struct HomeSetup { typedef struct HomeSetup {
char *dm_name; /* "home-<username>" */ char *dm_name;
char *dm_node; /* "/dev/mapper/home-<username>" */ char *dm_node;
LoopDevice *loop; LoopDevice *loop;
struct crypt_device *crypt_device; struct crypt_device *crypt_device;

View File

@ -59,10 +59,10 @@ static int netdev_tuntap_add(NetDev *netdev, struct ifreq *ifr) {
fd = open(TUN_DEV, O_RDWR|O_CLOEXEC); fd = open(TUN_DEV, O_RDWR|O_CLOEXEC);
if (fd < 0) if (fd < 0)
return log_netdev_error_errno(netdev, errno, "Failed to open tun dev: %m"); return log_netdev_error_errno(netdev, -errno, "Failed to open tun dev: %m");
if (ioctl(fd, TUNSETIFF, ifr) < 0) if (ioctl(fd, TUNSETIFF, ifr) < 0)
return log_netdev_error_errno(netdev, errno, "TUNSETIFF failed on tun dev: %m"); return log_netdev_error_errno(netdev, -errno, "TUNSETIFF failed on tun dev: %m");
if (netdev->kind == NETDEV_KIND_TAP) if (netdev->kind == NETDEV_KIND_TAP)
t = TAP(netdev); t = TAP(netdev);
@ -79,7 +79,7 @@ static int netdev_tuntap_add(NetDev *netdev, struct ifreq *ifr) {
return log_netdev_error_errno(netdev, r, "Cannot resolve user name %s: %m", t->user_name); return log_netdev_error_errno(netdev, r, "Cannot resolve user name %s: %m", t->user_name);
if (ioctl(fd, TUNSETOWNER, uid) < 0) if (ioctl(fd, TUNSETOWNER, uid) < 0)
return log_netdev_error_errno(netdev, errno, "TUNSETOWNER failed on tun dev: %m"); return log_netdev_error_errno(netdev, -errno, "TUNSETOWNER failed on tun dev: %m");
} }
if (t->group_name) { if (t->group_name) {
@ -90,12 +90,12 @@ static int netdev_tuntap_add(NetDev *netdev, struct ifreq *ifr) {
return log_netdev_error_errno(netdev, r, "Cannot resolve group name %s: %m", t->group_name); return log_netdev_error_errno(netdev, r, "Cannot resolve group name %s: %m", t->group_name);
if (ioctl(fd, TUNSETGROUP, gid) < 0) if (ioctl(fd, TUNSETGROUP, gid) < 0)
return log_netdev_error_errno(netdev, errno, "TUNSETGROUP failed on tun dev: %m"); return log_netdev_error_errno(netdev, -errno, "TUNSETGROUP failed on tun dev: %m");
} }
if (ioctl(fd, TUNSETPERSIST, 1) < 0) if (ioctl(fd, TUNSETPERSIST, 1) < 0)
return log_netdev_error_errno(netdev, errno, "TUNSETPERSIST failed on tun dev: %m"); return log_netdev_error_errno(netdev, -errno, "TUNSETPERSIST failed on tun dev: %m");
return 0; return 0;
} }

View File

@ -14,7 +14,6 @@
#include "networkd-manager.h" #include "networkd-manager.h"
#include "networkd-network.h" #include "networkd-network.h"
#include "networkd-queue.h" #include "networkd-queue.h"
#include "networkd-route-util.h"
#include "networkd-route.h" #include "networkd-route.h"
#include "parse-util.h" #include "parse-util.h"
#include "string-util.h" #include "string-util.h"
@ -1771,14 +1770,21 @@ int config_parse_address_scope(
return 0; return 0;
} }
r = route_scope_from_string(rvalue); if (streq(rvalue, "host"))
if (r < 0) { n->scope = RT_SCOPE_HOST;
log_syntax(unit, LOG_WARNING, filename, line, r, else if (streq(rvalue, "link"))
"Could not parse address scope \"%s\", ignoring assignment: %m", rvalue); n->scope = RT_SCOPE_LINK;
return 0; else if (streq(rvalue, "global"))
n->scope = RT_SCOPE_UNIVERSE;
else {
r = safe_atou8(rvalue , &n->scope);
if (r < 0) {
log_syntax(unit, LOG_WARNING, filename, line, r,
"Could not parse address scope \"%s\", ignoring assignment: %m", rvalue);
return 0;
}
} }
n->scope = r;
n->scope_set = true; n->scope_set = true;
TAKE_PTR(n); TAKE_PTR(n);
return 0; return 0;
@ -1918,8 +1924,8 @@ static int address_section_verify(Address *address) {
if (address->scope_set && address->scope != RT_SCOPE_HOST) if (address->scope_set && address->scope != RT_SCOPE_HOST)
log_warning_errno(SYNTHETIC_ERRNO(EINVAL), log_warning_errno(SYNTHETIC_ERRNO(EINVAL),
"%s: non-host scope is set for localhost address. " "%s: non-host scope is set in the [Address] section from line %u. "
"Ignoring Scope= setting in the [Address] section from line %u. ", "Ignoring Scope= setting.",
address->section->filename, address->section->line); address->section->filename, address->section->line);
address->scope = RT_SCOPE_HOST; address->scope = RT_SCOPE_HOST;

View File

@ -49,7 +49,7 @@ static int run(int argc, char *argv[]) {
if (lock_fd < 0) if (lock_fd < 0)
return log_error_errno(lock_fd, "Failed to lock whole block device of \"%s\": %m", device); return log_error_errno(lock_fd, "Failed to lock whole block device of \"%s\": %m", device);
} else } else
log_debug("%s is not a block device, no need to lock.", device); log_info("%s is not a block device.", device);
r = probe_filesystem(device, &detected); r = probe_filesystem(device, &detected);
if (r == -EUCLEAN) if (r == -EUCLEAN)

View File

@ -8,7 +8,6 @@
#include "process-util.h" #include "process-util.h"
#include "stdio-util.h" #include "stdio-util.h"
#include "string-util.h" #include "string-util.h"
#include "utf8.h"
int mkfs_exists(const char *fstype) { int mkfs_exists(const char *fstype) {
const char *mkfs; const char *mkfs;
@ -32,60 +31,6 @@ int mkfs_exists(const char *fstype) {
return true; return true;
} }
static int mangle_linux_fs_label(const char *s, size_t max_len, char **ret) {
/* Not more than max_len bytes (12 or 16) */
assert(s);
assert(max_len > 0);
assert(ret);
const char *q;
char *ans;
for (q = s; *q;) {
int l;
l = utf8_encoded_valid_unichar(q, SIZE_MAX);
if (l < 0)
return l;
if ((size_t) (q - s + l) > max_len)
break;
q += l;
}
ans = memdup_suffix0(s, q - s);
if (!ans)
return -ENOMEM;
*ret = ans;
return 0;
}
static int mangle_fat_label(const char *s, char **ret) {
assert(s);
_cleanup_free_ char *q = NULL;
int r;
r = utf8_to_ascii(s, '_', &q);
if (r < 0)
return r;
/* Classic FAT only allows 11 character uppercase labels */
strshorten(q, 11);
ascii_strupper(q);
/* mkfs.vfat: Labels with characters *?.,;:/\|+=<>[]" are not allowed.
* Let's also replace any control chars. */
for (char *p = q; *p; p++)
if (strchr("*?.,;:/\\|+=<>[]\"", *p) || char_is_cc(*p))
*p = '_';
*ret = TAKE_PTR(q);
return 0;
}
int make_filesystem( int make_filesystem(
const char *node, const char *node,
const char *fstype, const char *fstype,
@ -93,8 +38,7 @@ int make_filesystem(
sd_id128_t uuid, sd_id128_t uuid,
bool discard) { bool discard) {
_cleanup_free_ char *mkfs = NULL, *mangled_label = NULL; _cleanup_free_ char *mkfs = NULL;
char vol_id[CONST_MAX(ID128_UUID_STRING_MAX, 8 + 1)] = {};
int r; int r;
assert(node); assert(node);
@ -119,113 +63,64 @@ int make_filesystem(
return log_oom(); return log_oom();
} }
if (STR_IN_SET(fstype, "ext2", "ext3", "ext4", "xfs", "swap")) {
size_t max_len =
streq(fstype, "xfs") ? 12 :
streq(fstype, "swap") ? 15 :
16;
r = mangle_linux_fs_label(label, max_len, &mangled_label);
if (r < 0)
return log_error_errno(r, "Failed to determine volume label from string \"%s\": %m", label);
label = mangled_label;
} else if (streq(fstype, "vfat")) {
r = mangle_fat_label(label, &mangled_label);
if (r < 0)
return log_error_errno(r, "Failed to determine FAT label from string \"%s\": %m", label);
label = mangled_label;
xsprintf(vol_id, "%08" PRIx32,
((uint32_t) uuid.bytes[0] << 24) |
((uint32_t) uuid.bytes[1] << 16) |
((uint32_t) uuid.bytes[2] << 8) |
((uint32_t) uuid.bytes[3])); /* Take first 32 bytes of UUID */
}
if (isempty(vol_id))
id128_to_uuid_string(uuid, vol_id);
r = safe_fork("(mkfs)", FORK_RESET_SIGNALS|FORK_RLIMIT_NOFILE_SAFE|FORK_DEATHSIG|FORK_LOG|FORK_WAIT|FORK_STDOUT_TO_STDERR, NULL); r = safe_fork("(mkfs)", FORK_RESET_SIGNALS|FORK_RLIMIT_NOFILE_SAFE|FORK_DEATHSIG|FORK_LOG|FORK_WAIT|FORK_STDOUT_TO_STDERR, NULL);
if (r < 0) if (r < 0)
return r; return r;
if (r == 0) { if (r == 0) {
/* Child */ /* Child */
if (streq(fstype, "ext4"))
/* When changing this conditional, also adjust the log statement below. */
if (streq(fstype, "ext2"))
(void) execlp(mkfs, mkfs, (void) execlp(mkfs, mkfs,
"-q",
"-L", label, "-L", label,
"-U", vol_id, "-U", ID128_TO_UUID_STRING(uuid),
"-I", "256",
"-m", "0",
"-E", discard ? "discard,lazy_itable_init=1" : "nodiscard,lazy_itable_init=1",
node, NULL);
else if (STR_IN_SET(fstype, "ext3", "ext4"))
(void) execlp(mkfs, mkfs,
"-q",
"-L", label,
"-U", vol_id,
"-I", "256", "-I", "256",
"-O", "has_journal", "-O", "has_journal",
"-m", "0", "-m", "0",
"-E", discard ? "discard,lazy_itable_init=1" : "nodiscard,lazy_itable_init=1", "-E", discard ? "lazy_itable_init=1,discard" : "lazy_itable_init=1,nodiscard",
node, NULL); node, NULL);
else if (streq(fstype, "btrfs")) { else if (streq(fstype, "btrfs")) {
(void) execlp(mkfs, mkfs, if (discard)
"-q", (void) execlp(mkfs, mkfs, "-L", label, "-U", ID128_TO_UUID_STRING(uuid), node, NULL);
"-L", label, else
"-U", vol_id, (void) execlp(mkfs, mkfs, "-L", label, "-U", ID128_TO_UUID_STRING(uuid), "--nodiscard", node, NULL);
node,
discard ? NULL : "--nodiscard",
NULL);
} else if (streq(fstype, "f2fs")) {
(void) execlp(mkfs, mkfs,
"-q",
"-g", /* "default options" */
"-f", /* force override, without this it doesn't seem to want to write to an empty partition */
"-l", label,
"-U", vol_id,
"-t", one_zero(discard),
node,
NULL);
} else if (streq(fstype, "xfs")) { } else if (streq(fstype, "xfs")) {
const char *j; const char *j;
j = strjoina("uuid=", vol_id); j = strjoina("uuid=", ID128_TO_UUID_STRING(uuid));
if (discard)
(void) execlp(mkfs, mkfs, "-L", label, "-m", j, "-m", "reflink=1", node, NULL);
else
(void) execlp(mkfs, mkfs, "-L", label, "-m", j, "-m", "reflink=1", "-K", node, NULL);
(void) execlp(mkfs, mkfs, } else if (streq(fstype, "vfat")) {
"-q", char mangled_label[8 + 3 + 1], vol_id[8 + 1];
"-L", label,
"-m", j,
"-m", "reflink=1",
node,
discard ? NULL : "-K",
NULL);
} else if (streq(fstype, "vfat")) /* Classic FAT only allows 11 character uppercase labels */
strncpy(mangled_label, label, sizeof(mangled_label)-1);
mangled_label[sizeof(mangled_label)-1] = 0;
ascii_strupper(mangled_label);
xsprintf(vol_id, "%08" PRIx32,
((uint32_t) uuid.bytes[0] << 24) |
((uint32_t) uuid.bytes[1] << 16) |
((uint32_t) uuid.bytes[2] << 8) |
((uint32_t) uuid.bytes[3])); /* Take first 32 byte of UUID */
(void) execlp(mkfs, mkfs, (void) execlp(mkfs, mkfs,
"-i", vol_id, "-i", vol_id,
"-n", label, "-n", mangled_label,
"-F", "32", /* yes, we force FAT32 here */ "-F", "32", /* yes, we force FAT32 here */
node, NULL); node, NULL);
else if (streq(fstype, "swap")) } else if (streq(fstype, "swap")) {
/* TODO: add --quiet here if
* https://github.com/util-linux/util-linux/issues/1499 resolved. */
(void) execlp(mkfs, mkfs, (void) execlp(mkfs, mkfs,
"-L", label, "-L", label,
"-U", vol_id, "-U", ID128_TO_UUID_STRING(uuid),
node, NULL); node, NULL);
else } else
/* Generic fallback for all other file systems */ /* Generic fallback for all other file systems */
(void) execlp(mkfs, mkfs, node, NULL); (void) execlp(mkfs, mkfs, node, NULL);
@ -234,12 +129,5 @@ int make_filesystem(
_exit(EXIT_FAILURE); _exit(EXIT_FAILURE);
} }
if (STR_IN_SET(fstype, "ext2", "ext3", "ext4", "btrfs", "f2fs", "xfs", "vfat", "swap"))
log_info("%s successfully formatted as %s (label \"%s\", uuid %s)",
node, fstype, label, vol_id);
else
log_info("%s successfully formatted as %s (no label or uuid specified)",
node, fstype);
return 0; return 0;
} }

View File

@ -522,7 +522,7 @@ static int remount_with_timeout(MountPoint *m, int umount_log_level) {
if (r < 0) if (r < 0)
return r; return r;
if (r == 0) { if (r == 0) {
log_info("Remounting '%s' read-only with options '%s'.", m->path, strna(m->remount_options)); log_info("Remounting '%s' read-only in with options '%s'.", m->path, m->remount_options);
/* Start the mount operation here in the child */ /* Start the mount operation here in the child */
r = mount(NULL, m->path, NULL, m->remount_flags, m->remount_options); r = mount(NULL, m->path, NULL, m->remount_flags, m->remount_options);

View File

@ -465,7 +465,7 @@ static int merge_subprocess(Hashmap *images, const char *workspace) {
* but let the kernel do that entirely automatically, once our namespace dies. Note that this file * but let the kernel do that entirely automatically, once our namespace dies. Note that this file
* system won't be visible to anyone but us, since we opened our own namespace and then made the * system won't be visible to anyone but us, since we opened our own namespace and then made the
* /run/ hierarchy (which our workspace is contained in) MS_SLAVE, see above. */ * /run/ hierarchy (which our workspace is contained in) MS_SLAVE, see above. */
r = mount_nofollow_verbose(LOG_ERR, "sysext", workspace, "tmpfs", 0, "mode=0700"); r = mount_nofollow_verbose(LOG_ERR, "sysexit", workspace, "tmpfs", 0, "mode=0700");
if (r < 0) if (r < 0)
return r; return r;

View File

@ -66,33 +66,6 @@ static void test_ascii_is_valid_n(void) {
assert_se( ascii_is_valid_n("\342\204\242", 0)); assert_se( ascii_is_valid_n("\342\204\242", 0));
} }
static void test_utf8_to_ascii_one(const char *s, int r_expected, const char *expected) {
_cleanup_free_ char *ans = NULL;
int r;
r = utf8_to_ascii(s, '*', &ans);
log_debug("\"%s\" → %d/\"%s\" (expected %d/\"%s\")", s, r, strnull(ans), r_expected, strnull(expected));
assert_se(r == r_expected);
assert_se(streq_ptr(ans, expected));
}
static void test_utf8_to_ascii(void) {
log_info("/* %s */", __func__);
test_utf8_to_ascii_one("asdf", 0, "asdf");
test_utf8_to_ascii_one("dąb", 0, "d*b");
test_utf8_to_ascii_one("żęśłą óźń", 0, "***** ***");
test_utf8_to_ascii_one("\342\204\242", 0, "*");
test_utf8_to_ascii_one("\342\204", -EINVAL, NULL); /* truncated */
test_utf8_to_ascii_one("\342", -EINVAL, NULL); /* truncated */
test_utf8_to_ascii_one("\302\256", 0, "*");
test_utf8_to_ascii_one("", 0, "");
test_utf8_to_ascii_one(" ", 0, " ");
test_utf8_to_ascii_one("\t", 0, "\t");
test_utf8_to_ascii_one("", 0, "*");
test_utf8_to_ascii_one("…👊🔪💐…", 0, "*****");
}
static void test_utf8_encoded_valid_unichar(void) { static void test_utf8_encoded_valid_unichar(void) {
log_info("/* %s */", __func__); log_info("/* %s */", __func__);
@ -268,7 +241,6 @@ int main(int argc, char *argv[]) {
test_utf8_is_printable(); test_utf8_is_printable();
test_ascii_is_valid(); test_ascii_is_valid();
test_ascii_is_valid_n(); test_ascii_is_valid_n();
test_utf8_to_ascii();
test_utf8_encoded_valid_unichar(); test_utf8_encoded_valid_unichar();
test_utf8_escape_invalid(); test_utf8_escape_invalid();
test_utf8_escape_non_printable(); test_utf8_escape_non_printable();

View File

@ -10,6 +10,7 @@ TEST_NO_NSPAWN=1
. "${TEST_BASE_DIR:?}/test-functions" . "${TEST_BASE_DIR:?}/test-functions"
QEMU_TIMEOUT=300 QEMU_TIMEOUT=300
FSTYPE=ext4
TEST_FORCE_NEWIMAGE=1 TEST_FORCE_NEWIMAGE=1
do_test "$@" do_test "$@"

View File

@ -3,23 +3,9 @@
set -e set -e
TEST_DESCRIPTION="testing homed" TEST_DESCRIPTION="testing homed"
TEST_NO_QEMU=1
# Skip the qemu version of the test, unless we have btrfs
(modprobe -nv btrfs && command -v mkfs.btrfs) || TEST_NO_QEMU=1
# shellcheck source=test/test-functions # shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions" . "${TEST_BASE_DIR:?}/test-functions"
# Need loop devices for mounting images
test_append_files() {
(
if [ "$TEST_NO_QEMU" != "1" ] ; then
instmods loop =block
install_dmevent
install_btrfs
generate_module_dependencies
fi
)
}
do_test "$@" do_test "$@"

View File

@ -5,7 +5,8 @@ Before=local-fs.target
[Mount] [Mount]
What=/dev/sda1 What=/dev/sda1
Where=/ Where=/
Options=noatime Type=ext4
Options=errors=remount-ro,noatime
[Install] [Install]
WantedBy=local-fs.target WantedBy=local-fs.target

View File

@ -26,9 +26,7 @@ inspect() {
systemd-analyze log-level debug systemd-analyze log-level debug
systemd-analyze log-target console systemd-analyze log-target console
# we enable --luks-discard= since we run our tests in a tight VM, hence don't NEWPASSWORD=xEhErW0ndafV4s homectl create test-user --disk-size=20M
# needlessly pressure for storage
NEWPASSWORD=xEhErW0ndafV4s homectl create test-user --disk-size=256M --luks-discard=yes
inspect test-user inspect test-user
PASSWORD=xEhErW0ndafV4s homectl authenticate test-user PASSWORD=xEhErW0ndafV4s homectl authenticate test-user

View File

@ -12,6 +12,9 @@ L+ /etc/mtab - - - - ../proc/self/mounts
{% if HAVE_SMACK_RUN_LABEL %} {% if HAVE_SMACK_RUN_LABEL %}
t /etc/mtab - - - - security.SMACK64=_ t /etc/mtab - - - - security.SMACK64=_
{% endif %} {% endif %}
{% if ENABLE_RESOLVE %}
L! /etc/resolv.conf - - - - ../run/systemd/resolve/stub-resolv.conf
{% endif %}
C! /etc/nsswitch.conf - - - - C! /etc/nsswitch.conf - - - -
{% if HAVE_PAM %} {% if HAVE_PAM %}
C! /etc/pam.d - - - - C! /etc/pam.d - - - -

View File

@ -7,7 +7,6 @@ files = [['README', ''],
['journal-nocow.conf', ''], ['journal-nocow.conf', ''],
['systemd-nologin.conf', 'HAVE_PAM'], ['systemd-nologin.conf', 'HAVE_PAM'],
['systemd-nspawn.conf', 'ENABLE_MACHINED'], ['systemd-nspawn.conf', 'ENABLE_MACHINED'],
['systemd-resolve.conf', 'ENABLE_RESOLVE'],
['systemd-tmp.conf', ''], ['systemd-tmp.conf', ''],
['portables.conf', 'ENABLE_PORTABLED'], ['portables.conf', 'ENABLE_PORTABLED'],
['systemd-pstore.conf', 'ENABLE_PSTORE'], ['systemd-pstore.conf', 'ENABLE_PSTORE'],

View File

@ -1,10 +0,0 @@
# This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
# See tmpfiles.d(5) for details
L! /etc/resolv.conf - - - - ../run/systemd/resolve/stub-resolv.conf

View File

@ -16,7 +16,6 @@ DefaultDependencies=no
Conflicts=shutdown.target Conflicts=shutdown.target
After=proc-sys-fs-binfmt_misc.automount After=proc-sys-fs-binfmt_misc.automount
After=proc-sys-fs-binfmt_misc.mount After=proc-sys-fs-binfmt_misc.mount
After=local-fs.target
Before=sysinit.target shutdown.target Before=sysinit.target shutdown.target
ConditionPathIsReadWrite=/proc/sys/ ConditionPathIsReadWrite=/proc/sys/
ConditionDirectoryNotEmpty=|/lib/binfmt.d ConditionDirectoryNotEmpty=|/lib/binfmt.d