Changeset View
Changeset View
Standalone View
Standalone View
lib/libbe/be.c
Show All 29 Lines | |||||
#include <sys/param.h> | #include <sys/param.h> | ||||
#include <sys/mount.h> | #include <sys/mount.h> | ||||
#include <sys/stat.h> | #include <sys/stat.h> | ||||
#include <sys/ucred.h> | #include <sys/ucred.h> | ||||
#include <sys/queue.h> | #include <sys/queue.h> | ||||
#include <sys/zfs_context.h> | #include <sys/zfs_context.h> | ||||
#include <sys/mntent.h> | #include <sys/mntent.h> | ||||
#include <sys/zfs_ioctl.h> | |||||
#include <libzutil.h> | |||||
#include <ctype.h> | #include <ctype.h> | ||||
#include <libgen.h> | #include <libgen.h> | ||||
#include <libzfs_core.h> | #include <libzfs_core.h> | ||||
#include <libzfs_impl.h> | |||||
#include <libzfs_os.h> | |||||
#include <stdio.h> | #include <stdio.h> | ||||
#include <stdlib.h> | #include <stdlib.h> | ||||
#include <time.h> | #include <time.h> | ||||
#include <unistd.h> | #include <unistd.h> | ||||
#include "be.h" | #include "be.h" | ||||
#include "be_impl.h" | #include "be_impl.h" | ||||
Show All 13 Lines | |||||
static int be_create_child_noent(libbe_handle_t *lbh, const char *active, | static int be_create_child_noent(libbe_handle_t *lbh, const char *active, | ||||
const char *child_path); | const char *child_path); | ||||
static int be_create_child_cloned(libbe_handle_t *lbh, const char *active); | static int be_create_child_cloned(libbe_handle_t *lbh, const char *active); | ||||
#endif | #endif | ||||
/* Arbitrary... should tune */ | /* Arbitrary... should tune */ | ||||
#define BE_SNAP_SERIAL_MAX 1024 | #define BE_SNAP_SERIAL_MAX 1024 | ||||
static void | |||||
optadd(char *mntopts, size_t size, const char *opt) | |||||
{ | |||||
if (mntopts[0] != '\0') | |||||
strlcat(mntopts, ",", size); | |||||
strlcat(mntopts, opt, size); | |||||
} | |||||
/* | /* | ||||
* Iterator function for locating the rootfs amongst the children of the | * Iterator function for locating the rootfs amongst the children of the | ||||
* zfs_be_root set by loader(8). data is expected to be a libbe_handle_t *. | * zfs_be_root set by loader(8). data is expected to be a libbe_handle_t *. | ||||
*/ | */ | ||||
static int | static int | ||||
be_locate_rootfs(libbe_handle_t *lbh) | be_locate_rootfs(libbe_handle_t *lbh) | ||||
{ | { | ||||
struct statfs sfs; | struct statfs sfs; | ||||
▲ Show 20 Lines • Show All 909 Lines • ▼ Show 20 Lines | be_rename(libbe_handle_t *lbh, const char *old, const char *new) | ||||
if (zfs_dataset_exists(lbh->lzh, full_new, ZFS_TYPE_DATASET)) | if (zfs_dataset_exists(lbh->lzh, full_new, ZFS_TYPE_DATASET)) | ||||
return (set_error(lbh, BE_ERR_EXISTS)); | return (set_error(lbh, BE_ERR_EXISTS)); | ||||
if ((zfs_hdl = zfs_open(lbh->lzh, full_old, | if ((zfs_hdl = zfs_open(lbh->lzh, full_old, | ||||
ZFS_TYPE_FILESYSTEM)) == NULL) | ZFS_TYPE_FILESYSTEM)) == NULL) | ||||
return (set_error(lbh, BE_ERR_ZFSOPEN)); | return (set_error(lbh, BE_ERR_ZFSOPEN)); | ||||
/* recurse, nounmount, forceunmount */ | |||||
struct renameflags flags = { | |||||
.nounmount = 1, | |||||
}; | |||||
err = zfs_rename(zfs_hdl, NULL, full_new, flags); | err = zfs_rename(zfs_hdl,full_new, B_FALSE, B_FALSE); | ||||
zfs_close(zfs_hdl); | zfs_close(zfs_hdl); | ||||
if (err != 0) | if (err != 0) | ||||
return (set_error(lbh, BE_ERR_UNKNOWN)); | return (set_error(lbh, BE_ERR_UNKNOWN)); | ||||
return (0); | return (0); | ||||
} | } | ||||
Show All 10 Lines | if ((err = be_snapshot(lbh, bootenv, NULL, true, snap_name)) != 0) | ||||
/* Use the error set by be_snapshot */ | /* Use the error set by be_snapshot */ | ||||
return (err); | return (err); | ||||
be_root_concat(lbh, snap_name, buf); | be_root_concat(lbh, snap_name, buf); | ||||
if ((zfs = zfs_open(lbh->lzh, buf, ZFS_TYPE_DATASET)) == NULL) | if ((zfs = zfs_open(lbh->lzh, buf, ZFS_TYPE_DATASET)) == NULL) | ||||
return (set_error(lbh, BE_ERR_ZFSOPEN)); | return (set_error(lbh, BE_ERR_ZFSOPEN)); | ||||
err = zfs_send_one(zfs, NULL, fd, flags); | err = zfs_send_one(zfs, NULL, fd, &flags, /* redactbook */ ""); | ||||
zfs_close(zfs); | zfs_close(zfs); | ||||
return (err); | return (err); | ||||
} | } | ||||
int | int | ||||
be_import(libbe_handle_t *lbh, const char *bootenv, int fd) | be_import(libbe_handle_t *lbh, const char *bootenv, int fd) | ||||
▲ Show 20 Lines • Show All 300 Lines • Show Last 20 Lines |