2 * partx: tell the kernel about your disk's partitions
3 * [This is not an fdisk - adding and removing partitions
4 * is not a change of the disk, but just telling the kernel
5 * about presence and numbering of on-disk partitions.]
7 * aeb, 2000-03-21 -- sah is 42 now
9 * Copyright (C) 2010 Davidlohr Bueso <dave@gnu.org>
10 * Rewritten to use libblkid for util-linux
11 * based on ideas from Karel Zak <kzak@redhat.com>
22 #include <sys/sysmacros.h>
25 #include <libsmartcols.h>
28 #include "pathnames.h"
36 #include "closestream.h"
39 /* this is the default upper limit, could be modified by --nr */
40 #define SLICES_MAX 256
42 /* basic table settings */
45 PARTX_NOHEADINGS
= (1 << 1),
46 PARTX_EXPORT
= (1 << 2),
49 /* all the columns (-o option) */
63 #define ACT_ERROR "--{add,delete,show,list,raw,pairs}"
79 const char *name
; /* header */
80 double whint
; /* width hint (N < 1 is in percent of termwidth) */
81 int flags
; /* SCOLS_FL_* */
85 /* columns descriptions */
86 struct colinfo infos
[] = {
87 [COL_PARTNO
] = { "NR", 0.25, SCOLS_FL_RIGHT
, N_("partition number") },
88 [COL_START
] = { "START", 0.30, SCOLS_FL_RIGHT
, N_("start of the partition in sectors") },
89 [COL_END
] = { "END", 0.30, SCOLS_FL_RIGHT
, N_("end of the partition in sectors") },
90 [COL_SECTORS
] = { "SECTORS", 0.30, SCOLS_FL_RIGHT
, N_("number of sectors") },
91 [COL_SIZE
] = { "SIZE", 0.30, SCOLS_FL_RIGHT
, N_("human readable size") },
92 [COL_NAME
] = { "NAME", 0.30, SCOLS_FL_TRUNC
, N_("partition name") },
93 [COL_UUID
] = { "UUID", 36, 0, N_("partition UUID")},
94 [COL_SCHEME
] = { "SCHEME", 0.1, SCOLS_FL_TRUNC
, N_("partition table type (dos, gpt, ...)")},
95 [COL_FLAGS
] = { "FLAGS", 0.1, SCOLS_FL_TRUNC
, N_("partition flags")},
96 [COL_TYPE
] = { "TYPE", 1, SCOLS_FL_RIGHT
, N_("partition type (a string, a UUID, or hex)")},
99 #define NCOLS ARRAY_SIZE(infos)
101 /* array with IDs of enabled columns */
102 static int columns
[NCOLS
];
106 static int partx_flags
;
107 static struct loopdev_cxt lc
;
110 static void assoc_loopdev(const char *fname
)
114 if (loopcxt_init(&lc
, 0))
115 err(EXIT_FAILURE
, _("failed to initialize loopcxt"));
117 rc
= loopcxt_find_unused(&lc
);
119 err(EXIT_FAILURE
, _("%s: failed to find unused loop device"),
123 printf(_("Trying to use '%s' for the loop device\n"),
124 loopcxt_get_device(&lc
));
126 if (loopcxt_set_backing_file(&lc
, fname
))
127 err(EXIT_FAILURE
, _("%s: failed to set backing file"), fname
);
129 rc
= loopcxt_setup_device(&lc
);
132 err(EXIT_FAILURE
, _("%s: failed to set up loop device"), fname
);
137 static inline int get_column_id(int num
)
139 assert(ARRAY_SIZE(columns
) == NCOLS
);
140 assert((size_t)num
< ncolumns
);
141 assert(columns
[num
] < (int) NCOLS
);
145 static inline struct colinfo
*get_column_info(int num
)
147 return &infos
[ get_column_id(num
) ];
150 static int column_name_to_id(const char *name
, size_t namesz
)
156 for (i
= 0; i
< NCOLS
; i
++) {
157 const char *cn
= infos
[i
].name
;
159 if (!strncasecmp(name
, cn
, namesz
) && !*(cn
+ namesz
))
162 warnx(_("unknown column: %s"), name
);
167 * Given a partition return the corresponding partition number.
169 * Note that this function tries to use sysfs, otherwise it assumes that the
170 * last characters are always numeric (sda1, sdc20, etc).
172 static int get_partno_from_device(char *partition
, dev_t devno
)
176 char *p
, *end
= NULL
;
181 struct sysfs_cxt cxt
;
184 if (sysfs_init(&cxt
, devno
, NULL
))
187 rc
= sysfs_read_int(&cxt
, "partition", &partno
);
194 sz
= strlen(partition
);
195 p
= partition
+ sz
- 1;
197 if (!isdigit((unsigned int) *p
))
200 while (isdigit((unsigned int) *(p
- 1))) p
--;
203 partno
= strtol(p
, &end
, 10);
204 if (errno
|| !end
|| *end
|| p
== end
)
209 errx(EXIT_FAILURE
, _("%s: failed to get partition number"), partition
);
212 static int get_max_partno(const char *disk
, dev_t devno
)
214 char path
[PATH_MAX
], *parent
, *dirname
= NULL
;
220 if (!devno
&& !stat(disk
, &st
))
224 parent
= strrchr(disk
, '/');
229 snprintf(path
, sizeof(path
), _PATH_SYS_DEVBLOCK
"/%d:%d/",
230 major(devno
), minor(devno
));
236 dirname
= xstrdup(path
);
238 while ((d
= readdir(dir
))) {
241 if (!strcmp(d
->d_name
, ".") ||
242 !strcmp(d
->d_name
, ".."))
244 #ifdef _DIRENT_HAVE_D_TYPE
245 if (d
->d_type
!= DT_DIR
&& d
->d_type
!= DT_UNKNOWN
)
248 if (strncmp(parent
, d
->d_name
, strlen(parent
)))
250 snprintf(path
, sizeof(path
), "%s/partition", d
->d_name
);
252 fd
= openat(dirfd(dir
), path
, O_RDONLY
);
255 FILE *f
= fdopen(fd
, "r");
257 if (fscanf(f
, "%d", &x
) == 1 && x
> partno
)
271 static void del_parts_warnx(const char *device
, int first
, int last
)
274 warnx(_("%s: error deleting partition %d"), device
, first
);
276 warnx(_("%s: error deleting partitions %d-%d"),
277 device
, first
, last
);
280 static int del_parts(int fd
, const char *device
, dev_t devno
,
281 int lower
, int upper
)
283 int rc
= 0, i
, errfirst
= 0, errlast
= 0;
290 if (!upper
|| lower
< 0 || upper
< 0) {
291 int n
= get_max_partno(device
, devno
);
295 upper
= n
+ upper
+ 1;
297 lower
= n
+ lower
+ 1;
300 warnx(_("specified range <%d:%d> "
301 "does not make sense"), lower
, upper
);
305 for (i
= lower
; i
<= upper
; i
++) {
306 rc
= partx_del_partition(fd
, i
);
309 printf(_("%s: partition #%d removed\n"), device
, i
);
311 } else if (errno
== ENXIO
) {
313 printf(_("%s: partition #%d doesn't exist\n"), device
, i
);
318 warn(_("%s: deleting partition #%d failed"), device
, i
);
320 errlast
= errfirst
= i
;
321 else if (errlast
+ 1 == i
)
324 del_parts_warnx(device
, errfirst
, errlast
);
325 errlast
= errfirst
= i
;
330 del_parts_warnx(device
, errfirst
, errlast
);
335 static void add_parts_warnx(const char *device
, int first
, int last
)
338 warnx(_("%s: error adding partition %d"), device
, first
);
340 warnx(_("%s: error adding partitions %d-%d"),
341 device
, first
, last
);
344 static int add_parts(int fd
, const char *device
,
345 blkid_partlist ls
, int lower
, int upper
)
347 int i
, nparts
, rc
= 0, errfirst
= 0, errlast
= 0;
353 nparts
= blkid_partlist_numof_partitions(ls
);
355 for (i
= 0; i
< nparts
; i
++) {
356 blkid_partition par
= blkid_partlist_get_partition(ls
, i
);
357 int n
= blkid_partition_get_partno(par
);
358 uintmax_t start
, size
;
360 if (lower
&& n
< lower
)
362 if (upper
&& n
> upper
)
365 start
= blkid_partition_get_start(par
);
366 size
= blkid_partition_get_size(par
);
368 if (blkid_partition_is_extended(par
))
370 * Let's follow the Linux kernel and reduce
371 * DOS extended partition to 1 or 2 sectors.
373 size
= min(size
, (uintmax_t) 2);
375 if (partx_add_partition(fd
, n
, start
, size
) == 0) {
377 printf(_("%s: partition #%d added\n"), device
, n
);
382 warn(_("%s: adding partition #%d failed"), device
, n
);
384 errlast
= errfirst
= n
;
385 else if (errlast
+ 1 == n
)
388 add_parts_warnx(device
, errfirst
, errlast
);
389 errlast
= errfirst
= n
;
394 add_parts_warnx(device
, errfirst
, errlast
);
397 * The kernel with enabled partitions scanner for loop devices add *all*
398 * partitions, so we should delete any extra, unwanted ones, when the -n
401 if (loopdev
&& loopcxt_is_partscan(&lc
) && (lower
|| upper
)) {
402 for (i
= 0; i
< nparts
; i
++) {
403 blkid_partition par
= blkid_partlist_get_partition(ls
, i
);
404 int n
= blkid_partition_get_partno(par
);
406 if (n
< lower
|| n
> upper
)
407 partx_del_partition(fd
, n
);
414 static void upd_parts_warnx(const char *device
, int first
, int last
)
417 warnx(_("%s: error updating partition %d"), device
, first
);
419 warnx(_("%s: error updating partitions %d-%d"),
420 device
, first
, last
);
423 static int upd_parts(int fd
, const char *device
, dev_t devno
,
424 blkid_partlist ls
, int lower
, int upper
)
426 int n
, nparts
, rc
= 0, errfirst
= 0, errlast
= 0, err
;
428 uintmax_t start
, size
;
434 nparts
= blkid_partlist_numof_partitions(ls
);
437 if (!upper
|| lower
< 0 || upper
< 0) {
438 n
= get_max_partno(device
, devno
);
440 upper
= n
> nparts
? n
: nparts
;
442 upper
= n
+ upper
+ 1;
444 lower
= n
+ lower
+ 1;
447 warnx(_("specified range <%d:%d> "
448 "does not make sense"), lower
, upper
);
452 for (n
= lower
; n
<= upper
; n
++) {
453 par
= blkid_partlist_get_partition_by_partno(ls
, n
);
456 warn(_("%s: no partition #%d"), device
, n
);
460 start
= blkid_partition_get_start(par
);
461 size
= blkid_partition_get_size(par
);
462 if (blkid_partition_is_extended(par
))
464 * Let's follow the Linux kernel and reduce
465 * DOS extended partition to 1 or 2 sectors.
467 size
= min(size
, (uintmax_t) 2);
469 err
= partx_del_partition(fd
, n
);
470 if (err
== -1 && errno
== ENXIO
)
471 err
= 0; /* good, it already doesn't exist */
472 if (err
== -1 && errno
== EBUSY
)
475 err
= partx_resize_partition(fd
, n
, start
, size
);
477 printf(_("%s: partition #%d resized\n"), device
, n
);
481 if (err
== 0 && partx_add_partition(fd
, n
, start
, size
) == 0) {
483 printf(_("%s: partition #%d added\n"), device
, n
);
491 warn(_("%s: updating partition #%d failed"), device
, n
);
493 errlast
= errfirst
= n
;
494 else if (errlast
+ 1 == n
)
497 upd_parts_warnx(device
, errfirst
, errlast
);
498 errlast
= errfirst
= n
;
503 upd_parts_warnx(device
, errfirst
, errlast
);
507 static int list_parts(blkid_partlist ls
, int lower
, int upper
)
513 nparts
= blkid_partlist_numof_partitions(ls
);
515 for (i
= 0; i
< nparts
; i
++) {
516 blkid_partition par
= blkid_partlist_get_partition(ls
, i
);
517 int n
= blkid_partition_get_partno(par
);
518 uintmax_t start
, size
;
520 if (lower
&& n
< lower
)
522 if (upper
&& n
> upper
)
525 start
= blkid_partition_get_start(par
);
526 size
= blkid_partition_get_size(par
);
528 printf(P_("#%2d: %9ju-%9ju (%9ju sector, %6ju MB)\n",
529 "#%2d: %9ju-%9ju (%9ju sectors, %6ju MB)\n",
531 n
, start
, start
+ size
-1,
532 size
, (size
<< 9) / 1000000);
537 static int add_scols_line(struct libscols_table
*table
, blkid_partition par
)
539 struct libscols_line
*line
;
545 line
= scols_table_new_line(table
, NULL
);
547 warn(_("failed to add line to output"));
551 for (i
= 0; (size_t)i
< ncolumns
; i
++) {
552 char *str
= NULL
; /* allocated string */
553 const char *cstr
= NULL
; /* foreign string */
555 switch (get_column_id(i
)) {
557 xasprintf(&str
, "%d", blkid_partition_get_partno(par
));
560 xasprintf(&str
, "%ju", blkid_partition_get_start(par
));
563 xasprintf(&str
, "%ju",
564 blkid_partition_get_start(par
) +
565 blkid_partition_get_size(par
) - 1);
568 xasprintf(&str
, "%ju", blkid_partition_get_size(par
));
571 if (partx_flags
& FL_BYTES
)
572 xasprintf(&str
, "%ju", (uintmax_t)
573 blkid_partition_get_size(par
) << 9);
575 str
= size_to_human_string(SIZE_SUFFIX_1LETTER
,
576 blkid_partition_get_size(par
) << 9);
579 cstr
= blkid_partition_get_name(par
);
582 cstr
= blkid_partition_get_uuid(par
);
585 if (blkid_partition_get_type_string(par
))
586 cstr
= blkid_partition_get_type_string(par
);
588 xasprintf(&str
, "0x%x",
589 blkid_partition_get_type(par
));
592 xasprintf(&str
, "0x%llx", blkid_partition_get_flags(par
));
596 blkid_parttable tab
= blkid_partition_get_table(par
);
598 cstr
= blkid_parttable_get_type(tab
);
606 rc
= scols_line_set_data(line
, i
, cstr
);
608 rc
= scols_line_refer_data(line
, i
, str
);
610 warn(_("failed to add data to output table"));
618 static int show_parts(blkid_partlist ls
, int scols_flags
, int lower
, int upper
)
621 struct libscols_table
*table
;
626 nparts
= blkid_partlist_numof_partitions(ls
);
631 table
= scols_new_table();
633 warn(_("failed to initialize output table"));
636 scols_table_enable_raw(table
, !!(scols_flags
& PARTX_RAW
));
637 scols_table_enable_export(table
, !!(scols_flags
& PARTX_EXPORT
));
638 scols_table_enable_noheadings(table
, !!(scols_flags
& PARTX_NOHEADINGS
));
640 for (i
= 0; (size_t)i
< ncolumns
; i
++) {
641 struct colinfo
*col
= get_column_info(i
);
643 if (!scols_table_new_column(table
, col
->name
, col
->whint
, col
->flags
)) {
644 warnx(_("failed to initialize output column"));
649 for (i
= 0; i
< nparts
; i
++) {
650 blkid_partition par
= blkid_partlist_get_partition(ls
, i
);
651 int n
= blkid_partition_get_partno(par
);
653 if (lower
&& n
< lower
)
655 if (upper
&& n
> upper
)
658 rc
= add_scols_line(table
, par
);
664 scols_print_table(table
);
666 scols_unref_table(table
);
670 static blkid_partlist
get_partlist(blkid_probe pr
,
671 const char *device
, char *type
)
680 char *name
[] = { type
, NULL
};
682 if (blkid_probe_filter_partitions_type(pr
,
683 BLKID_FLTR_ONLYIN
, name
)) {
684 warnx(_("failed to initialize blkid "
685 "filter for '%s'"), type
);
690 ls
= blkid_probe_get_partitions(pr
);
692 warnx(_("%s: failed to read partition table"), device
);
696 tab
= blkid_partlist_get_table(ls
);
697 if (verbose
&& tab
) {
698 printf(_("%s: partition table type '%s' detected\n"),
699 device
, blkid_parttable_get_type(tab
));
701 if (!blkid_partlist_numof_partitions(ls
))
702 printf(_("%s: partition table with no partitions"), device
);
708 static void __attribute__((__noreturn__
)) usage(FILE *out
)
712 fputs(USAGE_HEADER
, out
);
714 _(" %s [-a|-d|-s|-u] [--nr <n:m> | <partition>] <disk>\n"),
715 program_invocation_short_name
);
717 fputs(USAGE_SEPARATOR
, out
);
718 fputs(_("Tell the kernel about the presence and numbering of partitions.\n"), out
);
720 fputs(USAGE_OPTIONS
, out
);
721 fputs(_(" -a, --add add specified partitions or all of them\n"), out
);
722 fputs(_(" -d, --delete delete specified partitions or all of them\n"), out
);
723 fputs(_(" -u, --update update specified partitions or all of them\n"), out
);
724 fputs(_(" -s, --show list partitions\n\n"), out
);
725 fputs(_(" -b, --bytes print SIZE in bytes rather than in human readable format\n"), out
);
726 fputs(_(" -g, --noheadings don't print headings for --show\n"), out
);
727 fputs(_(" -n, --nr <n:m> specify the range of partitions (e.g. --nr 2:4)\n"), out
);
728 fputs(_(" -o, --output <list> define which output columns to use\n"), out
);
729 fputs(_(" -P, --pairs use key=\"value\" output format\n"), out
);
730 fputs(_(" -r, --raw use raw output format\n"), out
);
731 fputs(_(" -t, --type <type> specify the partition type (dos, bsd, solaris, etc.)\n"), out
);
732 fputs(_(" -v, --verbose verbose mode\n"), out
);
734 fputs(USAGE_SEPARATOR
, out
);
735 fputs(USAGE_HELP
, out
);
736 fputs(USAGE_VERSION
, out
);
738 fputs(_("\nAvailable columns (for --show, --raw or --pairs):\n"), out
);
740 for (i
= 0; i
< NCOLS
; i
++)
741 fprintf(out
, " %10s %s\n", infos
[i
].name
, _(infos
[i
].help
));
743 fprintf(out
, USAGE_MAN_TAIL("partx(8)"));
745 exit(out
== stderr
? EXIT_FAILURE
: EXIT_SUCCESS
);
748 int main(int argc
, char **argv
)
750 int fd
, c
, what
= ACT_NONE
, lower
= 0, upper
= 0, rc
= 0;
753 char *device
= NULL
; /* pointer to argv[], ie: /dev/sda1 */
754 char *wholedisk
= NULL
; /* allocated, ie: /dev/sda */
756 dev_t disk_devno
= 0, part_devno
= 0;
758 static const struct option long_opts
[] = {
759 { "bytes", no_argument
, NULL
, 'b' },
760 { "noheadings", no_argument
, NULL
, 'g' },
761 { "raw", no_argument
, NULL
, 'r' },
762 { "list", no_argument
, NULL
, 'l' },
763 { "show", no_argument
, NULL
, 's' },
764 { "add", no_argument
, NULL
, 'a' },
765 { "delete", no_argument
, NULL
, 'd' },
766 { "update", no_argument
, NULL
, 'u' },
767 { "type", required_argument
, NULL
, 't' },
768 { "nr", required_argument
, NULL
, 'n' },
769 { "output", required_argument
, NULL
, 'o' },
770 { "pairs", no_argument
, NULL
, 'P' },
771 { "help", no_argument
, NULL
, 'h' },
772 { "version", no_argument
, NULL
, 'V' },
773 { "verbose", no_argument
, NULL
, 'v' },
777 static const ul_excl_t excl
[] = { /* rows and cols in in ASCII order */
778 { 'P','a','d','l','r','s','u' },
781 int excl_st
[ARRAY_SIZE(excl
)] = UL_EXCL_STATUS_INIT
;
783 setlocale(LC_ALL
, "");
784 bindtextdomain(PACKAGE
, LOCALEDIR
);
786 atexit(close_stdout
);
788 while ((c
= getopt_long(argc
, argv
,
789 "abdglrsuvn:t:o:PhV", long_opts
, NULL
)) != -1) {
791 err_exclusive_options(c
, long_opts
, excl
, excl_st
);
798 partx_flags
|= FL_BYTES
;
804 scols_flags
|= PARTX_NOHEADINGS
;
810 if (parse_range(optarg
, &lower
, &upper
, 0))
811 errx(EXIT_FAILURE
, _("failed to parse --nr <M-N> range"));
817 scols_flags
|= PARTX_EXPORT
;
821 scols_flags
|= PARTX_RAW
;
839 printf(UTIL_LINUX_VERSION
);
847 if (what
== ACT_NONE
)
850 /* --show default, could by modified by -o */
851 if (what
== ACT_SHOW
&& !ncolumns
) {
852 columns
[ncolumns
++] = COL_PARTNO
;
853 columns
[ncolumns
++] = COL_START
;
854 columns
[ncolumns
++] = COL_END
;
855 columns
[ncolumns
++] = COL_SECTORS
;
856 columns
[ncolumns
++] = COL_SIZE
;
857 columns
[ncolumns
++] = COL_NAME
;
858 columns
[ncolumns
++] = COL_UUID
;
861 if (what
== ACT_SHOW
&& outarg
&&
862 string_add_to_idarray(outarg
, columns
, ARRAY_SIZE(columns
),
863 &ncolumns
, column_name_to_id
) < 0)
867 * Note that 'partx /dev/sda1' == 'partx /dev/sda1 /dev/sda'
868 * so assume that the device and/or disk are always the last
869 * arguments to be passed to partx.
871 if (optind
== argc
- 2) {
872 /* passed 2 arguments:
873 * /dev/sda1 /dev/sda : partition + whole-disk
874 * -- /dev/sda1 : partition that should be used as a whole-disk
876 device
= argv
[optind
];
878 if (strcmp(device
, "-") == 0) {
880 wholedisk
= xstrdup(argv
[optind
+ 1]);
882 device
= argv
[optind
];
883 wholedisk
= xstrdup(argv
[optind
+ 1]);
885 } else if (optind
== argc
- 1) {
886 /* passed only one arg (ie: /dev/sda3 or /dev/sda) */
889 device
= argv
[optind
];
891 if (stat(device
, &sb
))
892 err(EXIT_FAILURE
, _("stat of %s failed"), device
);
894 part_devno
= sb
.st_rdev
;
896 if (blkid_devno_to_wholedisk(part_devno
,
897 NULL
, 0, &disk_devno
) == 0 &&
898 part_devno
!= disk_devno
)
899 wholedisk
= blkid_devno_to_devname(disk_devno
);
902 wholedisk
= xstrdup(device
);
903 disk_devno
= part_devno
;
910 if (device
&& (upper
|| lower
))
911 errx(EXIT_FAILURE
, _("--nr and <partition> are mutually exclusive"));
916 /* use partno from given partition instead of --nr range, e.g:
919 * partx -d --nr 3 /dev/sda
923 if (!part_devno
&& !stat(device
, &sb
))
924 part_devno
= sb
.st_rdev
;
926 lower
= upper
= get_partno_from_device(device
, part_devno
);
930 printf(_("partition: %s, disk: %s, lower: %d, upper: %d\n"),
931 device
? device
: "none", wholedisk
, lower
, upper
);
933 if (what
== ACT_ADD
|| what
== ACT_DELETE
) {
936 if (stat(wholedisk
, &x
))
937 errx(EXIT_FAILURE
, "%s", wholedisk
);
939 if (S_ISREG(x
.st_mode
)) {
940 /* not a blkdev, try to associate it to a loop device */
941 if (what
== ACT_DELETE
)
942 errx(EXIT_FAILURE
, _("%s: cannot delete partitions"),
944 if (!loopmod_supports_partscan())
945 errx(EXIT_FAILURE
, _("%s: partitioned loop devices unsupported"),
947 assoc_loopdev(wholedisk
);
948 wholedisk
= xstrdup(lc
.device
);
949 } else if (!S_ISBLK(x
.st_mode
))
950 errx(EXIT_FAILURE
, _("%s: not a block device"), wholedisk
);
952 if ((fd
= open(wholedisk
, O_RDONLY
)) == -1)
953 err(EXIT_FAILURE
, _("cannot open %s"), wholedisk
);
955 if (what
== ACT_DELETE
)
956 rc
= del_parts(fd
, wholedisk
, disk_devno
, lower
, upper
);
958 blkid_probe pr
= blkid_new_probe();
959 blkid_partlist ls
= NULL
;
961 if (!pr
|| blkid_probe_set_device(pr
, fd
, 0, 0))
962 warnx(_("%s: failed to initialize blkid prober"),
965 ls
= get_partlist(pr
, wholedisk
, type
);
968 int n
= blkid_partlist_numof_partitions(ls
);
971 lower
= n
+ lower
+ 1;
973 upper
= n
+ upper
+ 1;
975 warnx(_("specified range <%d:%d> "
976 "does not make sense"), lower
, upper
);
977 rc
= -1, what
= ACT_NONE
;
982 rc
= show_parts(ls
, scols_flags
, lower
, upper
);
985 rc
= list_parts(ls
, lower
, upper
);
988 rc
= add_parts(fd
, wholedisk
, ls
, lower
, upper
);
991 rc
= upd_parts(fd
, wholedisk
, disk_devno
, ls
, lower
, upper
);
998 blkid_free_probe(pr
);
1002 loopcxt_deinit(&lc
);
1004 if (close_fd(fd
) != 0)
1005 err(EXIT_FAILURE
, _("write failed"));
1007 return rc
? EXIT_FAILURE
: EXIT_SUCCESS
;