system/corennnnn
Revision | 39f5dea21df86534dda11e6e5278f3cab522a8db (tree) |
---|---|
Zeit | 2016-09-04 08:46:00 |
Autor | Diogo Ferreira <diogo@unde...> |
Commiter | Steve Kondik |
fs_mgr: When formating ext4 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 ext4 formatting, if the length
is greater than zero, use that, if it isn't subtract that size
from the block size.
Change-Id: I4d18d5161360f8de0e571352e705678682e61332
Ticket: CYNGNOS-931
@@ -31,7 +31,7 @@ | ||
31 | 31 | extern struct fs_info info; /* magic global from ext4_utils */ |
32 | 32 | extern void reset_ext4fs_info(); |
33 | 33 | |
34 | -static int format_ext4(char *fs_blkdev, char *fs_mnt_point) | |
34 | +static int format_ext4(char *fs_blkdev, char *fs_mnt_point, long long fs_length) | |
35 | 35 | { |
36 | 36 | unsigned int nr_sec; |
37 | 37 | int fd, rc = 0; |
@@ -51,6 +51,12 @@ static int format_ext4(char *fs_blkdev, char *fs_mnt_point) | ||
51 | 51 | reset_ext4fs_info(); |
52 | 52 | info.len = ((off64_t)nr_sec * 512); |
53 | 53 | |
54 | + if (fs_length > 0) { | |
55 | + info.len = fs_length; | |
56 | + } else if (fs_length < 0) { | |
57 | + info.len += fs_length; | |
58 | + } | |
59 | + | |
54 | 60 | /* Use make_ext4fs_internal to avoid wiping an already-wiped partition. */ |
55 | 61 | rc = make_ext4fs_internal(fd, NULL, NULL, fs_mnt_point, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL); |
56 | 62 | if (rc) { |
@@ -110,7 +116,7 @@ int fs_mgr_do_format(struct fstab_rec *fstab) | ||
110 | 116 | if (!strncmp(fstab->fs_type, "f2fs", 4)) { |
111 | 117 | rc = format_f2fs(fstab->blk_device); |
112 | 118 | } else if (!strncmp(fstab->fs_type, "ext4", 4)) { |
113 | - rc = format_ext4(fstab->blk_device, fstab->mount_point); | |
119 | + rc = format_ext4(fstab->blk_device, fstab->mount_point, fstab->length); | |
114 | 120 | } else { |
115 | 121 | ERROR("File system type '%s' is not supported\n", fstab->fs_type); |
116 | 122 | } |