[PATCH 1/3] mmc-utils: Add -c option for partitioning commands

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Adding 'continue' option to:
gp create
enh_area set
write_reliability set

Partitioning commands are connected, register PARTITION_SETTING_COMPLETED
should not be written until all settings have been done.
The continue option enables writing more than one partitioning setting before
sealing settings.

Signed-off-by: Tomas Melin<tomas.melin@xxxxxxxxxxx>
---
 mmc_cmds.c | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/mmc_cmds.c b/mmc_cmds.c
index ef3a50f..5f2b2b5 100644
--- a/mmc_cmds.c
+++ b/mmc_cmds.c
@@ -813,12 +813,16 @@ int set_partitioning_setting_completed(int dry_run, const char * const device,
 {
     int ret;
 
-    if (dry_run) {
+    if (dry_run == 1) {
         fprintf(stderr, "NOT setting PARTITION_SETTING_COMPLETED\n");
         fprintf(stderr, "These changes will not take effect neither "
             "now nor after a power cycle\n");
         return 1;
-    }
+    } else if (dry_run == 2) {
+                printf("-c given, expecting more partition settings before "
+                       "writing PARTITION_SETTING_COMPLETED\n");
+                return 0;
+        }
 
     fprintf(stderr, "setting OTP PARTITION_SETTING_COMPLETED!\n");
     ret = write_extcsd_value(fd, EXT_CSD_PARTITION_SETTING_COMPLETED, 0x1);
@@ -958,11 +962,13 @@ int do_create_gp_partition(int nargs, char **argv)
     unsigned int length_kib, gp_size_mult;
     unsigned long align;
 
-    CHECK(nargs != 7, "Usage: mmc gp create <-y|-n> <length KiB> "
+    CHECK(nargs != 7, "Usage: mmc gp create <-y|-n|-c> <length KiB> "
         "<partition> <enh_attr> <ext_attr> </path/to/mmcblkX>\n", exit(1));
 
     if (!strcmp("-y", argv[1]))
         dry_run = 0;
+        if (!strcmp("-c", argv[1]))
+                dry_run = 2;
 
     length_kib = strtol(argv[2], NULL, 10);
     partition = strtol(argv[3], NULL, 10);
@@ -1081,11 +1087,13 @@ int do_enh_area_set(int nargs, char **argv)
     unsigned int start_kib, length_kib, enh_start_addr, enh_size_mult;
     unsigned long align;
 
-    CHECK(nargs != 5, "Usage: mmc enh_area set <-y|-n> <start KiB> <length KiB> "
+    CHECK(nargs != 5, "Usage: mmc enh_area set <-y|-n|-c> <start KiB> <length KiB> "
               "</path/to/mmcblkX>\n", exit(1));
 
     if (!strcmp("-y", argv[1]))
         dry_run = 0;
+        if (!strcmp("-c", argv[1]))
+                dry_run = 2;
 
     start_kib = strtol(argv[2], NULL, 10);
     length_kib = strtol(argv[3], NULL, 10);
@@ -1223,11 +1231,13 @@ int do_write_reliability_set(int nargs, char **argv)
     int partition;
     char *device;
 
-    CHECK(nargs != 4, "Usage: mmc write_reliability set <-y|-n> "
+    CHECK(nargs != 4, "Usage: mmc write_reliability set <-y|-n|-c> "
             "<partition> </path/to/mmcblkX>\n", exit(1));
 
     if (!strcmp("-y", argv[1]))
         dry_run = 0;
+        if (!strcmp("-c", argv[1]))
+                dry_run = 2;
 
     partition = strtol(argv[2], NULL, 10);
     device = argv[3];
-- 
2.1.4
��.n��������+%������w��{.n�����{��i��)��jg��������ݢj����G�������j:+v���w�m������w�������h�����٥




[Index of Archives]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux