summaryrefslogtreecommitdiff
path: root/src/mount
Commit message (Collapse)AuthorAgeFilesLines
* systemd-mount: don't check for non-normalized WHAT for network FSKarel Zak2019-06-111-1/+2
| | | | | | | The WHAT string could be whatever for many filesystems. The common example are network filesystems. Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1708996
* Merge pull request #12411 from keszybz/pr/12394Lennart Poettering2019-05-081-0/+1
|\ | | | | run: when emitting the calendarspec warning, use red
| * Enable log colors for most of tools in /usr/binZbigniew Jędrzejewski-Szmek2019-05-081-0/+1
| | | | | | | | | | | | | | | | | | | | When emitting the calendarspec warning we want to see some color. Follow-up for 04220fda5c. Exceptions: - systemctl, because it has a lot hand-crafted coloring - tmpfiles, sysusers, stdio-bridge, etc, because they are also used in services and I'm not sure if this wouldn't mess up something.
* | Add helper function for mnt_table_parse_{stream,mtab}Zbigniew Jędrzejewski-Szmek2019-04-231-6/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This wraps a few common steps. It is defined as inline function instead of in a .c file to avoid having a .c file. With a .c file, we would have three choices: - either link it into libshared, but then then libshared would have to be linked to libmount. - or compile the .c file into each target separately. This has the disdvantage that configuration of every target has to be updated and stuff will be compiled multiple times anyway, which is not too different from keeping this in the header file. - or create a new convenience library just for this. This also has the disadvantage that the every target would have to be updated, and a separate library for a 10 line function seems overkill. By keeping everything in a header file, we compile this a few times, but otherwise it's the least painful option. The compiler can optimize most of the function away, because it knows if 'source' is set or not.
* | mount-tool: use libmount to parse /proc/self/mountinfoZbigniew Jędrzejewski-Szmek2019-04-231-34/+29
|/ | | | | | | | | | | Same motivation as in other places: let's use a single logic to parse this. Use path_equal() to compare the path. A bug in error handling is fixed: if we failed after the GREEDY_REALLOC but before the line that sets the last item to NULL, we would jump to _cleanup_strv_free_ with the strv unterminated. Let's use GREEDY_REALLOC0 to avoid the issue.
* headers: remove unneeded includes from util.hZbigniew Jędrzejewski-Szmek2019-03-271-0/+1
| | | | | This means we need to include many more headers in various files that simply included util.h before, but it seems cleaner to do it this way.
* shared: split out code to wait for jobs to complet into its own source fileLennart Poettering2019-03-131-0/+1
| | | | | | | It's complex enough and quite a few functions. Let's hence split this out. No code change, just some rearranging of source files.
* util: split out sorting related calls to new sort-util.[ch]Lennart Poettering2019-03-131-1/+2
|
* Split out part of mount-util.c into mountpoint-util.cZbigniew Jędrzejewski-Szmek2018-11-291-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The idea is that anything which is related to actually manipulating mounts is in mount-util.c, but functions for mountpoint introspection are moved to the new file. Anything which requires libmount must be in mount-util.c. This was supposed to be a preparation for further changes, with no functional difference, but it results in a significant change in linkage: $ ldd build/libnss_*.so.2 (before) build/libnss_myhostname.so.2: linux-vdso.so.1 (0x00007fff77bf5000) librt.so.1 => /lib64/librt.so.1 (0x00007f4bbb7b2000) libmount.so.1 => /lib64/libmount.so.1 (0x00007f4bbb755000) libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f4bbb734000) libc.so.6 => /lib64/libc.so.6 (0x00007f4bbb56e000) /lib64/ld-linux-x86-64.so.2 (0x00007f4bbb8c1000) libblkid.so.1 => /lib64/libblkid.so.1 (0x00007f4bbb51b000) libuuid.so.1 => /lib64/libuuid.so.1 (0x00007f4bbb512000) libselinux.so.1 => /lib64/libselinux.so.1 (0x00007f4bbb4e3000) libpcre2-8.so.0 => /lib64/libpcre2-8.so.0 (0x00007f4bbb45e000) libdl.so.2 => /lib64/libdl.so.2 (0x00007f4bbb458000) build/libnss_mymachines.so.2: linux-vdso.so.1 (0x00007ffc19cc0000) librt.so.1 => /lib64/librt.so.1 (0x00007fdecb74b000) libcap.so.2 => /lib64/libcap.so.2 (0x00007fdecb744000) libmount.so.1 => /lib64/libmount.so.1 (0x00007fdecb6e7000) libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fdecb6c6000) libc.so.6 => /lib64/libc.so.6 (0x00007fdecb500000) /lib64/ld-linux-x86-64.so.2 (0x00007fdecb8a9000) libblkid.so.1 => /lib64/libblkid.so.1 (0x00007fdecb4ad000) libuuid.so.1 => /lib64/libuuid.so.1 (0x00007fdecb4a2000) libselinux.so.1 => /lib64/libselinux.so.1 (0x00007fdecb475000) libpcre2-8.so.0 => /lib64/libpcre2-8.so.0 (0x00007fdecb3f0000) libdl.so.2 => /lib64/libdl.so.2 (0x00007fdecb3ea000) build/libnss_resolve.so.2: linux-vdso.so.1 (0x00007ffe8ef8e000) librt.so.1 => /lib64/librt.so.1 (0x00007fcf314bd000) libcap.so.2 => /lib64/libcap.so.2 (0x00007fcf314b6000) libmount.so.1 => /lib64/libmount.so.1 (0x00007fcf31459000) libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fcf31438000) libc.so.6 => /lib64/libc.so.6 (0x00007fcf31272000) /lib64/ld-linux-x86-64.so.2 (0x00007fcf31615000) libblkid.so.1 => /lib64/libblkid.so.1 (0x00007fcf3121f000) libuuid.so.1 => /lib64/libuuid.so.1 (0x00007fcf31214000) libselinux.so.1 => /lib64/libselinux.so.1 (0x00007fcf311e7000) libpcre2-8.so.0 => /lib64/libpcre2-8.so.0 (0x00007fcf31162000) libdl.so.2 => /lib64/libdl.so.2 (0x00007fcf3115c000) build/libnss_systemd.so.2: linux-vdso.so.1 (0x00007ffda6d17000) librt.so.1 => /lib64/librt.so.1 (0x00007f610b83c000) libcap.so.2 => /lib64/libcap.so.2 (0x00007f610b835000) libmount.so.1 => /lib64/libmount.so.1 (0x00007f610b7d8000) libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f610b7b7000) libc.so.6 => /lib64/libc.so.6 (0x00007f610b5f1000) /lib64/ld-linux-x86-64.so.2 (0x00007f610b995000) libblkid.so.1 => /lib64/libblkid.so.1 (0x00007f610b59e000) libuuid.so.1 => /lib64/libuuid.so.1 (0x00007f610b593000) libselinux.so.1 => /lib64/libselinux.so.1 (0x00007f610b566000) libpcre2-8.so.0 => /lib64/libpcre2-8.so.0 (0x00007f610b4e1000) libdl.so.2 => /lib64/libdl.so.2 (0x00007f610b4db000) (after) build/libnss_myhostname.so.2: linux-vdso.so.1 (0x00007fff0b5e2000) librt.so.1 => /lib64/librt.so.1 (0x00007fde0c328000) libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fde0c307000) libc.so.6 => /lib64/libc.so.6 (0x00007fde0c141000) /lib64/ld-linux-x86-64.so.2 (0x00007fde0c435000) build/libnss_mymachines.so.2: linux-vdso.so.1 (0x00007ffdc30a7000) librt.so.1 => /lib64/librt.so.1 (0x00007f06ecabb000) libcap.so.2 => /lib64/libcap.so.2 (0x00007f06ecab4000) libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f06eca93000) libc.so.6 => /lib64/libc.so.6 (0x00007f06ec8cd000) /lib64/ld-linux-x86-64.so.2 (0x00007f06ecc15000) build/libnss_resolve.so.2: linux-vdso.so.1 (0x00007ffe95747000) librt.so.1 => /lib64/librt.so.1 (0x00007fa56a80f000) libcap.so.2 => /lib64/libcap.so.2 (0x00007fa56a808000) libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fa56a7e7000) libc.so.6 => /lib64/libc.so.6 (0x00007fa56a621000) /lib64/ld-linux-x86-64.so.2 (0x00007fa56a964000) build/libnss_systemd.so.2: linux-vdso.so.1 (0x00007ffe67b51000) librt.so.1 => /lib64/librt.so.1 (0x00007ffb32113000) libcap.so.2 => /lib64/libcap.so.2 (0x00007ffb3210c000) libpthread.so.0 => /lib64/libpthread.so.0 (0x00007ffb320eb000) libc.so.6 => /lib64/libc.so.6 (0x00007ffb31f25000) /lib64/ld-linux-x86-64.so.2 (0x00007ffb3226a000) I don't quite understand what is going on here, but let's not be too picky.
* coccinelle: make use of SYNTHETIC_ERRNOZbigniew Jędrzejewski-Szmek2018-11-221-55/+44
| | | | | | | | | | | Ideally, coccinelle would strip unnecessary braces too. But I do not see any option in coccinelle for this, so instead, I edited the patch text using search&replace to remove the braces. Unfortunately this is not fully automatic, in particular it didn't deal well with if-else-if-else blocks and ifdefs, so there is an increased likelikehood be some bugs in such spots. I also removed part of the patch that coccinelle generated for udev, where we returns -1 for failure. This should be fixed independently.
* mount-tool: use static destructor and DEFINE_MAIN_FUNCTION() macroYu Watanabe2018-11-201-41/+27
|
* Split out pretty-print.c and move pager.c and main-func.h to shared/Zbigniew Jędrzejewski-Szmek2018-11-201-0/+1
| | | | | This is high-level functionality, and fits better in shared/ (which is for our executables), than in basic/ (which is also for libraries).
* basic/pager: convert the pager options to a flags argumentZbigniew Jędrzejewski-Szmek2018-11-141-3/+3
| | | | | Pretty much everything uses just the first argument, and this doesn't make this common pattern more complicated, but makes it simpler to pass multiple options.
* mount-tool: use log_device_*()Yu Watanabe2018-10-231-3/+3
|
* tree-wide: use typesafe_qsort()Yu Watanabe2018-09-191-8/+6
|
* tree-wide: replace ↵Yu Watanabe2018-09-101-6/+2
| | | | device_enumerator_scan_devices()+FOREACH_DEVICE_AND_SUBSYSTEM() by FOREACH_DEVICE()
* mount-tool: replace udev_device by sd_deviceYu Watanabe2018-08-231-90/+62
|
* Merge pull request #9783 from poettering/get-user-creds-flagsZbigniew Jędrzejewski-Szmek2018-08-211-1/+1
|\ | | | | beef up get_user_creds() a bit and other improvements
| * user-util: rework get_user_creds()Lennart Poettering2018-08-201-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Let's fold get_user_creds_clean() into get_user_creds(), and introduce a flags argument for it to select "clean" behaviour. This flags parameter also learns to other new flags: - USER_CREDS_SYNTHESIZE_FALLBACK: in this mode the user records for root/nobody are only synthesized as fallback. Normally, the synthesized records take precedence over what is in the user database. With this flag set this is reversed, and the user database takes precedence, and the synthesized records are only used if they are missing there. This flag should be set in cases where doing NSS is deemed safe, and where there's interest in knowing the correct shell, for example if the admin changed root's shell to zsh or suchlike. - USER_CREDS_ALLOW_MISSING: if set, and a UID/GID is specified by numeric value, and there's no user/group record for it accept it anyway. This allows us to fix #9767 This then also ports all users to set the most appropriate flags. Fixes: #9767 [zj: remove one isempty() call]
* | tree-wide: add clickable man page link to all --help textsLennart Poettering2018-08-201-6/+17
|/ | | | | | | | | | This is a bit like the info link in most of GNU's --help texts, but we don't do info but man pages, and we make them properly clickable on terminal supporting that, because awesome. I think it's generally advisable to link up our (brief) --help texts and our (more comprehensive) man pages a bit, so this should be an easy and straight-forward way to do it.
* mount: do not output (null) in optionYu Watanabe2018-06-191-1/+1
| | | | Fixes #9327.
* tree-wide: remove Lennart's copyright linesLennart Poettering2018-06-141-3/+0
| | | | | | | | | | | These lines are generally out-of-date, incomplete and unnecessary. With SPDX and git repository much more accurate and fine grained information about licensing and authorship is available, hence let's drop the per-file copyright notice. Of course, removing copyright lines of others is problematic, hence this commit only removes my own lines and leaves all others untouched. It might be nicer if sooner or later those could go away too, making git the only and accurate source of authorship information.
* tree-wide: drop 'This file is part of systemd' blurbLennart Poettering2018-06-141-2/+0
| | | | | | | | | | | | | | | | This part of the copyright blurb stems from the GPL use recommendations: https://www.gnu.org/licenses/gpl-howto.en.html The concept appears to originate in times where version control was per file, instead of per tree, and was a way to glue the files together. Ultimately, we nowadays don't live in that world anymore, and this information is entirely useless anyway, as people are very welcome to copy these files into any projects they like, and they shouldn't have to change bits that are part of our copyright header for that. hence, let's just get rid of this old cruft, and shorten our codebase a bit.
* path-util: introduce path_simplify()Yu Watanabe2018-06-031-3/+3
| | | | | | | | The function is similar to path_kill_slashes() but also removes initial './', trailing '/.', and '/./' in the path. When the second argument of path_simplify() is false, then it behaves as the same as path_kill_slashes(). Hence, this also replaces path_kill_slashes() with path_simplify().
* tree-wide: drop redundant _cleanup_ macros (#8810)Lennart Poettering2018-04-251-9/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | This drops a good number of type-specific _cleanup_ macros, and patches all users to just use the generic ones. In most recent code we abstained from defining type-specific macros, and this basically removes all those added already, with the exception of the really low-level ones. Having explicit macros for this is not too useful, as the expression without the extra macro is generally just 2ch wider. We should generally emphesize generic code, unless there are really good reasons for specific code, hence let's follow this in this case too. Note that _cleanup_free_ and similar really low-level, libc'ish, Linux API'ish macros continue to be defined, only the really high-level OO ones are dropped. From now on this should really be the rule: for really low-level stuff, such as memory allocation, fd handling and so one, go ahead and define explicit per-type macros, but for high-level, specific program code, just use the generic _cleanup_() macro directly, in order to keep things simple and as readable as possible for the uninitiated. Note that before this patch some of the APIs (notable libudev ones) were already used with the high-level macros at some places and with the generic _cleanup_ macro at others. With this patch we hence unify on the latter.
* tree-wide: drop license boilerplateZbigniew Jędrzejewski-Szmek2018-04-061-13/+0
| | | | | | | | | | Files which are installed as-is (any .service and other unit files, .conf files, .policy files, etc), are left as is. My assumption is that SPDX identifiers are not yet that well known, so it's better to retain the extended header to avoid any doubt. I also kept any copyright lines. We can probably remove them, but it'd nice to obtain explicit acks from all involved authors before doing that.
* macro: introduce TAKE_PTR() macroLennart Poettering2018-03-221-6/+3
| | | | | | | | | | | | | | | | This macro will read a pointer of any type, return it, and set the pointer to NULL. This is useful as an explicit concept of passing ownership of a memory area between pointers. This takes inspiration from Rust: https://doc.rust-lang.org/std/option/enum.Option.html#method.take and was suggested by Alan Jenkins (@sourcejedi). It drops ~160 lines of code from our codebase, which makes me like it. Also, I think it clarifies passing of ownership, and thus helps readability a bit (at least for the initiated who know the new macro)
* tree-wide: voidify pager_open()Yu Watanabe2018-03-191-1/+1
| | | | | | Even if pager_open() fails, in general, we should continue the operations. All erroneous cases in pager_open() show log message in the function. So, it is not necessary to check the returned value.
* Comment the fact that some tools need to termintate their bus connect firstFranck Bui2018-01-121-1/+2
|
* mount: make sure we terminate the bus connection first, and then close the pagerFranck Bui2018-01-121-1/+1
| | | | See cf647b69baee4c478d3909c327e3d917e1563f44 commit message for details.
* Revert "tree-wide: use _cleanup_(sd_bus_flush_close_unrefp) at various ↵Franck Bui2018-01-121-0/+2
| | | | | | | | | | | appropriate places" This reverts commit 0b3c84eb7da3a8c28ac248a68228f6a7edbb2e19. The removal of _cleanup_() usages was done on purpose, see cf647b69baee4c478d3909c327e3d917e1563f44. Fixes: #3543
* bus-unit-util: add socket unit related optionsYu Watanabe2017-12-231-4/+5
| | | | Also, split bus_append_unit_property_assignment().
* mount: add option to specify uid= and gid=Zbigniew Jędrzejewski-Szmek2017-12-151-3/+52
| | | | | | | | | | | | The kernel needs two numbers, but for the user it's most convenient to provide the user name and have that resolved to uid and gid. Right now the primary group of the specified user is always used. That's the most common case anyway. In the future we can extend the --owner option to allow a group after a colon. [I added this before realizing that this will not be enough to be used for user runtime directory. But this seems useful on its own, so I'm keeping this commit.]
* mount: use chase_symlinks()Yu Watanabe2017-12-031-15/+4
|
* mount: do not require that the specified directory existsYu Watanabe2017-12-031-8/+2
| | | | | | If the specified direcotry does not exist, then systemd creates it when the mount unit starts. So, it is not necessary to check the existence in the client tool.
* mount: ignore error when stop non-existing automount unitYu Watanabe2017-12-031-3/+7
| | | | | | | | | | The command `systemd-mount -u` tries to stop both mount and automount units. If the corresponding mount unit does not exist, then it is user's fault, that is, the specified path is not a mount point. However, not all mount units have corresponding autmount units. Thus, the error about non-existing automount unit is not user's falut, and showing the error may confuse users. So, let's ignore the error of such case.
* Merge pull request #7198 from poettering/stdin-stdoutLennart Poettering2017-11-191-6/+6
|\ | | | | Add StandardInput=data, StandardInput=file:... and more
| * fs-util: rename path_is_safe() → path_is_normalized()Lennart Poettering2017-11-171-6/+6
| | | | | | | | | | | | | | | | | | | | | | Already, path_is_safe() refused paths container the "." dir. Doing that isn't strictly necessary to be "safe" by most definitions of the word. But it is necessary in order to consider a path "normalized". Hence, "path_is_safe()" is slightly misleading a name, but "path_is_normalize()" is more descriptive, hence let's rename things accordingly. No functional changes.
* | Add SPDX license identifiers to source files under the LGPLZbigniew Jędrzejewski-Szmek2017-11-191-0/+1
|/ | | | | This follows what the kernel is doing, c.f. https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=5fd54ace4721fc5ce2bb5aef6318fcf17f421460.
* mount: show which argument is invalidYu Watanabe2017-11-171-4/+4
|
* mount: add "-G" as shortcut for "--property=CollectMode=inactive-or-failed"Yu Watanabe2017-11-171-2/+15
|
* tree-wide: use _cleanup_(sd_bus_flush_close_unrefp) at various appropriate ↵Lennart Poettering2017-11-101-2/+0
| | | | | | places Let's shorten the code a bit.
* treewide: unify identical definitions of polkit_agent_open_if_enabled() (#7187)Zbigniew Jędrzejewski-Szmek2017-10-301-15/+3
| | | Follows the same pattern as pager_open() now.
* mount: always show the user-provided argument when umount can't be doneFelipe Sateler2017-09-071-3/+3
| | | | Otherwise it can be confusing if the path is not the same
* mount: Add message when the target path does not existFelipe Sateler2017-09-071-0/+5
| | | | Fixes: #6760
* systemd-mount: allow to specify an arbitrary string for arg_mount_what when ↵Yu Watanabe2017-09-041-1/+7
| | | | | | vfs is used Fixes #6591.
* systemd-mount: fix that wrong argument is used for arg_mount_whatYu Watanabe2017-09-011-2/+1
|
* build-sys: drop automake supportZbigniew Jędrzejewski-Szmek2017-07-181-1/+0
| | | | | v2: - also mention m4
* mount: add missing validation error messageLennart Poettering2017-07-101-1/+3
| | | | | We really should generate exactly one log message for each error, hence let's do that in this one case too.
* mount: change find_loop_device() error code when no loop device is found to ↵Lennart Poettering2017-07-101-4/+4
| | | | | | | | | | ENXIO ENOENT is a bit too likely to be returned for various reasons, for example if /sys or /proc are not mounted and hence the files we need not around. Hence, let's use ENXIO instead, which is equally fitting for the purpose but has the benefit that the underlying calls won't generate this error on their own, hence any ambiguity is removed.