btrfs-progs: send: use static buffer for output file name
Signed-off-by: David Sterba <dsterba@suse.cz>
This commit is contained in:
parent
a245463281
commit
d304cf1a2d
13
cmds-send.c
13
cmds-send.c
|
@ -427,7 +427,7 @@ int cmd_send(int argc, char **argv)
|
||||||
{
|
{
|
||||||
char *subvol = NULL;
|
char *subvol = NULL;
|
||||||
int ret;
|
int ret;
|
||||||
char *outname = NULL;
|
char outname[PATH_MAX];
|
||||||
struct btrfs_send send;
|
struct btrfs_send send;
|
||||||
u32 i;
|
u32 i;
|
||||||
char *mount_root = NULL;
|
char *mount_root = NULL;
|
||||||
|
@ -440,6 +440,7 @@ int cmd_send(int argc, char **argv)
|
||||||
|
|
||||||
memset(&send, 0, sizeof(send));
|
memset(&send, 0, sizeof(send));
|
||||||
send.dump_fd = fileno(stdout);
|
send.dump_fd = fileno(stdout);
|
||||||
|
outname[0] = 0;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
enum { GETOPT_VAL_SEND_NO_DATA = 256 };
|
enum { GETOPT_VAL_SEND_NO_DATA = 256 };
|
||||||
|
@ -507,7 +508,13 @@ int cmd_send(int argc, char **argv)
|
||||||
full_send = 0;
|
full_send = 0;
|
||||||
break;
|
break;
|
||||||
case 'f':
|
case 'f':
|
||||||
outname = optarg;
|
if (arg_copy_path(outname, optarg, sizeof(outname))) {
|
||||||
|
fprintf(stderr,
|
||||||
|
"ERROR: output file path too long (%zu)\n",
|
||||||
|
strlen(optarg));
|
||||||
|
ret = 1;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'p':
|
case 'p':
|
||||||
if (snapshot_parent) {
|
if (snapshot_parent) {
|
||||||
|
@ -555,7 +562,7 @@ int cmd_send(int argc, char **argv)
|
||||||
if (check_argc_min(argc - optind, 1))
|
if (check_argc_min(argc - optind, 1))
|
||||||
usage(cmd_send_usage);
|
usage(cmd_send_usage);
|
||||||
|
|
||||||
if (outname != NULL) {
|
if (outname[0]) {
|
||||||
send.dump_fd = creat(outname, 0600);
|
send.dump_fd = creat(outname, 0600);
|
||||||
if (send.dump_fd == -1) {
|
if (send.dump_fd == -1) {
|
||||||
ret = -errno;
|
ret = -errno;
|
||||||
|
|
Loading…
Reference in New Issue