btrfs-progs: receive: add missing unused inode number reads from the stream

Kernel emits inode number for all mkfile/mkdir/... commands but the
receive part does not pass it to the callbacks. At least document that
and read it from the stream in case we'd like to use it in the future.

Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
David Sterba 2021-10-25 16:48:48 +02:00
parent 7674317139
commit 17aab2e428

View File

@ -324,6 +324,7 @@ static int read_and_process_cmd(struct btrfs_send_stream *sctx)
u64 dev; u64 dev;
u64 clone_offset; u64 clone_offset;
u64 offset; u64 offset;
u64 ino;
int len; int len;
int xattr_len; int xattr_len;
@ -349,28 +350,40 @@ static int read_and_process_cmd(struct btrfs_send_stream *sctx)
break; break;
case BTRFS_SEND_C_MKFILE: case BTRFS_SEND_C_MKFILE:
TLV_GET_STRING(sctx, BTRFS_SEND_A_PATH, &path); TLV_GET_STRING(sctx, BTRFS_SEND_A_PATH, &path);
/* ino is not passed to the callbacks in v1 */
TLV_GET_U64(sctx, BTRFS_SEND_A_INO, &ino);
ret = sctx->ops->mkfile(path, sctx->user); ret = sctx->ops->mkfile(path, sctx->user);
break; break;
case BTRFS_SEND_C_MKDIR: case BTRFS_SEND_C_MKDIR:
TLV_GET_STRING(sctx, BTRFS_SEND_A_PATH, &path); TLV_GET_STRING(sctx, BTRFS_SEND_A_PATH, &path);
/* ino is not passed to the callbacks in v1 */
TLV_GET_U64(sctx, BTRFS_SEND_A_INO, &ino);
ret = sctx->ops->mkdir(path, sctx->user); ret = sctx->ops->mkdir(path, sctx->user);
break; break;
case BTRFS_SEND_C_MKNOD: case BTRFS_SEND_C_MKNOD:
TLV_GET_STRING(sctx, BTRFS_SEND_A_PATH, &path); TLV_GET_STRING(sctx, BTRFS_SEND_A_PATH, &path);
/* ino is not passed to the callbacks in v1 */
TLV_GET_U64(sctx, BTRFS_SEND_A_INO, &ino);
TLV_GET_U64(sctx, BTRFS_SEND_A_MODE, &mode); TLV_GET_U64(sctx, BTRFS_SEND_A_MODE, &mode);
TLV_GET_U64(sctx, BTRFS_SEND_A_RDEV, &dev); TLV_GET_U64(sctx, BTRFS_SEND_A_RDEV, &dev);
ret = sctx->ops->mknod(path, mode, dev, sctx->user); ret = sctx->ops->mknod(path, mode, dev, sctx->user);
break; break;
case BTRFS_SEND_C_MKFIFO: case BTRFS_SEND_C_MKFIFO:
TLV_GET_STRING(sctx, BTRFS_SEND_A_PATH, &path); TLV_GET_STRING(sctx, BTRFS_SEND_A_PATH, &path);
/* ino is not passed to the callbacks in v1 */
TLV_GET_U64(sctx, BTRFS_SEND_A_INO, &ino);
ret = sctx->ops->mkfifo(path, sctx->user); ret = sctx->ops->mkfifo(path, sctx->user);
break; break;
case BTRFS_SEND_C_MKSOCK: case BTRFS_SEND_C_MKSOCK:
TLV_GET_STRING(sctx, BTRFS_SEND_A_PATH, &path); TLV_GET_STRING(sctx, BTRFS_SEND_A_PATH, &path);
/* ino is not passed to the callbacks in v1 */
TLV_GET_U64(sctx, BTRFS_SEND_A_INO, &ino);
ret = sctx->ops->mksock(path, sctx->user); ret = sctx->ops->mksock(path, sctx->user);
break; break;
case BTRFS_SEND_C_SYMLINK: case BTRFS_SEND_C_SYMLINK:
TLV_GET_STRING(sctx, BTRFS_SEND_A_PATH, &path); TLV_GET_STRING(sctx, BTRFS_SEND_A_PATH, &path);
/* ino is not passed to the callbacks in v1 */
TLV_GET_U64(sctx, BTRFS_SEND_A_INO, &ino);
TLV_GET_STRING(sctx, BTRFS_SEND_A_PATH_LINK, &path_to); TLV_GET_STRING(sctx, BTRFS_SEND_A_PATH_LINK, &path_to);
ret = sctx->ops->symlink(path, path_to, sctx->user); ret = sctx->ops->symlink(path, path_to, sctx->user);
break; break;