mirror of
https://github.com/systemd/systemd.git
synced 2024-11-06 16:59:03 +03:00
ebc8968bc0
Since commit 9d06297
, mount units from mountinfo are not bound to their devices
anymore (they use the "Requires" dependency instead).
This has the following drawback: if a media is mounted and the eject button is
pressed then the media is unconditionally ejected leaving some inconsistent
states.
Since udev is the component that is reacting (no matter if the device is used
or not) to the eject button, users expect that udev at least try to unmount the
media properly.
This patch introduces a new property "SYSTEMD_MOUNT_DEVICE_BOUND". When set on
a block device, all units that requires this device will see their "Requires"
dependency upgraded to a "BindTo" one. This is currently only used by cdrom
devices.
This patch also gives the possibility to the user to restore the previous
behavior that is bind a mount unit to a device. This is achieved by passing the
"x-systemd.device-bound" option to mount(8). Please note that currently this is
not working because libmount treats the x-* options has comments therefore
they're not available in utab for later application retrievals.
51 lines
1.5 KiB
C
51 lines
1.5 KiB
C
#pragma once
|
|
|
|
/***
|
|
This file is part of systemd.
|
|
|
|
Copyright 2010 Lennart Poettering
|
|
|
|
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.
|
|
|
|
systemd is distributed in the hope that it will be useful, but
|
|
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Lesser General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Lesser General Public License
|
|
along with systemd; If not, see <http://www.gnu.org/licenses/>.
|
|
***/
|
|
|
|
typedef struct Device Device;
|
|
|
|
typedef enum DeviceFound {
|
|
DEVICE_NOT_FOUND = 0,
|
|
DEVICE_FOUND_UDEV = 1,
|
|
DEVICE_FOUND_MOUNT = 2,
|
|
DEVICE_FOUND_SWAP = 4,
|
|
} DeviceFound;
|
|
|
|
struct Device {
|
|
Unit meta;
|
|
|
|
char *sysfs;
|
|
DeviceFound found;
|
|
|
|
/* In order to be able to distinguish dependencies on
|
|
different device nodes we might end up creating multiple
|
|
devices for the same sysfs path. We chain them up here. */
|
|
LIST_FIELDS(struct Device, same_sysfs);
|
|
|
|
DeviceState state, deserialized_state;
|
|
|
|
bool bind_mounts;
|
|
};
|
|
|
|
extern const UnitVTable device_vtable;
|
|
|
|
int device_found_node(Manager *m, const char *node, bool add, DeviceFound found, bool now);
|
|
bool device_shall_be_bound_by(Unit *device, Unit *u);
|