X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/3903760236c30e3b5ace7a4eefac3a269d68957c..c6bf4f310a33a9262d455ea4d3f0630b1255e3fe:/libsyscall/wrappers/fs_snapshot.c diff --git a/libsyscall/wrappers/fs_snapshot.c b/libsyscall/wrappers/fs_snapshot.c index 10aed0453..88b567203 100644 --- a/libsyscall/wrappers/fs_snapshot.c +++ b/libsyscall/wrappers/fs_snapshot.c @@ -43,11 +43,11 @@ fs_snapshot_list(int dirfd, struct attrlist *alist, void *attrbuf, size_t bufsiz { if (flags != 0) { errno = EINVAL; - return (-1); + return -1; } - return (getattrlistbulk(dirfd, alist, attrbuf, bufsize, - FSOPT_LIST_SNAPSHOT)); + return getattrlistbulk(dirfd, alist, attrbuf, bufsize, + FSOPT_LIST_SNAPSHOT); } int @@ -65,57 +65,19 @@ fs_snapshot_rename(int dirfd, const char *old, const char *new, uint32_t flags) int fs_snapshot_revert(int dirfd, const char *name, uint32_t flags) { - return __fs_snapshot(SNAPSHOT_OP_REVERT, dirfd, name, NULL, NULL, flags); + return __fs_snapshot(SNAPSHOT_OP_REVERT, dirfd, name, NULL, NULL, flags); } -/* - * XXX Temporary hack to do what mount_apfs(8) does. This will be removed and - * replaced with a VFS_IOCTL based implementation in the kernel. - */ -#include -#include "strings.h" - -#ifndef SNAPSHOT_OP_MOUNT -#define SNAPSHOT_OP_MOUNT 0x4 -#endif - -#define FS_MOUNT_SNAPSHOT 2 -#define MAX_SNAPSHOT_NAMELEN 256 - -struct fs_mount_options { - uint32_t fs_flags; - uint8_t _padding_[2]; -}; - -struct fs_mount_args { - char *specdev; - struct fs_mount_options options; - uint16_t mode; - uint16_t _padding_[3]; - union { - struct { // FS_MOUNT_SNAPSHOT - dev_t snap_fsys; - char snap_name[MAX_SNAPSHOT_NAMELEN]; - }; - struct { // APFS_MOUNT_FOR_CONVERSION - }; - }; -}; +int +fs_snapshot_root(int dirfd, const char *name, uint32_t flags) +{ + return __fs_snapshot(SNAPSHOT_OP_ROOT, dirfd, name, NULL, NULL, flags); +} int fs_snapshot_mount(int dirfd, const char *dir, const char *snapshot, uint32_t flags) { - struct stat st; - struct fs_mount_args mnt_args; - - mnt_args.specdev = NULL; - mnt_args.mode = FS_MOUNT_SNAPSHOT; - if (fstat(dirfd, &st) == -1) - return (-1); - - mnt_args.snap_fsys = st.st_dev; - strlcpy(mnt_args.snap_name, snapshot, sizeof(mnt_args.snap_name)); - return (__fs_snapshot(SNAPSHOT_OP_MOUNT, dirfd, snapshot, dir, - (void *)&mnt_args, flags)); + return __fs_snapshot(SNAPSHOT_OP_MOUNT, dirfd, snapshot, dir, + NULL, flags); }