Skip to contentSkip to conversation

btrfs-progs: fi resize: fix return value check_resize_args()

PATCH In review Sidong Yang 3 participants 4 messages Aug 11, 2022 – Sep 12, 2022 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 btrfs-progs: fi resize: fix return value check_resize_args()

check_resize_args() function checks user argument amount and should returns it's validity. But now the code returns only zero. This patch make it correct to return ret.

---
 cmds/filesystem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
cmds/filesystem.c +1 -1
index 7cd08fcd..9eff5680 100644
@@ -1203,7 +1203,7 @@ static int check_resize_args(const char *amount, const char *path) {
 
 out:
 	free(di_args);
-	return 0;
+	return ret;
 }
 
 static int cmd_filesystem_resize(const struct cmd_struct *cmd,
Signature · 1 line
2.34.1
#1 lore raw
Quoted 5 lines · Sidong Yang

check_resize_args() function checks user argument amount and should returns it's validity. But now the code returns only zero. This patch make it correct to return ret.

Added to devel, thanks.

#2 lore raw
In reply to Sidong Yang

Hi,

Quoted 14 lines

check_resize_args() function checks user argument amount and should returns it's validity. But now the code returns only zero. This patch make it correct to return ret.

---
 cmds/filesystem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
cmds/filesystem.c +0 -0
index 7cd08fcd..9eff5680 100644

cmds/filesystem.c static int check_resize_args(const char *amount, const char *path) { · line 1209

Quoted 8 lines
cmds/filesystem.c +1 -1
@@ -1203,7 +1203,7 @@ static int check_resize_args(const char *amount, const char *path) {
 
 out:
 	free(di_args);
-	return 0;
+	return ret;
 }
 
 static int cmd_filesystem_resize(const struct cmd_struct *cmd,

This patch will make 'btrfs filesystem resize' always fail, and then break fstests btrfs/177.

# df -h /mnt/scratch/
Filesystem      Size  Used Avail Use% Mounted on
/dev/sdb2       1.0G  3.4M  927M   1% /mnt/scratch
# btrfs filesystem resize 3G /mnt/scratch/
Resize device id 1 (/dev/sdb2) from 3.00GiB to 3.00GiB
# echo $?
1
# df -h /mnt/scratch/
Filesystem      Size  Used Avail Use% Mounted on
/dev/sdb2       1.0G  3.4M  927M   1% /mnt/scratch

'ret' is set to 2 here.

    ret = snprintf(amount_dup, BTRFS_VOL_NAME_MAX, "%s", amount);
    if (strlen(amount) != ret) {
        error("newsize argument is too long");
        ret = 1;
        goto out;
    }

Best Regards
Wang Yugui ([email protected])
2022/09/12

#3 lore raw
Quoted 23 lines · Wang Yugui

Hi,

Quoted 21 lines

check_resize_args() function checks user argument amount and should returns it's validity. But now the code returns only zero. This patch make it correct to return ret.

---
 cmds/filesystem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
cmds/filesystem.c +1 -1
index 7cd08fcd..9eff5680 100644
@@ -1203,7 +1203,7 @@ static int check_resize_args(const char *amount, const char *path) {
 
 out:
 	free(di_args);
-	return 0;
+	return ret;
 }
 
Quoted 4 lines

cmds/filesystem.c static int check_resize_args(const char *amount, const char *path) { · line 1209

Quoted 1 line
cmds/filesystem.c +0 -0
 static int cmd_filesystem_resize(const struct cmd_struct *cmd,

This patch will make 'btrfs filesystem resize' always fail, and then break fstests btrfs/177.

I noticed that too when doing the progs release so the patch will be dropped.