summaryrefslogtreecommitdiff
path: root/src/mount
Commit message (Collapse)AuthorAgeFilesLines
...
* 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.
* mount: add debug logging for the case when we knowingly ignore an errorLennart Poettering2017-07-101-1/+3
|
* mount: rework find_loop_device() to log about no errorsLennart Poettering2017-07-101-7/+4
| | | | | | | | We should either log about all errors in a function, or about none (and then leave the logging about it to the caller who we propagate the error to). Given that the callers of find_loop_device() already log about the returned errors let's hence suppress the log messages in find_loop_device() itself.
* mount: fix potential bad memory access when /proc/self/mountinfo is emptyLennart Poettering2017-07-101-5/+5
| | | | | | It's unlikely this can ever be triggered, but let's be safe rather than sorry, and handle the case where the list of mount points is zero, and the "l" array thus NULL. let's ensure we allocate at least one entry.
* systemd-mount: support relative pathsYu Watanabe2017-07-051-12/+52
|
* systemd-mount: support unmounting devices on remote hostYu Watanabe2017-07-051-2/+24
| | | | | The commit 9017f5d88d5061487de53f00a1a8c0a83e41e760 prohibits to unmount devices on remote host. This makes reenable such feature.
* systemd-mount: support discovery of loop backing fileYu Watanabe2017-07-051-122/+252
| | | | | | | | | ``` $ suro systemd-mount /path/to/disk.img Started unit run-media-system-disk.img.mount for mount point: /run/media/system/disk.img ``` Closes #6226.
* systemd-mount: support unmounting loop devices by backing files (#6211)Yu Watanabe2017-06-281-50/+95
| | | | | | | This makes `systemd-umount` or `systemd-mount -u` support unmounting loop devices by the corresponding backing files, like `systemd-mount --umount /tmp/foo.img /tmp/bar.img` Fixes #6206.
* systemd-mount: support device names and multiple arguments for umount (#6096)Yu Watanabe2017-06-261-25/+211
| | | | | | | This makes systemd-umount (or systemd-mount -u) supports multiple arguments which can be path, device, or fstab style node name, like `systemd-umount /path/to/umount /dev/sda1 UUID=xxxxxx-xxxx LABEL=xxxxx`. C.f. https://github.com/systemd/systemd/pull/5235#issuecomment-277731314.