system/corennnnn
Revision | c7829b52c917be7c9522b17ad72eaf9cd5c11fcf (tree) |
---|---|
Zeit | 2016-09-04 08:46:00 |
Autor | Keith Mok <kmok@cyng...> |
Commiter | Steve Kondik |
fs_mgr: When formating f2fs volumes, respect the length parameter
When formatting a volume because it is marked as formattable, the
length parameter is discarded which makes fs_mgr write a filesystem
to the full length of the block device.
This patch adds length semantics to f2fs formatting, if the length
is greater than zero, use that, if it isn't subtract that size
from the block size.
Change-Id: I526f80aa299e7b34e9802141e7fa7050d5cb5558
Ticket: SAMBAR-729
@@ -67,15 +67,27 @@ static int format_ext4(char *fs_blkdev, char *fs_mnt_point, long long fs_length) | ||
67 | 67 | return rc; |
68 | 68 | } |
69 | 69 | |
70 | -static int format_f2fs(char *fs_blkdev) | |
70 | +static int format_f2fs(char *fs_blkdev, long long fs_length) | |
71 | 71 | { |
72 | - char * args[3]; | |
72 | + char * args[5]; | |
73 | 73 | int pid; |
74 | 74 | int rc = 0; |
75 | + char buff[65]; | |
75 | 76 | |
76 | 77 | args[0] = (char *)"/sbin/mkfs.f2fs"; |
77 | - args[1] = fs_blkdev; | |
78 | - args[2] = (char *)0; | |
78 | + | |
79 | + if (fs_length >= 0) { | |
80 | + snprintf(buff, sizeof(buff), "%lld", fs_length / 512); | |
81 | + args[1] = fs_blkdev; | |
82 | + args[2] = buff; | |
83 | + args[3] = (char *)0; | |
84 | + } else if (fs_length < 0) { | |
85 | + snprintf(buff, sizeof(buff), "%lld", -fs_length); | |
86 | + args[1] = "-r"; | |
87 | + args[2] = buff; | |
88 | + args[3] = fs_blkdev; | |
89 | + args[4] = (char *)0; | |
90 | + } | |
79 | 91 | |
80 | 92 | pid = fork(); |
81 | 93 | if (pid < 0) { |
@@ -114,7 +126,7 @@ int fs_mgr_do_format(struct fstab_rec *fstab) | ||
114 | 126 | ERROR("%s: Format %s as '%s'.\n", __func__, fstab->blk_device, fstab->fs_type); |
115 | 127 | |
116 | 128 | if (!strncmp(fstab->fs_type, "f2fs", 4)) { |
117 | - rc = format_f2fs(fstab->blk_device); | |
129 | + rc = format_f2fs(fstab->blk_device, fstab->length); | |
118 | 130 | } else if (!strncmp(fstab->fs_type, "ext4", 4)) { |
119 | 131 | rc = format_ext4(fstab->blk_device, fstab->mount_point, fstab->length); |
120 | 132 | } else { |