tmpfiles: add new line type 'v' for creating btrfs subvolumes
This commit is contained in:
parent
ebd93cb684
commit
d7b8eec7dc
|
@ -167,6 +167,17 @@ L /tmp/foobar - - - - /dev/null</programlisting>
|
|||
<listitem><para>Create or empty a directory.</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><varname>v</varname></term>
|
||||
<listitem><para>Create a
|
||||
subvolume if the path does not
|
||||
exist yet and the file system
|
||||
supports this (btrfs). Otherwise
|
||||
create a normal directory, in
|
||||
the same way as
|
||||
<varname>d</varname>.</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><varname>p</varname></term>
|
||||
<term><varname>p+</varname></term>
|
||||
|
|
|
@ -42,9 +42,7 @@
|
|||
#include "sd-daemon.h"
|
||||
#include "sd-messages.h"
|
||||
#include "sd-bus.h"
|
||||
#include "manager.h"
|
||||
#include "log.h"
|
||||
#include "load-fragment.h"
|
||||
#include "fdset.h"
|
||||
#include "special.h"
|
||||
#include "conf-parser.h"
|
||||
|
@ -64,9 +62,12 @@
|
|||
#include "env-util.h"
|
||||
#include "clock-util.h"
|
||||
#include "fileio.h"
|
||||
#include "dbus-manager.h"
|
||||
#include "bus-error.h"
|
||||
#include "bus-util.h"
|
||||
#include "selinux-util.h"
|
||||
#include "manager.h"
|
||||
#include "dbus-manager.h"
|
||||
#include "load-fragment.h"
|
||||
|
||||
#include "mount-setup.h"
|
||||
#include "loopback-setup.h"
|
||||
|
|
|
@ -35,7 +35,6 @@
|
|||
#include "strv.h"
|
||||
#include "util.h"
|
||||
#include "path-util.h"
|
||||
#include "namespace.h"
|
||||
#include "missing.h"
|
||||
#include "execute.h"
|
||||
#include "loopback-setup.h"
|
||||
|
@ -43,6 +42,8 @@
|
|||
#include "dev-setup.h"
|
||||
#include "def.h"
|
||||
#include "label.h"
|
||||
#include "selinux-util.h"
|
||||
#include "namespace.h"
|
||||
|
||||
typedef enum MountMode {
|
||||
/* This is ordered by priority! */
|
||||
|
|
|
@ -48,6 +48,7 @@
|
|||
#include "smack-util.h"
|
||||
#include "bus-util.h"
|
||||
#include "bus-error.h"
|
||||
#include "selinux-util.h"
|
||||
#include "dbus-socket.h"
|
||||
#include "unit.h"
|
||||
#include "socket.h"
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include "label.h"
|
||||
#include "bus-util.h"
|
||||
#include "event-util.h"
|
||||
#include "selinux-util.h"
|
||||
|
||||
#define VALID_DEPLOYMENT_CHARS (DIGITS LETTERS "-.:")
|
||||
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
#include "bus-message.h"
|
||||
#include "event-util.h"
|
||||
#include "locale-util.h"
|
||||
#include "selinux-util.h"
|
||||
|
||||
#ifdef HAVE_XKBCOMMON
|
||||
#include <xkbcommon/xkbcommon.h>
|
||||
|
|
|
@ -39,9 +39,10 @@
|
|||
#include "audit.h"
|
||||
#include "bus-util.h"
|
||||
#include "bus-error.h"
|
||||
#include "logind.h"
|
||||
#include "bus-common-errors.h"
|
||||
#include "udev-util.h"
|
||||
#include "selinux-util.h"
|
||||
#include "logind.h"
|
||||
|
||||
static int property_get_idle_hint(
|
||||
sd_bus *bus,
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include "mkdir.h"
|
||||
#include "label.h"
|
||||
#include "capability.h"
|
||||
#include "selinux-util.h"
|
||||
|
||||
#include "resolved-manager.h"
|
||||
#include "resolved-conf.h"
|
||||
|
|
|
@ -33,6 +33,8 @@
|
|||
#include "macro.h"
|
||||
#include "strv.h"
|
||||
#include "copy.h"
|
||||
#include "selinux-util.h"
|
||||
#include "smack-util.h"
|
||||
#include "btrfs-ctree.h"
|
||||
#include "btrfs-util.h"
|
||||
|
||||
|
@ -184,6 +186,24 @@ int btrfs_subvol_make(const char *path) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int btrfs_subvol_make_label(const char *path) {
|
||||
int r;
|
||||
|
||||
assert(path);
|
||||
|
||||
r = mac_selinux_create_file_prepare(path, S_IFDIR);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = btrfs_subvol_make(path);
|
||||
mac_selinux_create_file_clear();
|
||||
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
return mac_smack_fix(path, false, false);
|
||||
}
|
||||
|
||||
int btrfs_subvol_remove(const char *path) {
|
||||
struct btrfs_ioctl_vol_args args = {};
|
||||
_cleanup_close_ int fd = -1;
|
||||
|
|
|
@ -37,6 +37,7 @@ typedef struct BtrfsSubvolInfo {
|
|||
int btrfs_is_snapshot(int fd);
|
||||
|
||||
int btrfs_subvol_make(const char *path);
|
||||
int btrfs_subvol_make_label(const char *path);
|
||||
int btrfs_subvol_remove(const char *path);
|
||||
int btrfs_subvol_snapshot(const char *old_path, const char *new_path, bool read_only, bool fallback_copy);
|
||||
|
||||
|
|
|
@ -23,9 +23,10 @@
|
|||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "fileio-label.h"
|
||||
#include "label.h"
|
||||
#include "util.h"
|
||||
#include "selinux-util.h"
|
||||
#include "label.h"
|
||||
#include "fileio-label.h"
|
||||
|
||||
int write_string_file_atomic_label(const char *fn, const char *line) {
|
||||
int r;
|
||||
|
|
|
@ -19,8 +19,10 @@
|
|||
along with systemd; If not, see <http://www.gnu.org/licenses/>.
|
||||
***/
|
||||
|
||||
#include "label.h"
|
||||
#include "selinux-util.h"
|
||||
#include "smack-util.h"
|
||||
#include "util.h"
|
||||
#include "label.h"
|
||||
|
||||
int label_fix(const char *path, bool ignore_enoent, bool ignore_erofs) {
|
||||
int r, q;
|
||||
|
|
|
@ -21,8 +21,8 @@
|
|||
along with systemd; If not, see <http://www.gnu.org/licenses/>.
|
||||
***/
|
||||
|
||||
#include "selinux-util.h"
|
||||
#include "smack-util.h"
|
||||
#include <stdbool.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
int label_fix(const char *path, bool ignore_enoent, bool ignore_erofs);
|
||||
|
||||
|
|
|
@ -35,9 +35,10 @@
|
|||
#include "macro.h"
|
||||
#include "util.h"
|
||||
#include "mkdir.h"
|
||||
#include "socket-util.h"
|
||||
#include "missing.h"
|
||||
#include "label.h"
|
||||
#include "selinux-util.h"
|
||||
#include "socket-util.h"
|
||||
|
||||
int socket_address_listen(
|
||||
const SocketAddress *a,
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
#include "label.h"
|
||||
#include "fileio-label.h"
|
||||
#include "uid-range.h"
|
||||
#include "selinux-util.h"
|
||||
|
||||
typedef enum ItemType {
|
||||
ADD_USER = 'u',
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include <sys/signalfd.h>
|
||||
|
||||
#include "missing.h"
|
||||
#include "selinux-util.h"
|
||||
#include "udev.h"
|
||||
#include "udev-util.h"
|
||||
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
#include "bus-error.h"
|
||||
#include "bus-common-errors.h"
|
||||
#include "event-util.h"
|
||||
#include "selinux-util.h"
|
||||
|
||||
#define NULL_ADJTIME_UTC "0.0 0 0\n0\nUTC\n"
|
||||
#define NULL_ADJTIME_LOCAL "0.0 0 0\n0\nLOCAL\n"
|
||||
|
|
|
@ -54,6 +54,8 @@
|
|||
#include "specifier.h"
|
||||
#include "build.h"
|
||||
#include "copy.h"
|
||||
#include "selinux-util.h"
|
||||
#include "btrfs-util.h"
|
||||
|
||||
/* This reads all files listed in /etc/tmpfiles.d/?*.conf and creates
|
||||
* them in the file system. This is intended to be used to create
|
||||
|
@ -66,6 +68,7 @@ typedef enum ItemType {
|
|||
TRUNCATE_FILE = 'F',
|
||||
CREATE_DIRECTORY = 'd',
|
||||
TRUNCATE_DIRECTORY = 'D',
|
||||
CREATE_SUBVOLUME = 'v',
|
||||
CREATE_FIFO = 'p',
|
||||
CREATE_SYMLINK = 'L',
|
||||
CREATE_CHAR_DEVICE = 'c',
|
||||
|
@ -758,17 +761,27 @@ static int create_item(Item *i) {
|
|||
|
||||
break;
|
||||
|
||||
case TRUNCATE_DIRECTORY:
|
||||
case CREATE_DIRECTORY:
|
||||
case TRUNCATE_DIRECTORY:
|
||||
case CREATE_SUBVOLUME:
|
||||
|
||||
RUN_WITH_UMASK(0000) {
|
||||
RUN_WITH_UMASK(0000)
|
||||
mkdir_parents_label(i->path, 0755);
|
||||
r = mkdir_label(i->path, i->mode);
|
||||
|
||||
if (i->type == CREATE_SUBVOLUME) {
|
||||
RUN_WITH_UMASK((~i->mode) & 0777)
|
||||
r = btrfs_subvol_make(i->path);
|
||||
} else
|
||||
r = 0;
|
||||
|
||||
if (i->type == CREATE_DIRECTORY || r == -ENOTTY) {
|
||||
RUN_WITH_UMASK(0000)
|
||||
r = mkdir_label(i->path, i->mode);
|
||||
}
|
||||
|
||||
if (r < 0) {
|
||||
if (r != -EEXIST)
|
||||
return log_error_errno(r, "Failed to create directory %s: %m", i->path);
|
||||
return log_error_errno(r, "Failed to create directory or subvolume %s: %m", i->path);
|
||||
|
||||
if (stat(i->path, &st) < 0)
|
||||
return log_error_errno(errno, "stat(%s) failed: %m", i->path);
|
||||
|
@ -970,6 +983,7 @@ static int remove_item_instance(Item *i, const char *instance) {
|
|||
case CREATE_FILE:
|
||||
case TRUNCATE_FILE:
|
||||
case CREATE_DIRECTORY:
|
||||
case CREATE_SUBVOLUME:
|
||||
case CREATE_FIFO:
|
||||
case CREATE_SYMLINK:
|
||||
case CREATE_BLOCK_DEVICE:
|
||||
|
@ -1014,6 +1028,7 @@ static int remove_item(Item *i) {
|
|||
case CREATE_FILE:
|
||||
case TRUNCATE_FILE:
|
||||
case CREATE_DIRECTORY:
|
||||
case CREATE_SUBVOLUME:
|
||||
case CREATE_FIFO:
|
||||
case CREATE_SYMLINK:
|
||||
case CREATE_CHAR_DEVICE:
|
||||
|
@ -1091,6 +1106,7 @@ static int clean_item(Item *i) {
|
|||
|
||||
switch (i->type) {
|
||||
case CREATE_DIRECTORY:
|
||||
case CREATE_SUBVOLUME:
|
||||
case TRUNCATE_DIRECTORY:
|
||||
case IGNORE_PATH:
|
||||
case COPY_FILES:
|
||||
|
@ -1289,6 +1305,7 @@ static int parse_line(const char *fname, unsigned line, const char *buffer) {
|
|||
case CREATE_FILE:
|
||||
case TRUNCATE_FILE:
|
||||
case CREATE_DIRECTORY:
|
||||
case CREATE_SUBVOLUME:
|
||||
case TRUNCATE_DIRECTORY:
|
||||
case CREATE_FIFO:
|
||||
case IGNORE_PATH:
|
||||
|
@ -1429,6 +1446,7 @@ static int parse_line(const char *fname, unsigned line, const char *buffer) {
|
|||
} else
|
||||
i->mode =
|
||||
i->type == CREATE_DIRECTORY ||
|
||||
i->type == CREATE_SUBVOLUME ||
|
||||
i->type == TRUNCATE_DIRECTORY ? 0755 : 0644;
|
||||
|
||||
if (age && !streq(age, "-")) {
|
||||
|
@ -1636,7 +1654,7 @@ static int read_config_file(const char *fn, bool ignore_enoent) {
|
|||
continue;
|
||||
|
||||
HASHMAP_FOREACH(j, items, iter) {
|
||||
if (j->type != CREATE_DIRECTORY && j->type != TRUNCATE_DIRECTORY)
|
||||
if (j->type != CREATE_DIRECTORY && j->type != TRUNCATE_DIRECTORY && j->type != CREATE_SUBVOLUME)
|
||||
continue;
|
||||
|
||||
if (path_equal(j->path, i->path)) {
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
|
||||
#include "udev.h"
|
||||
#include "smack-util.h"
|
||||
#include "selinux-util.h"
|
||||
|
||||
static int node_symlink(struct udev_device *dev, const char *node, const char *slink) {
|
||||
struct stat stats;
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include <errno.h>
|
||||
#include <getopt.h>
|
||||
|
||||
#include "selinux-util.h"
|
||||
#include "udev.h"
|
||||
|
||||
static int adm_version(struct udev *udev, int argc, char *argv[]) {
|
||||
|
|
|
@ -46,13 +46,14 @@
|
|||
#include <sys/inotify.h>
|
||||
#include <sys/utsname.h>
|
||||
|
||||
#include "udev.h"
|
||||
#include "udev-util.h"
|
||||
#include "rtnl-util.h"
|
||||
#include "sd-daemon.h"
|
||||
#include "rtnl-util.h"
|
||||
#include "cgroup-util.h"
|
||||
#include "dev-setup.h"
|
||||
#include "fileio.h"
|
||||
#include "selinux-util.h"
|
||||
#include "udev.h"
|
||||
#include "udev-util.h"
|
||||
|
||||
static struct udev_rules *rules;
|
||||
static struct udev_ctrl *udev_ctrl;
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
|
||||
#include "util.h"
|
||||
#include "label.h"
|
||||
#include "selinux-util.h"
|
||||
|
||||
#define MESSAGE \
|
||||
"This file was created by systemd-update-done. Its only \n" \
|
||||
|
|
Loading…
Reference in a new issue