• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

system/corennnnn


Commit MetaInfo

Revisionc7829b52c917be7c9522b17ad72eaf9cd5c11fcf (tree)
Time2016-09-04 08:46:00
AuthorKeith Mok <kmok@cyng...>
CommiterSteve Kondik

Log Message

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

Change Summary

Incremental Difference

--- a/fs_mgr/fs_mgr_format.c
+++ b/fs_mgr/fs_mgr_format.c
@@ -67,15 +67,27 @@ static int format_ext4(char *fs_blkdev, char *fs_mnt_point, long long fs_length)
6767 return rc;
6868 }
6969
70-static int format_f2fs(char *fs_blkdev)
70+static int format_f2fs(char *fs_blkdev, long long fs_length)
7171 {
72- char * args[3];
72+ char * args[5];
7373 int pid;
7474 int rc = 0;
75+ char buff[65];
7576
7677 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+ }
7991
8092 pid = fork();
8193 if (pid < 0) {
@@ -114,7 +126,7 @@ int fs_mgr_do_format(struct fstab_rec *fstab)
114126 ERROR("%s: Format %s as '%s'.\n", __func__, fstab->blk_device, fstab->fs_type);
115127
116128 if (!strncmp(fstab->fs_type, "f2fs", 4)) {
117- rc = format_f2fs(fstab->blk_device);
129+ rc = format_f2fs(fstab->blk_device, fstab->length);
118130 } else if (!strncmp(fstab->fs_type, "ext4", 4)) {
119131 rc = format_ext4(fstab->blk_device, fstab->mount_point, fstab->length);
120132 } else {