Commit Graph

7 Commits (master)

Author SHA1 Message Date
David Sterba 4b09ba4b78 btrfs-progs: restore: fix chown of a symlink
User reports:

"When I execute btrfs restore -S to restore a symlink, it prints:

SYMLINK: 'dest/path/of/symlink' => 'symlink/target'
Failed to change owner: Bad file descriptor

And at cmds-restore.c#L937:

ret = fchownat(-1, file, btrfs_inode_uid(path.nodes[0], inode_item),
                           btrfs_inode_gid(path.nodes[0], inode_item),
                           AT_SYMLINK_NOFOLLOW);
"

The -1 is indeed a bad descriptor, and should be probably AT_FDCWD as
this is documented. The path passed as 'file' is always absolute, so the
semantics are unaffected.

Issue: #183
Signed-off-by: David Sterba <dsterba@suse.com>
2019-07-26 17:46:43 +02:00
pjw91 064341dca9 btrfs-progs: restore: Fix input buffer handling
fgets consumes n-1 bytes from input buffer.

When a user types y\n, the newline is left in the buffer.  As a result,
the next fgets uses that \n as answer without waiting for the user to
type.

This patch also fix a bug that dereference the ret without checking if
it's NULL.

* Consumes the `\n` from stdin buffer
* Avoid NULL pointer dereference: treat EOF as default value

Pull-request: #182
Author: pjw91 <mail6543210@yahoo.com.tw>
Signed-off-by: David Sterba <dsterba@suse.com>
2019-07-04 02:06:34 +02:00
David Sterba 94fced6353 btrfs-progs: build: drop kernel-lib from -I and update paths
Include the files by full path to avoid any confusion in case of
potentially duplicate names.

Signed-off-by: David Sterba <dsterba@suse.com>
2019-07-03 20:49:04 +02:00
David Sterba c07960c8be btrfs-progs: move utils.[ch] to common/
Update include paths and remove some duplicates.

Signed-off-by: David Sterba <dsterba@suse.com>
2019-07-03 20:49:04 +02:00
David Sterba aac564aca6 btrfs-progs: move commonh to common/
Signed-off-by: David Sterba <dsterba@suse.com>
2019-07-03 20:49:03 +02:00
David Sterba f93b471143 btrfs-progs: move help.[ch] to common/
Signed-off-by: David Sterba <dsterba@suse.com>
2019-07-03 20:49:03 +02:00
David Sterba 4bee9116bb btrfs-progs: move cmds-restore.c to cmds/
Signed-off-by: David Sterba <dsterba@suse.com>
2019-07-03 20:49:02 +02:00