summaryrefslogtreecommitdiff
path: root/src/core/mount.c
AgeCommit message (Collapse)Author
2015-07-28mount: remove obsolete -nKarel Zak
It seems that systemd still uses legacy -n option. The option has been originally designed to avoid write to /etc/mtab during boot when root FS is not ready or read-only. This is not necessary for long time, because /etc/mtab is not a real file (it's symlink) and write to the file is impossible. All utils should be able to detect the symlink and ignore mtab. This concept is supported for very long time before systemd. The userspase mount options are currently maintained by libmount (mount(8) and mount.nfs) in /run/mount) which is tmpfs initialized during early boot.
2015-07-21core: remove generic job completion messages from unit vtablesMichal Schmidt
These units' message format strings are identical to the generic strings. Since we can always rely on the fallback, these are now redundant.
2015-07-21core: correct return value from reload methodsMichal Schmidt
Return 1 from *_reload() methods to signify "we did something", just like in *_start(). This causes "Reloading foo..." messages to be logged. "Reloaded foo." messages are already logged.
2015-06-04core/mount: skip incomplete mountinfo entriesDaniel Mack
Skip /proc/mountinfo entries for which libmount returns a NULL pointer for 'source' or 'target'. This happened on Semaphore CI's build servers when the test suite is run.
2015-05-19mount: properly check for mounts currently in /proc/self/mountinfoLennart Poettering
http://lists.freedesktop.org/archives/systemd-devel/2015-May/032059.html
2015-05-19mount: don't claim a device is gone from /proc/self/mountinfo before it is ↵Lennart Poettering
gone from *all* lines Devices might be referenced by multiple mount points in /proc/self/mountinfo, hence we should consider them unmounted only after they disappeared from all lines, not just from one. http://lists.freedesktop.org/archives/systemd-devel/2015-May/032026.html
2015-05-13Default to /usr/bin/u?mount, configurable, rather than hard-coded /bin/u?mount.Dimitri John Ledkov
2015-05-13core: never create device depencies for /dev/root mountsLennart Poettering
http://lists.freedesktop.org/archives/systemd-devel/2015-May/031658.html
2015-05-11core: rename SystemdRunningAs to ManagerRunningAsLennart Poettering
It's primarily just a property of the Manager object after all, and we try to refer to PID 1 as "manager" instead of "systemd", hence let's to stick to this here too.
2015-05-11unit: move unit_warn_if_dir_nonempty() and friend to unit.cLennart Poettering
The call is only used by the mount and automount unit types, but that's already enough to consider it generic unit functionality, hence move it out of mount.c and into unit.c.
2015-05-11core,network: major per-object logging reworkLennart Poettering
This changes log_unit_info() (and friends) to take a real Unit* object insted of just a unit name as parameter. The call will now prefix all logged messages with the unit name, thus allowing the unit name to be dropped from the various passed romat strings, simplifying invocations drastically, and unifying log output across messages. Also, UNIT= vs. USER_UNIT= is now derived from the Manager object attached to the Unit object, instead of getpid(). This has the benefit of correcting the field for --test runs. Also contains a couple of other logging improvements: - Drops a couple of strerror() invocations in favour of using %m. - Not only .mount units now warn if a symlinks exist for the mount point already, .automount units do that too, now. - A few invocations of log_struct() that didn't actually pass any additional structured data have been replaced by simpler invocations of log_unit_info() and friends. - For structured data a new LOG_UNIT_MESSAGE() macro has been added, that works like LOG_MESSAGE() but prefixes the message with the unit name. Similar, there's now LOG_LINK_MESSAGE() and LOG_NETDEV_MESSAGE(). - For structured data new LOG_UNIT_ID(), LOG_LINK_INTERFACE(), LOG_NETDEV_INTERFACE() macros have been added that generate the necessary per object fields. The old log_unit_struct() call has been removed in favour of these new macros used in raw log_struct() invocations. In addition to removing one more function call this allows generated structured log messages that contain two object fields, as necessary for example for network interfaces that are joined into another network interface, and whose messages shall be indexed by both. - The LOG_ERRNO() macro has been removed, in favour of log_struct_errno(). The latter has the benefit of ensuring that %m in format strings is properly resolved to the specified error number. - A number of logging messages have been converted to use log_unit_info() instead of log_info() - The client code in sysv-generator no longer #includes core code from src/core/. - log_unit_full_errno() has been removed, log_unit_full() instead takes an errno now, too. - log_unit_info(), log_link_info(), log_netdev_info() and friends, now avoid double evaluation of their parameters
2015-05-11core: always initialize ExecParamters.bus_endpoint_fd to -1Lennart Poettering
Otherwise it might be passed in as 0, which is a valid fd, but usually does not refer to a real endpoint.
2015-05-05core: rework unit name validation and manipulation logicLennart Poettering
A variety of changes: - Make sure all our calls distuingish OOM from other errors if OOM is not the only error possible. - Be much stricter when parsing escaped paths, do not accept trailing or leading escaped slashes. - Change unit validation to take a bit mask for allowing plain names, instance names or template names or an combination thereof. - Refuse manipulating invalid unit name
2015-04-29core: annotate event sourcesTom Gundersen
2015-04-24Revert "core: do not spawn jobs or touch other units during coldplugging"Lennart Poettering
This reverts commit 6e392c9c45643d106673c6643ac8bf4e65da13c1. We really shouldn't invent external state keeping hashmaps, if we can keep this state in the units themselves.
2015-04-21automount: add expire supportMichael Olbrich
2015-04-10shared: add formats-util.hRonny Chevalier
2015-04-07util: rework cunescape(), improve error handlingLennart Poettering
Change cunescape() to return a normal error code, so that we can distuingish OOM errors from parse errors. This also adds a flags parameter to control whether "relaxed" or normal parsing shall be done. If set no parse failures are generated, and the only reason why cunescape() can fail is OOM.
2015-04-01mount: fix up wording in the commentMichal Sekletar
2015-04-01mount: don't run quotaon only for network filesystemsLukas Nykryn
If you have for example ext4 on iscsi devices it is possible to setup qoutas there. Unfortunately, because such fstab entry contains _netdev, systemd will not add dependency to quotaon.service.
2015-03-07core: do not spawn jobs or touch other units during coldpluggingIvan Shapovalov
Because the order of coldplugging is not defined, we can reference a not-yet-coldplugged unit and read its state while it has not yet been set to a meaningful value. This way, already active units may get started again. We fix this by deferring such actions until all units have been at least somehow coldplugged. Fixes https://bugs.freedesktop.org/show_bug.cgi?id=88401
2015-03-02core: expose consumed CPU time per unitLennart Poettering
This adds support for showing the accumulated consumed CPU time per-unit in the "systemctl status" output. The property is also readable via the bus.
2015-02-28core: rework device state logicLennart Poettering
This change introduces a new state "tentative" for device units. Device units are considered "plugged" when udev announced them, "dead" when they are not available in the kernel, and "tentative" when they are referenced in /proc/self/mountinfo or /proc/swaps but not (yet) announced via udev. This should fix a race when device nodes (like loop devices) are created and immediately mounted. Previously, systemd might end up seeing the mount unit before the device, and would thus pull down the mount because its BindTo dependency on the device would not be fulfilled.
2015-02-23remove unused includesThomas Hindoe Paaboel Andersen
This patch removes includes that are not used. The removals were found with include-what-you-use which checks if any of the symbols from a header is in use.
2015-02-03util: rework strappenda(), and rename it strjoina()Lennart Poettering
After all it is now much more like strjoin() than strappend(). At the same time, add support for NULL sentinels, even if they are normally not necessary.
2015-01-28core/mount: add dependencies to dynamically mounted mounts tooMartin Pitt
Add unit dependencies for dynamic (i. e. not from fstab) mounts. With that, mount units properly bind to their underlying device, and thus get automatically stopped/unmounted when the underlying device goes away. This cleans up stale mounts from unplugged devices. Thanks to Lennart Poettering for pointing out the fix!
2015-01-28core: output unit status output strings to console, only if we actually are ↵Lennart Poettering
changing unit state Unit _start() and _stop() implementations can fail with -EAGAIN to delay execution temporarily. Thus, we should not output status messages before invoking these calls, but after, and only when we know that the invocation actually made a change.
2015-01-23core,shutdown: don't bother with unmounting any mounts below /sys, /proc, ↵Lennart Poettering
/dev when shutting down After all, mounts below these directories are pretty much guaranteed to be virtual, and it's hence unnecessary to unmount them during shutdown. Moreover, in less-priviliged containers we might lack the rights to unmount them, hence don't even try. http://lists.freedesktop.org/archives/systemd-devel/2015-January/027113.html
2015-01-12core/mount: remove "fail" againZbigniew Jędrzejewski-Szmek
deb6120920 'man: there's actually no "fail" fstab option, but only "nofail" removed it from our documentation, which I missed. fstab(5) only mentions "auto", "noauto", and "nofail". Stick to those three.
2015-01-12core/mount: use isempty() to check for empty stringsDaniel Mack
strempty() will return an empty string in case the input parameter is a NULL pointer. The correct test to check for an empty string is isempty(), so use that instead. This fixes a regression from commit 17a1c59 ("core/mount: filter out noauto,auto,nofail,fail options").
2015-01-11core/mount: filter out noauto,auto,nofail,fail optionsZbigniew Jędrzejewski-Szmek
We passed the full option string from fstab to /bin/mount. It would in turn pass the full option string to its helper, if it needed to invoke one. Some helpers would ignore things like "nofail", but others would be confused. We could try to get all helpers to ignore those "meta-options", but it seems better to simply filter them out. In our model, /bin/mount simply has no business in knowing whether the mount was configured as fail or nofail, auto or noauto, in the fstab. If systemd tells invokes a command to mount something, and it fails, it should always return an error. It seems cleaner to filter out the option, since then there's no doubt how the command should behave. https://bugzilla.redhat.com/show_bug.cgi?id=1177823
2015-01-11Add new function to filter fstab optionsZbigniew Jędrzejewski-Szmek
This fixes parsing of options in shared/generator.c. Existing code had some issues: - it would treate whitespace and semicolons as seperators. fstab(5) is pretty clear that only commas matter. And the syntax does not allow for spaces to be inserted in the field in fstab. Whitespace might be escaped, but then it should not seperate options. Treat whitespace and semicolons as any other character. - it assumed that x-systemd.device-timeout would always be followed by "=". But this is not guaranteed, hasmntopt will return this option even if there's no value. Uninitialized memory could be read. - some error paths would log, and inconsistently, some would just return an error code. Filtering is split out to a separate function and tests are added. Similar code paths in other places are adjusted to use the new function.
2015-01-01mount: do not use -n when running in --user modeZbigniew Jędrzejewski-Szmek
-n is only allowed for root. /etc/mtab is nowadays almost always a link to /proc/, so in practice this does not really matter too much, but should allow .mount units to work in --user mode. https://bugs.freedesktop.org/show_bug.cgi?id=87602
2014-12-24util: fix strict aliasing violations in use of struct inotify_event v5Shawn Paul Landden
There is alot of cleanup that will have to happen to turn on -fstrict-aliasing, but I think our code should be "correct" to the rule.
2014-12-15unit: handle nicely of certain unit types are not supported on specific systemsLennart Poettering
Containers do not really support .device, .automount or .swap units; Systems compiled without support for swap do not support .swap units; Systems without kdbus do not support .busname units. With this change attempts to start a unsupported unit types will result in an immediate "unsupported" job result, which is a lot more descriptive then before. Also, attempts to start device units in containers will now immediately fail instead of causing jobs to be enqueued that never go away.
2014-12-12core: retry unmounting until we are done, in case of stacked mountsLennart Poettering
2014-12-10sd-bus: move common errors src/shared/bus-errors.h → ↵Lennart Poettering
src/libsystemd/sd-bus/bus-common-errors.h Stuff in src/shared/ should not use stuff from src/libsystemd/ really.
2014-12-10mount: clarify that we really need to replace the utab inotify code with the ↵Lennart Poettering
native API for this in libmount, as soon as that's stable
2014-12-10core: unify how we iterate over inotify eventsLennart Poettering
Let's add some syntactic sugar for iterating through inotify events, and use it everywhere.
2014-12-10mount: use bools where appropriateLennart Poettering
2014-11-28mount: use DEFINE_TRIVIAL_CLEANUP_FUNCZbigniew Jędrzejewski-Szmek
2014-11-28mount: constify MountParametersZbigniew Jędrzejewski-Szmek
2014-11-28mount: deal with inotify queue overflowZbigniew Jędrzejewski-Szmek
Overflow is very unlikely, since we are watching a privileged directory, but could be triggered if thousands of mounts are suddently executed.
2014-11-28mount: create directory before adding watches on itZbigniew Jędrzejewski-Szmek
2014-11-28mount: be more careful about errors when parsing mtabZbigniew Jędrzejewski-Szmek
Fixup for 4a3a9ef610.
2014-11-28mount: simplify mount_needs_network checkZbigniew Jędrzejewski-Szmek
2014-11-28mount: check options as well as fstype for network mountsChris Leech
When creating a new mount unit after an event on /proc/self/mountinfo, check the mount options as well as the fstype to determine if this is a remote mount that requires network access.
2014-11-28mount: add remote-fs dependencies if needed after changeChris Leech
This is an attempt to add it the remote-fs dependencies to a mount unit if the options change, like when the utab options are picked up after mountinfo has already been processed. It just adds the remote-fs dependencies, leaving the local-fs ones in place. With this change I always get mount units with proper remote-fs dependencies when mounted with the _netdev option.
2014-11-28mount: monitor for utab changes with inotifyChris Leech
Parsing the mount table with libmount races against the mount command, which will handle the actual mounting before updating utab. This means the poll event on /proc/self/mountinfo can kick of a reparse in systemd before the utab information is available. This change adds in an additional event source using inotify to watch for changes to utab. It only watches for IN_MOVED_TO events, matching libmount behavior of always overwriting this file using rename(2). This does add a second pass through the mount table parsing when utab is updated.
2014-11-28mount: use libmount to enumerate /proc/self/mountinfoChris Leech
This lets libmount add in user options from /run/mount/utab, like _netdev which is needed to get proper ordering against remote-fs.target