Commit Graph

146 Commits

Author SHA1 Message Date
Daan De Meyer
8857aa74e5 tree-wide: Clean up includes
This commit cleans up the includes for all the small tools across
the tree.

A few cases of returning EXIT_SUCCESS are replaced with returning
0 to avoid including <stdlib.h>.

Split out of #37344.
2025-05-14 22:34:02 +02:00
Yu Watanabe
ab1bd9daed device-util: introduce several more helper functions
This also makes device_in_subsystem() and device_is_devtype() return
negative error on critical error
2025-05-14 02:06:02 +09:00
Mike Yuan
b3cfee2f5d mount-tool: honor arg_canonicalize for ACTION_UMOUNT path_is_absolute() check too
Follow-up for 4e24796b5a
2025-05-09 18:39:51 +02:00
Daan De Meyer
76d62b63ef main-func: Reduce transitive includes
Let's move some logic from _DEFINE_MAIN_FUNCTION() and other places
in main-func.h into functions that we implement in main-func.c to
allow moving some included headers from the header to the .c file.
2025-05-06 10:07:27 +02:00
Yu Watanabe
c0cc01de8a meson: use install_symlink() where applicable
Now our baseline of meson is 0.62, hence install_symlink() can be used.

Note, install_symlink() implies install_emptydir() for specified
install_dir. Hence, this also drops several unnecessary
install_emptydir() calls.

Note, the function currently does not support 'relative' and 'force' flags,
so several 'ln -frsT' inline calls cannot be replaced.
2025-03-10 02:41:40 +09:00
Mike Yuan
bb12d57cd5 mount-tool: never bind to device on explicit x-systemd.device-bound=no 2025-03-03 10:45:57 +01:00
Mike Yuan
0a7295b388 mount-tool: correct arg_bind_device check 2025-03-03 10:45:56 +01:00
Mike Yuan
36d4437c5b mount-tool: accept fstab-style identifiers for remote what too
fstab-style identifiers have stable translation to absolute paths
in the file system, hence it makes no sense to reject them
even for remote mounts.
2025-03-03 10:45:56 +01:00
Mike Yuan
70b1f3e0a2 mount-tool: some modernizations and log message tweaks 2025-03-03 10:45:56 +01:00
Lennart Poettering
4e24796b5a mount-tool: add explicitly control of path canonicalization
With this the default canonicalization of paths can be turned off,
giving users explicit control on what shall happen if symlinks are
encountered within a path.
2025-02-18 13:49:24 +01:00
Lennart Poettering
61178346e6 mount-tool: modernize umount and make sure it works for bind mounted files
So far, "systemd-umount" executed on a bind mounted file would assume it
is supposed to unmount a loopback mounted file system. Let's address
that by instead checking if the file is a mount.
2025-02-18 13:49:24 +01:00
Yu Watanabe
93f6cee97e libmount-util: introduce two helper functions
This introduces libmount_parse_mountinfo() and libmount_parse_with_utab().
The former one parses only mountinfo, but the latter one also parse
utab. Hopefully this avoids pitfalls like issue #35949.
2025-01-25 09:34:01 +09:00
Daan De Meyer
d8a77d55e6 bus-util: Log more information when connecting to a bus socket fails
Let's log about which bus we're trying to connect to and what transport
we're using to do it.
2024-10-09 10:27:53 +02:00
Yu Watanabe
04834552ed mount: use sd_bus_set_allow_interactive_authorization() 2024-08-19 11:36:32 +09:00
Yu Watanabe
f3cf6167ef tree-wide: voidify polkit_agent_open_if_enabled() 2024-08-19 11:36:32 +09:00
Lennart Poettering
5b37c4cf86 mount-tool: show diskseq in --list output
Let's expose the diskseq a bit more prominently.
2024-07-10 09:35:31 +02:00
Lennart Poettering
3d41dfe447 mount-tool: use the usual coloring in --help text 2024-07-10 09:35:31 +02:00
Lennart Poettering
66f4f49c8f mount-tool: add support for a --json= output mode
Let's add a JSON output mode, like we have it for so many of our tools.
2024-07-10 09:35:31 +02:00
Lennart Poettering
070a43ced4 mount-tool: use lowercase table column names
The "systemd-mount" tool is the one outlier in our codebase to specify
upper case column names. And it's quite pointless given that our table
output logic uppercases this anyway on output. Hence, let's fix that.

(This would be a compat break, if we'd support JSON output of this
table, but we do not currently. JSON fields use the literal column
name after all.)
2024-07-10 09:35:31 +02:00
Zbigniew Jędrzejewski-Szmek
1b919ca4db Rename spawn-polkit-agent.c to just polkit-agent.c
The functions in the file were *not* using the spawn prefix,
and the prefix seems completely unnecessary.
2024-06-26 15:04:06 +02:00
Daan De Meyer
aa976d8788 tree-wide: Use log_setup() everywhere
Otherwise the default log target is the console and we won't use
the journal socket even if it is available.
2024-04-25 17:06:43 +02:00
Yu Watanabe
fb53ee0a64 tree-wide: use device_in_subsystem() and device_is_devtype() 2023-12-23 03:52:21 +09:00
Matteo Croce
e22ad53d5c dbus-wait-for-jobs: change 'quiet' flag to enum
Change the 'quiet' flag to `bus_wait_for_jobs()` to an enum, so we can
select with more granularity the type of information logged.
2023-12-19 04:52:41 -08:00
Frantisek Sumsal
6e07f600ba mount: don't call sd_device_get_property_value() with a NULL pointer
Otherwise bad thing would've happened is this was a hard assert:

+ systemd-mount --umount /dev/loop0
Assertion 'device' failed at src/libsystemd/sd-device/sd-device.c:2202, function sd_device_get_property_value(). Ignoring.
2023-11-15 13:46:09 +01:00
Yu Watanabe
4e2df3082d Merge pull request #30010 from poettering/mount-tool-tweakles
mount-tool: trivial tweaklets
2023-11-14 02:38:09 +09:00
Lennart Poettering
3cc7a9fd25 udev-util: add generic device_get_{vendor,model}_string() helpers
We chck the same props in various places, add a single implementation of
a call to inquire this.
2023-11-13 16:24:17 +01:00
Lennart Poettering
b86155d071 mount-tool: make internal and external column name match 2023-11-13 16:13:07 +01:00
Lennart Poettering
4096143827 mount-tool: rely on format-table.c's ersatz logic
Let the table logic handle the special casing ov unavailable data,
rather than doing that ourselves.
2023-11-13 16:13:07 +01:00
Lennart Poettering
4cbf9d52f3 mount-tool: reduce scope of enum 2023-11-13 16:13:07 +01:00
Zbigniew Jędrzejewski-Szmek
660087dc9c tree-wide: add path_simplify_alloc() and use it
path_simplify_full()/path_simplify() are changed to allow a NULL path, for
which a NULL is returned. Generally, callers have already asserted before that
the argument is nonnull. This way path_simplify_full()/path_simplify() and
path_simplify_alloc() behave consistently.

In sd-device.c, logging in device_set_syspath() is intentionally dropped: other
branches don't log.

In mount-tool.c, logging in parse_argv() is changed to log the user-specified
value, not the simplified string. In an error message, we should show the
actual argument we got, not some transformed version.
2023-09-22 08:13:34 +02:00
Mike Yuan
82007efa44 mount/mount-tool: return correct errno
Follow-up for 9269296df0
2023-08-26 09:27:23 +09:00
Zbigniew Jędrzejewski-Szmek
9269296df0 mount-tool: override mode of --tmpfs mounts to (rwxrwxrwx & ~umask)
The kernel default for tmpfs mounts is rwxrwxrwt, i.e. world-writable with the
sticky bit set. This makes sense for /tmp and /var/tmp, but less so for other
directories. Users will not use systemd-mount to mount /tmp and /var/tmp, so
the existing behaviour is surprising. The defaults are overriden to the
same defaults we use for "internal tmpfs mounts", i.e. no sticky bit, nosuid,
nodev, and limits of size=10%, nr_inodes=400k.

--tmpfs is new, so we can modify the behaviour without breaking compatibility.
2023-08-22 12:31:45 +02:00
Zbigniew Jędrzejewski-Szmek
857127f1e3 mount-tool: reduce scope of iterator variables 2023-08-22 05:33:36 +02:00
Zbigniew Jędrzejewski-Szmek
52a1e91e96 mount-tool,man: reword comments and error messages
We were consistenly using --umount everywhere, but add a comment to make this
clearer. Also, reword a few things for clarity.
2023-08-21 20:47:17 +02:00
Luca Boccassi
2322c6c735 sd-mount: allow creating tmpfs
Mount units can do it, but the command line tool cannot, as it needs a
valid 'what'. If --tmpfs/-T if passed, parse the argument as 'where'
and send a literal 'tmpfs' as the 'what' if not specified.
2023-08-21 11:45:15 +02:00
Yu Watanabe
9289e093ae meson: use install_emptydir() and drop meson-make-symlink.sh
The script is mostly equivalent to 'mkdir -p' and 'ln -sfr'.
Let's replace it with install_emptydir() builtin function and
inline meson call.
2023-08-08 22:11:34 +01:00
Yu Watanabe
9f907d305f meson: move declarations of cgls, cgtop, initctl, and systemd-mount 2023-08-01 21:37:31 +09:00
Daan De Meyer
a1af83728f device-util: Declare iterator variables inline 2023-07-12 20:05:18 +02:00
Lennart Poettering
563e684689 stat-util: rename files_same() → inode_same()
Let's be more accurate about what this function does: it checks whether
the underlying reported inode is the same. Internally, this already uses
a better named stat_inode_same() call, hence let's similarly name the
wrapping function following the same logic.

Similar for files_same_at() and path_equal_or_same_files().

No code changes, just some renaming.
2023-05-19 17:42:41 +02:00
Daan De Meyer
f461a28da7 chase-symlinks: Rename chase_symlinks() to chase()
Chasing symlinks is a core function that's used in a lot of places
so it deservers a less verbose names so let's rename it to chase()
and chaseat().

We also slightly change the pattern used for the chaseat() helpers
so we get chase_and_openat() and similar.
2023-03-24 13:43:51 +01:00
Lennart Poettering
4870133bfa basic: add RuntimeScope enum
In various tools and services we have a per-system and per-user concept.
So far we sometimes used a boolean indicating whether we are in system
mode, or a reversed boolean indicating whether we are in user mode, or
the LookupScope enum used by the lookup path logic.

Let's address that, in introduce a common enum for this, we can use all
across the board.

This is mostly just search/replace, no actual code changes.
2023-03-10 09:47:39 +01:00
Lennart Poettering
451f0dba60 mount-tool: port over basename() → path_extract_filename() 2022-12-23 15:04:19 +01:00
Yu Watanabe
1480c23199 mount: use device enumerator to find matching loopback block device
No functional change, just refactoring.
2022-11-24 14:17:35 +09:00
Yu Watanabe
961d08cadb mount: split umount_by_device() into two
No functional change, just refactoring and preparation for later
commits.
2022-11-24 14:17:35 +09:00
Yu Watanabe
95a45a87d6 mount: make acquire_mount_where_for_loop_dev() take sd-device object
No functional change, just refactoring.
2022-11-24 14:17:22 +09:00
Zbigniew Jędrzejewski-Szmek
d6b4d1c7c4 basic: move version() to build.h+c 2022-11-08 13:41:14 +01:00
Jonas Kümmerlin
1355672437 generator: skip fsck if fsck command is missing
This is useful for systems which don't have any fsck.

We already skip emitting the fsck dependency when the fsck.$fstype helper
is missing, but fstab-generator doesn't necessarily know the fstype when
handling the root= parameter.

Previously, systemd-fsck was started for these mounts and then exited
immediately because it couldn't find the fsck.$fstype helper.
2022-09-30 15:01:41 +01:00
Luca Boccassi
86980de64b dbus-wait-for-jobs: add extra_args to bus_wait_for_jobs_one()
And pass it through to bus_wait_for_jobs()
2021-12-30 23:50:45 +09:00
Zbigniew Jędrzejewski-Szmek
af3b864d76 Define FOREACH_DIRENT through FOREACH_DIRENT_ALL
As in the previous commit, 'de' is used as the iterator variable name.
2021-12-15 22:50:00 +01:00
Luca Boccassi
8389fd19d2 Merge pull request #20138 from keszybz/coding-style-variable-decls
A coding style tweak and checking of sd_notify() calls and voidification of pager_open()
2021-11-05 13:57:30 +00:00