]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
Merge branch 'mount-nosymfollow' of https://github.com/jwilk-forks/util-linux
authorKarel Zak <kzak@redhat.com>
Fri, 28 Jan 2022 08:26:39 +0000 (09:26 +0100)
committerKarel Zak <kzak@redhat.com>
Fri, 28 Jan 2022 08:26:39 +0000 (09:26 +0100)
* 'mount-nosymfollow' of https://github.com/jwilk-forks/util-linux:
  mount: Allow bind-mounting with "nosymfollow"

13 files changed:
libfdisk/src/gpt.c
tests/expected/fdisk/gpt-resize
tests/expected/libfdisk/gpt-all-defaults
tests/expected/libfdisk/gpt-all-defaults-with-typo
tests/expected/libfdisk/mkpart-gpt
tests/expected/sfdisk/gpt-all-defaults
tests/expected/sfdisk/gpt-attrs
tests/expected/sfdisk/gpt-attrs-guid
tests/expected/sfdisk/gpt-attrs-space
tests/expected/sfdisk/gpt-attrs-with-typo
tests/expected/sfdisk/wipe-gpt-to-dos
tests/expected/sfdisk/wipe-gpt-to-dos-auto
tests/expected/sfdisk/wipe-partition

index 3d8b264d2ac34881be4a9dd77d2f1d08868b93cf..72370a19a7b8093bf654724000d59bda3f5efb11 100644 (file)
@@ -2297,7 +2297,7 @@ static int gpt_verify_disklabel(struct fdisk_context *cxt)
                           P_("A total of %ju free sectors is available in %u segment.",
                              "A total of %ju free sectors is available in %u segments "
                              "(the largest is %s).", nsegments),
-                          free_sectors, nsegments, strsz);
+                          free_sectors, nsegments, strsz ? : "0 B");
                free(strsz);
 
        } else
@@ -2346,7 +2346,7 @@ static int gpt_add_partition(
 {
        uint64_t user_f, user_l;        /* user input ranges for first and last sectors */
        uint64_t disk_f, disk_l;        /* first and last available sector ranges on device*/
-       uint64_t dflt_f, dflt_l;        /* largest segment (default) */
+       uint64_t dflt_f, dflt_l, max_l; /* largest segment (default) */
        struct gpt_guid typeid;
        struct fdisk_gpt_label *gpt;
        struct gpt_header *pheader;
@@ -2428,6 +2428,14 @@ static int gpt_add_partition(
        dflt_f = find_first_in_largest(gpt);
        dflt_l = find_last_free(gpt, dflt_f);
 
+       /* don't offer too small free space by default, this is possible to
+        * bypass by sfdisk script */
+       if ((!pa || !fdisk_partition_has_start(pa))
+           && dflt_l - dflt_f + 1 < cxt->grain / cxt->sector_size) {
+               fdisk_warnx(cxt, _("No enough free sectors available."));
+               return -ENOSPC;
+       }
+
        /* align the default in range <dflt_f,dflt_l>*/
        dflt_f = fdisk_align_lba_in_range(cxt, dflt_f, dflt_f, dflt_l);
 
@@ -2474,15 +2482,23 @@ static int gpt_add_partition(
 
 
        /* Last sector */
-       dflt_l = find_last_free(gpt, user_f);
+       dflt_l = max_l = find_last_free(gpt, user_f);
+
+       /* Make sure the last partition has aligned size by default because
+        * range specified by LastUsableLBA may be unaligned on disks where
+        * logical sector != physical (512/4K) because backup header size is
+        * calculated from logical sectors. */
+       if (max_l == le64_to_cpu(gpt->pheader->last_usable_lba))
+               dflt_l = fdisk_align_lba_in_range(cxt, max_l, user_f, max_l) - 1;
 
        if (pa && pa->end_follow_default) {
                user_l = dflt_l;
 
        } else if (pa && fdisk_partition_has_size(pa)) {
                user_l = user_f + pa->size - 1;
-               DBG(GPT, ul_debug("size defined: %ju, end: %"PRIu64" (last possible: %"PRIu64")",
-                                        (uintmax_t)pa->size, user_l, dflt_l));
+               DBG(GPT, ul_debug("size defined: %ju, end: %"PRIu64
+                                 "(last possible: %"PRIu64", optimal: %"PRIu64")",
+                               (uintmax_t)pa->size, user_l, max_l, dflt_l));
 
                if (user_l != dflt_l
                    && !pa->size_explicit
@@ -2506,7 +2522,7 @@ static int gpt_add_partition(
                        fdisk_ask_set_type(ask, FDISK_ASKTYPE_OFFSET);
                        fdisk_ask_number_set_low(ask,     user_f);      /* minimal */
                        fdisk_ask_number_set_default(ask, dflt_l);      /* default */
-                       fdisk_ask_number_set_high(ask,    dflt_l);      /* maximal */
+                       fdisk_ask_number_set_high(ask,    max_l);       /* maximal */
                        fdisk_ask_number_set_base(ask,    user_f);      /* base for relative input */
                        fdisk_ask_number_set_unit(ask,    cxt->sector_size);
                        fdisk_ask_number_set_wrap_negative(ask, 1);     /* wrap negative around high */
index 64b6c431d9a64251c2f0692975ee56d0ab89069f..d6a331a7f54a386e4f329579c28b5e7544630073 100644 (file)
@@ -12,7 +12,7 @@ Disklabel type: gpt
 Disk identifier: <removed>
 
 Device             Start   End Sectors Size Type
-<removed>p1  2048 20446   18399   9M Linux filesystem
+<removed>p1  2048 18431   16384   8M Linux filesystem
 
 The partition table has been altered.
 ----- fixing after resize: -----
@@ -22,7 +22,7 @@ Changes will remain in memory only, until you decide to write them.
 Be careful before using the write command.
 
 
-Command (m for help): Partition number (2-128, default 2): First sector (20447-40926, default 20480): Last sector, +/-sectors or +/-size{K,M,G,T,P} (20480-40926, default 40926): 
+Command (m for help): Partition number (2-128, default 2): First sector (18432-40926, default 18432): Last sector, +/-sectors or +/-size{K,M,G,T,P} (18432-40926, default 38911): 
 Created a new partition <removed>.
 
 Command (m for help): The partition table has been altered.
@@ -39,5 +39,5 @@ Disklabel type: gpt
 Disk identifier: <removed>
 
 Device             Start   End Sectors Size Type
-<removed>p1  2048 20446   18399   9M Linux filesystem
-<removed>p2 20480 40926   20447  10M Linux filesystem
+<removed>p1  2048 18431   16384   8M Linux filesystem
+<removed>p2 18432 38911   20480  10M Linux filesystem
index 6351f25de7136992ba6ed703fbc03735f91fd7f8..218338a8f89a880666707204a47db8ca671b1c7a 100644 (file)
@@ -18,7 +18,7 @@ Disk identifier: <removed>
 
 Device             Start   End Sectors Size Type
 <removed>1  2048 12287   10240   5M Linux filesystem
-<removed>2 12288 20446    8159   4M Linux filesystem
+<removed>2 12288 18431    6144   3M Linux filesystem
 
 The partition table has been altered.
 Syncing disks.
index 6351f25de7136992ba6ed703fbc03735f91fd7f8..218338a8f89a880666707204a47db8ca671b1c7a 100644 (file)
@@ -18,7 +18,7 @@ Disk identifier: <removed>
 
 Device             Start   End Sectors Size Type
 <removed>1  2048 12287   10240   5M Linux filesystem
-<removed>2 12288 20446    8159   4M Linux filesystem
+<removed>2 12288 18431    6144   3M Linux filesystem
 
 The partition table has been altered.
 Syncing disks.
index fab28b1ce6ba4a8b48f1e8062d530aa4e587ae53..1c39f6a45a4373e635cb42a337ab01b3e9ce4970 100644 (file)
@@ -20,4 +20,4 @@ Device             Start   End Sectors Size Type
 <removed>4  8192 10239    2048   1M Linux filesystem
 <removed>5 10240 12287    2048   1M Linux filesystem
 <removed>6 12288 14335    2048   1M Linux filesystem
-<removed>7 14336 30686   16351   8M Linux filesystem
+<removed>7 14336 28671   14336   7M Linux filesystem
index 55eb256a9e7be6223cf841fccfbf0986fcb3565b..66868ed48059e0cbd2e2e157f2d1ab6bcc36ffa3 100644 (file)
@@ -25,7 +25,7 @@ Device             Start    End Sectors Size Type
 <removed>2  12288  22527   10240   5M Linux filesystem
 <removed>3  22528  32767   10240   5M Linux swap
 <removed>4  32768  43007   10240   5M Linux root (x86-64)
-<removed>5  43008 102366   59359  29M Linux filesystem
+<removed>5  43008 100351   57344  28M Linux filesystem
 
 The partition table has been altered.
 Calling ioctl() to re-read partition table.
index 0194320b47917d79949d48de4ed572205025a374..7cbfee435c7b25e403d859e3e97031bd5bc2a144 100644 (file)
@@ -21,11 +21,11 @@ PMBR: offset = 0, size = 512 bytes.
 
 GPT Header: offset = 512, size = 512 bytes.
 00000200  45 46 49 20 50 41 52 54  00 00 01 00 5c 00 00 00
-00000210  cc 5a ce cf 00 00 00 00  01 00 00 00 00 00 00 00
+00000210  9b 58 15 32 00 00 00 00  01 00 00 00 00 00 00 00
 00000220  ff 8f 01 00 00 00 00 00  00 08 00 00 00 00 00 00
 00000230  de 8f 01 00 00 00 00 00  99 c3 81 b1 11 47 52 4c
 00000240  8b 65 9e 76 45 41 21 8d  02 00 00 00 00 00 00 00
-00000250  80 00 00 00 80 00 00 00  9f 91 62 10 00 00 00 00
+00000250  80 00 00 00 80 00 00 00  25 86 e1 c0 00 00 00 00
 00000260  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
 *
 
@@ -55,7 +55,7 @@ GPT Entries: offset = 1024, size = 16384 bytes.
 *
 00000600  af 3d c6 0f 83 84 72 47  8e 79 3d 69 d8 47 7d e4
 00000610  d7 5b 15 60 d8 bf 8c 4e  b8 00 22 19 00 77 93 73
-00000620  00 a8 00 00 00 00 00 00  de 8f 01 00 00 00 00 00
+00000620  00 a8 00 00 00 00 00 00  ff 87 01 00 00 00 00 00
 00000630  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
 *
 
@@ -85,17 +85,17 @@ GPT Backup Entries: offset = 52411904, size = 16384 bytes.
 *
 031fc000  af 3d c6 0f 83 84 72 47  8e 79 3d 69 d8 47 7d e4
 031fc010  d7 5b 15 60 d8 bf 8c 4e  b8 00 22 19 00 77 93 73
-031fc020  00 a8 00 00 00 00 00 00  de 8f 01 00 00 00 00 00
+031fc020  00 a8 00 00 00 00 00 00  ff 87 01 00 00 00 00 00
 031fc030  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
 *
 
 GPT Backup Header: offset = 52428288, size = 512 bytes.
 031ffe00  45 46 49 20 50 41 52 54  00 00 01 00 5c 00 00 00
-031ffe10  75 e0 4c 4f 00 00 00 00  ff 8f 01 00 00 00 00 00
+031ffe10  22 e2 97 b2 00 00 00 00  ff 8f 01 00 00 00 00 00
 031ffe20  01 00 00 00 00 00 00 00  00 08 00 00 00 00 00 00
 031ffe30  de 8f 01 00 00 00 00 00  99 c3 81 b1 11 47 52 4c
 031ffe40  8b 65 9e 76 45 41 21 8d  df 8f 01 00 00 00 00 00
-031ffe50  80 00 00 00 80 00 00 00  9f 91 62 10 00 00 00 00
+031ffe50  80 00 00 00 80 00 00 00  25 86 e1 c0 00 00 00 00
 031ffe60  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
 *
 
index a2e1e601012a38cec0c7609fbd4ac457bea16413..9797b49425c4a29f761e5403fde4a2a22d89bbc3 100644 (file)
@@ -21,11 +21,11 @@ PMBR: offset = 0, size = 512 bytes.
 
 GPT Header: offset = 512, size = 512 bytes.
 00000200  45 46 49 20 50 41 52 54  00 00 01 00 5c 00 00 00
-00000210  0d a5 4b da 00 00 00 00  01 00 00 00 00 00 00 00
+00000210  5a a7 90 27 00 00 00 00  01 00 00 00 00 00 00 00
 00000220  ff 8f 01 00 00 00 00 00  00 08 00 00 00 00 00 00
 00000230  de 8f 01 00 00 00 00 00  99 c3 81 b1 11 47 52 4c
 00000240  8b 65 9e 76 45 41 21 8d  02 00 00 00 00 00 00 00
-00000250  80 00 00 00 80 00 00 00  15 4e df fa 00 00 00 00
+00000250  80 00 00 00 80 00 00 00  af 59 5c 2a 00 00 00 00
 00000260  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
 *
 
@@ -55,7 +55,7 @@ GPT Entries: offset = 1024, size = 16384 bytes.
 *
 00000600  af 3d c6 0f 83 84 72 47  8e 79 3d 69 d8 47 7d e4
 00000610  d7 5b 15 60 d8 bf 8c 4e  b8 00 22 19 00 77 93 73
-00000620  00 a8 00 00 00 00 00 00  de 8f 01 00 00 00 00 00
+00000620  00 a8 00 00 00 00 00 00  ff 87 01 00 00 00 00 00
 00000630  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
 *
 
@@ -85,17 +85,17 @@ GPT Backup Entries: offset = 52411904, size = 16384 bytes.
 *
 031fc000  af 3d c6 0f 83 84 72 47  8e 79 3d 69 d8 47 7d e4
 031fc010  d7 5b 15 60 d8 bf 8c 4e  b8 00 22 19 00 77 93 73
-031fc020  00 a8 00 00 00 00 00 00  de 8f 01 00 00 00 00 00
+031fc020  00 a8 00 00 00 00 00 00  ff 87 01 00 00 00 00 00
 031fc030  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
 *
 
 GPT Backup Header: offset = 52428288, size = 512 bytes.
 031ffe00  45 46 49 20 50 41 52 54  00 00 01 00 5c 00 00 00
-031ffe10  b4 1f c9 5a 00 00 00 00  ff 8f 01 00 00 00 00 00
+031ffe10  e3 1d 12 a7 00 00 00 00  ff 8f 01 00 00 00 00 00
 031ffe20  01 00 00 00 00 00 00 00  00 08 00 00 00 00 00 00
 031ffe30  de 8f 01 00 00 00 00 00  99 c3 81 b1 11 47 52 4c
 031ffe40  8b 65 9e 76 45 41 21 8d  df 8f 01 00 00 00 00 00
-031ffe50  80 00 00 00 80 00 00 00  15 4e df fa 00 00 00 00
+031ffe50  80 00 00 00 80 00 00 00  af 59 5c 2a 00 00 00 00
 031ffe60  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
 *
 
index 0194320b47917d79949d48de4ed572205025a374..7cbfee435c7b25e403d859e3e97031bd5bc2a144 100644 (file)
@@ -21,11 +21,11 @@ PMBR: offset = 0, size = 512 bytes.
 
 GPT Header: offset = 512, size = 512 bytes.
 00000200  45 46 49 20 50 41 52 54  00 00 01 00 5c 00 00 00
-00000210  cc 5a ce cf 00 00 00 00  01 00 00 00 00 00 00 00
+00000210  9b 58 15 32 00 00 00 00  01 00 00 00 00 00 00 00
 00000220  ff 8f 01 00 00 00 00 00  00 08 00 00 00 00 00 00
 00000230  de 8f 01 00 00 00 00 00  99 c3 81 b1 11 47 52 4c
 00000240  8b 65 9e 76 45 41 21 8d  02 00 00 00 00 00 00 00
-00000250  80 00 00 00 80 00 00 00  9f 91 62 10 00 00 00 00
+00000250  80 00 00 00 80 00 00 00  25 86 e1 c0 00 00 00 00
 00000260  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
 *
 
@@ -55,7 +55,7 @@ GPT Entries: offset = 1024, size = 16384 bytes.
 *
 00000600  af 3d c6 0f 83 84 72 47  8e 79 3d 69 d8 47 7d e4
 00000610  d7 5b 15 60 d8 bf 8c 4e  b8 00 22 19 00 77 93 73
-00000620  00 a8 00 00 00 00 00 00  de 8f 01 00 00 00 00 00
+00000620  00 a8 00 00 00 00 00 00  ff 87 01 00 00 00 00 00
 00000630  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
 *
 
@@ -85,17 +85,17 @@ GPT Backup Entries: offset = 52411904, size = 16384 bytes.
 *
 031fc000  af 3d c6 0f 83 84 72 47  8e 79 3d 69 d8 47 7d e4
 031fc010  d7 5b 15 60 d8 bf 8c 4e  b8 00 22 19 00 77 93 73
-031fc020  00 a8 00 00 00 00 00 00  de 8f 01 00 00 00 00 00
+031fc020  00 a8 00 00 00 00 00 00  ff 87 01 00 00 00 00 00
 031fc030  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
 *
 
 GPT Backup Header: offset = 52428288, size = 512 bytes.
 031ffe00  45 46 49 20 50 41 52 54  00 00 01 00 5c 00 00 00
-031ffe10  75 e0 4c 4f 00 00 00 00  ff 8f 01 00 00 00 00 00
+031ffe10  22 e2 97 b2 00 00 00 00  ff 8f 01 00 00 00 00 00
 031ffe20  01 00 00 00 00 00 00 00  00 08 00 00 00 00 00 00
 031ffe30  de 8f 01 00 00 00 00 00  99 c3 81 b1 11 47 52 4c
 031ffe40  8b 65 9e 76 45 41 21 8d  df 8f 01 00 00 00 00 00
-031ffe50  80 00 00 00 80 00 00 00  9f 91 62 10 00 00 00 00
+031ffe50  80 00 00 00 80 00 00 00  25 86 e1 c0 00 00 00 00
 031ffe60  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
 *
 
index 0194320b47917d79949d48de4ed572205025a374..7cbfee435c7b25e403d859e3e97031bd5bc2a144 100644 (file)
@@ -21,11 +21,11 @@ PMBR: offset = 0, size = 512 bytes.
 
 GPT Header: offset = 512, size = 512 bytes.
 00000200  45 46 49 20 50 41 52 54  00 00 01 00 5c 00 00 00
-00000210  cc 5a ce cf 00 00 00 00  01 00 00 00 00 00 00 00
+00000210  9b 58 15 32 00 00 00 00  01 00 00 00 00 00 00 00
 00000220  ff 8f 01 00 00 00 00 00  00 08 00 00 00 00 00 00
 00000230  de 8f 01 00 00 00 00 00  99 c3 81 b1 11 47 52 4c
 00000240  8b 65 9e 76 45 41 21 8d  02 00 00 00 00 00 00 00
-00000250  80 00 00 00 80 00 00 00  9f 91 62 10 00 00 00 00
+00000250  80 00 00 00 80 00 00 00  25 86 e1 c0 00 00 00 00
 00000260  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
 *
 
@@ -55,7 +55,7 @@ GPT Entries: offset = 1024, size = 16384 bytes.
 *
 00000600  af 3d c6 0f 83 84 72 47  8e 79 3d 69 d8 47 7d e4
 00000610  d7 5b 15 60 d8 bf 8c 4e  b8 00 22 19 00 77 93 73
-00000620  00 a8 00 00 00 00 00 00  de 8f 01 00 00 00 00 00
+00000620  00 a8 00 00 00 00 00 00  ff 87 01 00 00 00 00 00
 00000630  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
 *
 
@@ -85,17 +85,17 @@ GPT Backup Entries: offset = 52411904, size = 16384 bytes.
 *
 031fc000  af 3d c6 0f 83 84 72 47  8e 79 3d 69 d8 47 7d e4
 031fc010  d7 5b 15 60 d8 bf 8c 4e  b8 00 22 19 00 77 93 73
-031fc020  00 a8 00 00 00 00 00 00  de 8f 01 00 00 00 00 00
+031fc020  00 a8 00 00 00 00 00 00  ff 87 01 00 00 00 00 00
 031fc030  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
 *
 
 GPT Backup Header: offset = 52428288, size = 512 bytes.
 031ffe00  45 46 49 20 50 41 52 54  00 00 01 00 5c 00 00 00
-031ffe10  75 e0 4c 4f 00 00 00 00  ff 8f 01 00 00 00 00 00
+031ffe10  22 e2 97 b2 00 00 00 00  ff 8f 01 00 00 00 00 00
 031ffe20  01 00 00 00 00 00 00 00  00 08 00 00 00 00 00 00
 031ffe30  de 8f 01 00 00 00 00 00  99 c3 81 b1 11 47 52 4c
 031ffe40  8b 65 9e 76 45 41 21 8d  df 8f 01 00 00 00 00 00
-031ffe50  80 00 00 00 80 00 00 00  9f 91 62 10 00 00 00 00
+031ffe50  80 00 00 00 80 00 00 00  25 86 e1 c0 00 00 00 00
 031ffe60  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
 *
 
index de7cd6298d552f1f0a939d895f43361f00fa8676..8b9b130a8e420709ae5041321522ef354cd22009 100644 (file)
@@ -15,7 +15,7 @@ Disklabel type: gpt
 Disk identifier: <removed>
 
 Device             Start    End Sectors Size Type
-<removed>1   2048 102366  100319  49M Linux filesystem
+<removed>1   2048 100351   98304  48M Linux filesystem
 
 The partition table has been altered.
 
@@ -31,7 +31,7 @@ Disk identifier: <removed>
 Old situation:
 
 Device             Start    End Sectors Size Type
-<removed>1   2048 102366  100319  49M Linux filesystem
+<removed>1   2048 100351   98304  48M Linux filesystem
 
 >>> Created a new disklabel.
 <removed>1: Created a new partition <removed>.
index d6c075fff7ffe761964471bc270afcf253bdb2e6..2047a6173463e6bc3a5cdecc5fdfe57c1fc813aa 100644 (file)
@@ -22,7 +22,7 @@ Disklabel type: gpt
 Disk identifier: <removed>
 
 Device             Start    End Sectors Size Type
-<removed>1   2048 102366  100319  49M Linux filesystem
+<removed>1   2048 100351   98304  48M Linux filesystem
 
 The partition table has been altered.
 
@@ -38,7 +38,7 @@ Disk identifier: <removed>
 Old situation:
 
 Device             Start    End Sectors Size Type
-<removed>1   2048 102366  100319  49M Linux filesystem
+<removed>1   2048 100351   98304  48M Linux filesystem
 
 >>> Created a new disklabel.
 <removed>1: Created a new partition <removed>.
index dc5e5fceab7d65a2da071b419fdc5a300585192a..765a22ee2867ec9c35158e762ff73fd3f43702a2 100644 (file)
@@ -15,7 +15,7 @@ Disklabel type: gpt
 Disk identifier: <removed>
 
 Device             Start    End Sectors Size Type
-<removed>1   2048 102366  100319  49M Linux filesystem
+<removed>1   2048 100351   98304  48M Linux filesystem
 
 The partition table has been altered.
 Calling ioctl() to re-read partition table.
@@ -42,7 +42,7 @@ Disklabel type: gpt
 Disk identifier: <removed>
 
 Device             Start    End Sectors Size Type
-<removed>1   2048 102366  100319  49M Linux filesystem
+<removed>1   2048 100351   98304  48M Linux filesystem
 
 Filesystem/RAID signature on partition 1 will be wiped.