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>
24 #include <libsmartcols.h>
27 #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
], ncolumns
;
105 static int partx_flags
;
106 static struct loopdev_cxt lc
;
109 static void assoc_loopdev(const char *fname
)
113 if (loopcxt_init(&lc
, 0))
114 err(EXIT_FAILURE
, _("failed to initialize loopcxt"));
116 rc
= loopcxt_find_unused(&lc
);
118 err(EXIT_FAILURE
, _("%s: failed to find unused loop device"),
122 printf(_("Trying to use '%s' for the loop device\n"),
123 loopcxt_get_device(&lc
));
125 if (loopcxt_set_backing_file(&lc
, fname
))
126 err(EXIT_FAILURE
, _("%s: failed to set backing file"), fname
);
128 rc
= loopcxt_setup_device(&lc
);
131 err(EXIT_FAILURE
, _("%s: failed to set up loop device"), fname
);
136 static inline int get_column_id(int num
)
138 assert(ARRAY_SIZE(columns
) == NCOLS
);
139 assert(num
< ncolumns
);
140 assert(columns
[num
] < (int) NCOLS
);
144 static inline struct colinfo
*get_column_info(int num
)
146 return &infos
[ get_column_id(num
) ];
149 static int column_name_to_id(const char *name
, size_t namesz
)
155 for (i
= 0; i
< NCOLS
; i
++) {
156 const char *cn
= infos
[i
].name
;
158 if (!strncasecmp(name
, cn
, namesz
) && !*(cn
+ namesz
))
161 warnx(_("unknown column: %s"), name
);
166 * Given a partition return the corresponding partition number.
168 * Note that this function tries to use sysfs, otherwise it assumes that the
169 * last characters are always numeric (sda1, sdc20, etc).
171 static int get_partno_from_device(char *partition
, dev_t devno
)
175 char *p
, *end
= NULL
;
180 struct sysfs_cxt cxt
;
183 if (sysfs_init(&cxt
, devno
, NULL
))
186 rc
= sysfs_read_int(&cxt
, "partition", &partno
);
193 sz
= strlen(partition
);
194 p
= partition
+ sz
- 1;
196 if (!isdigit((unsigned int) *p
))
199 while (isdigit((unsigned int) *(p
- 1))) p
--;
202 partno
= strtol(p
, &end
, 10);
203 if (errno
|| !end
|| *end
|| p
== end
)
208 errx(EXIT_FAILURE
, _("%s: failed to get partition number"), partition
);
211 static int get_max_partno(const char *disk
, dev_t devno
)
213 char path
[PATH_MAX
], *parent
, *dirname
= NULL
;
219 if (!devno
&& !stat(disk
, &st
))
223 parent
= strrchr(disk
, '/');
228 snprintf(path
, sizeof(path
), _PATH_SYS_DEVBLOCK
"/%d:%d/",
229 major(devno
), minor(devno
));
235 dirname
= xstrdup(path
);
237 while ((d
= readdir(dir
))) {
240 if (!strcmp(d
->d_name
, ".") ||
241 !strcmp(d
->d_name
, ".."))
243 #ifdef _DIRENT_HAVE_D_TYPE
244 if (d
->d_type
!= DT_DIR
&& d
->d_type
!= DT_UNKNOWN
)
247 if (strncmp(parent
, d
->d_name
, strlen(parent
)))
249 snprintf(path
, sizeof(path
), "%s/partition", d
->d_name
);
251 fd
= open_at(dirfd(dir
), dirname
, path
, O_RDONLY
);
254 FILE *f
= fdopen(fd
, "r");
256 if (fscanf(f
, "%d", &x
) == 1 && x
> partno
)
270 static void del_parts_warnx(const char *device
, int first
, int last
)
273 warnx(_("%s: error deleting partition %d"), device
, first
);
275 warnx(_("%s: error deleting partitions %d-%d"),
276 device
, first
, last
);
279 static int del_parts(int fd
, const char *device
, dev_t devno
,
280 int lower
, int upper
)
282 int rc
= 0, i
, errfirst
= 0, errlast
= 0;
289 if (!upper
|| lower
< 0 || upper
< 0) {
290 int n
= get_max_partno(device
, devno
);
294 upper
= n
+ upper
+ 1;
296 lower
= n
+ lower
+ 1;
299 warnx(_("specified range <%d:%d> "
300 "does not make sense"), lower
, upper
);
304 for (i
= lower
; i
<= upper
; i
++) {
305 rc
= partx_del_partition(fd
, i
);
308 printf(_("%s: partition #%d removed\n"), device
, i
);
310 } else if (errno
== ENXIO
) {
312 printf(_("%s: partition #%d already doesn't exist\n"), device
, i
);
317 warn(_("%s: deleting partition #%d failed"), device
, i
);
319 errlast
= errfirst
= i
;
320 else if (errlast
+ 1 == i
)
323 del_parts_warnx(device
, errfirst
, errlast
);
324 errlast
= errfirst
= i
;
329 del_parts_warnx(device
, errfirst
, errlast
);
334 static void add_parts_warnx(const char *device
, int first
, int last
)
337 warnx(_("%s: error adding partition %d"), device
, first
);
339 warnx(_("%s: error adding partitions %d-%d"),
340 device
, first
, last
);
343 static int add_parts(int fd
, const char *device
,
344 blkid_partlist ls
, int lower
, int upper
)
346 int i
, nparts
, rc
= 0, errfirst
= 0, errlast
= 0;
352 nparts
= blkid_partlist_numof_partitions(ls
);
354 for (i
= 0; i
< nparts
; i
++) {
355 blkid_partition par
= blkid_partlist_get_partition(ls
, i
);
356 int n
= blkid_partition_get_partno(par
);
357 uintmax_t start
, size
;
359 if (lower
&& n
< lower
)
361 if (upper
&& n
> upper
)
364 start
= blkid_partition_get_start(par
);
365 size
= blkid_partition_get_size(par
);
367 if (blkid_partition_is_extended(par
))
369 * Let's follow the Linux kernel and reduce
370 * DOS extended partition to 1 or 2 sectors.
372 size
= min(size
, (uintmax_t) 2);
374 if (partx_add_partition(fd
, n
, start
, size
) == 0) {
376 printf(_("%s: partition #%d added\n"), device
, n
);
381 warn(_("%s: adding partition #%d failed"), device
, n
);
383 errlast
= errfirst
= n
;
384 else if (errlast
+ 1 == n
)
387 add_parts_warnx(device
, errfirst
, errlast
);
388 errlast
= errfirst
= n
;
393 add_parts_warnx(device
, errfirst
, errlast
);
396 * The kernel with enabled partitions scanner for loop devices add *all*
397 * partitions, so we should delete any extra, unwanted ones, when the -n
400 if (loopdev
&& loopcxt_is_partscan(&lc
) && (lower
|| upper
)) {
401 for (i
= 0; i
< nparts
; i
++) {
402 blkid_partition par
= blkid_partlist_get_partition(ls
, i
);
403 int n
= blkid_partition_get_partno(par
);
405 if (n
< lower
|| n
> upper
)
406 partx_del_partition(fd
, n
);
413 static void upd_parts_warnx(const char *device
, int first
, int last
)
416 warnx(_("%s: error updating partition %d"), device
, first
);
418 warnx(_("%s: error updating partitions %d-%d"),
419 device
, first
, last
);
422 static int upd_parts(int fd
, const char *device
, dev_t devno
,
423 blkid_partlist ls
, int lower
, int upper
)
425 int n
, nparts
, rc
= 0, errfirst
= 0, errlast
= 0, err
;
427 uintmax_t start
, size
;
433 nparts
= blkid_partlist_numof_partitions(ls
);
436 if (!upper
|| lower
< 0 || upper
< 0) {
437 n
= get_max_partno(device
, devno
);
439 upper
= n
> nparts
? n
: nparts
;
441 upper
= n
+ upper
+ 1;
443 lower
= n
+ lower
+ 1;
446 warnx(_("specified range <%d:%d> "
447 "does not make sense"), lower
, upper
);
451 for (n
= lower
; n
<= upper
; n
++) {
452 par
= blkid_partlist_get_partition_by_partno(ls
, n
);
455 warn(_("%s: no partition #%d"), device
, n
);
459 start
= blkid_partition_get_start(par
);
460 size
= blkid_partition_get_size(par
);
461 if (blkid_partition_is_extended(par
))
463 * Let's follow the Linux kernel and reduce
464 * DOS extended partition to 1 or 2 sectors.
466 size
= min(size
, (uintmax_t) 2);
468 err
= partx_del_partition(fd
, n
);
469 if (err
== -1 && errno
== ENXIO
)
470 err
= 0; /* good, it already doesn't exist */
471 if (err
== -1 && errno
== EBUSY
)
474 err
= partx_resize_partition(fd
, n
, start
, size
);
476 printf(_("%s: partition #%d resized\n"), device
, n
);
480 if (err
== 0 && partx_add_partition(fd
, n
, start
, size
) == 0) {
482 printf(_("%s: partition #%d added\n"), device
, n
);
490 warn(_("%s: updating partition #%d failed"), device
, n
);
492 errlast
= errfirst
= n
;
493 else if (errlast
+ 1 == n
)
496 upd_parts_warnx(device
, errfirst
, errlast
);
497 errlast
= errfirst
= n
;
502 upd_parts_warnx(device
, errfirst
, errlast
);
506 static int list_parts(blkid_partlist ls
, int lower
, int upper
)
512 nparts
= blkid_partlist_numof_partitions(ls
);
514 for (i
= 0; i
< nparts
; i
++) {
515 blkid_partition par
= blkid_partlist_get_partition(ls
, i
);
516 int n
= blkid_partition_get_partno(par
);
517 uintmax_t start
, size
;
519 if (lower
&& n
< lower
)
521 if (upper
&& n
> upper
)
524 start
= blkid_partition_get_start(par
);
525 size
= blkid_partition_get_size(par
);
527 printf(P_("#%2d: %9ju-%9ju (%9ju sector, %6ju MB)\n",
528 "#%2d: %9ju-%9ju (%9ju sectors, %6ju MB)\n",
530 n
, start
, start
+ size
-1,
531 size
, (size
<< 9) / 1000000);
536 static int add_scols_line(struct libscols_table
*table
, blkid_partition par
)
538 struct libscols_line
*line
;
544 line
= scols_table_new_line(table
, NULL
);
546 warn(_("failed to add line to output"));
550 for (i
= 0; i
< ncolumns
; i
++) {
551 char *str
= NULL
; /* allocated string */
552 const char *cstr
= NULL
; /* foreign string */
554 switch (get_column_id(i
)) {
556 xasprintf(&str
, "%d", blkid_partition_get_partno(par
));
559 xasprintf(&str
, "%ju", blkid_partition_get_start(par
));
562 xasprintf(&str
, "%ju",
563 blkid_partition_get_start(par
) +
564 blkid_partition_get_size(par
) - 1);
567 xasprintf(&str
, "%ju", blkid_partition_get_size(par
));
570 if (partx_flags
& FL_BYTES
)
571 xasprintf(&str
, "%ju", (uintmax_t)
572 blkid_partition_get_size(par
) << 9);
574 str
= size_to_human_string(SIZE_SUFFIX_1LETTER
,
575 blkid_partition_get_size(par
) << 9);
578 cstr
= blkid_partition_get_name(par
);
581 cstr
= blkid_partition_get_uuid(par
);
584 if (blkid_partition_get_type_string(par
))
585 cstr
= blkid_partition_get_type_string(par
);
587 xasprintf(&str
, "0x%x",
588 blkid_partition_get_type(par
));
591 xasprintf(&str
, "0x%llx", blkid_partition_get_flags(par
));
595 blkid_parttable tab
= blkid_partition_get_table(par
);
597 cstr
= blkid_parttable_get_type(tab
);
605 rc
= scols_line_set_data(line
, i
, cstr
);
607 rc
= scols_line_refer_data(line
, i
, str
);
609 warn(_("failed to add data to output table"));
617 static int show_parts(blkid_partlist ls
, int scols_flags
, int lower
, int upper
)
620 struct libscols_table
*table
;
625 nparts
= blkid_partlist_numof_partitions(ls
);
630 table
= scols_new_table();
632 warn(_("failed to initialize output table"));
635 scols_table_enable_raw(table
, !!(scols_flags
& PARTX_RAW
));
636 scols_table_enable_export(table
, !!(scols_flags
& PARTX_EXPORT
));
637 scols_table_enable_noheadings(table
, !!(scols_flags
& PARTX_NOHEADINGS
));
639 for (i
= 0; i
< ncolumns
; i
++) {
640 struct colinfo
*col
= get_column_info(i
);
642 if (!scols_table_new_column(table
, col
->name
, col
->whint
, col
->flags
)) {
643 warnx(_("failed to initialize output column"));
648 for (i
= 0; i
< nparts
; i
++) {
649 blkid_partition par
= blkid_partlist_get_partition(ls
, i
);
650 int n
= blkid_partition_get_partno(par
);
652 if (lower
&& n
< lower
)
654 if (upper
&& n
> upper
)
657 rc
= add_scols_line(table
, par
);
663 scols_print_table(table
);
665 scols_unref_table(table
);
669 static blkid_partlist
get_partlist(blkid_probe pr
,
670 const char *device
, char *type
)
679 char *name
[] = { type
, NULL
};
681 if (blkid_probe_filter_partitions_type(pr
,
682 BLKID_FLTR_ONLYIN
, name
)) {
683 warnx(_("failed to initialize blkid "
684 "filter for '%s'"), type
);
689 ls
= blkid_probe_get_partitions(pr
);
691 warnx(_("%s: failed to read partition table"), device
);
695 tab
= blkid_partlist_get_table(ls
);
696 if (verbose
&& tab
) {
697 printf(_("%s: partition table type '%s' detected\n"),
698 device
, blkid_parttable_get_type(tab
));
700 if (!blkid_partlist_numof_partitions(ls
))
701 printf(_("%s: partition table with no partitions"), device
);
707 static void __attribute__((__noreturn__
)) usage(FILE *out
)
711 fputs(USAGE_HEADER
, out
);
713 _(" %s [-a|-d|-s|-u] [--nr <n:m> | <partition>] <disk>\n"),
714 program_invocation_short_name
);
716 fputs(USAGE_SEPARATOR
, out
);
717 fputs(_("Tell the kernel about the presence and numbering of partitions.\n"), out
);
719 fputs(USAGE_OPTIONS
, out
);
720 fputs(_(" -a, --add add specified partitions or all of them\n"), out
);
721 fputs(_(" -d, --delete delete specified partitions or all of them\n"), out
);
722 fputs(_(" -u, --update update specified partitions or all of them\n"), out
);
723 fputs(_(" -s, --show list partitions\n\n"), out
);
724 fputs(_(" -b, --bytes print SIZE in bytes rather than in human readable format\n"), out
);
725 fputs(_(" -g, --noheadings don't print headings for --show\n"), out
);
726 fputs(_(" -n, --nr <n:m> specify the range of partitions (e.g. --nr 2:4)\n"), out
);
727 fputs(_(" -o, --output <list> define which output columns to use\n"), out
);
728 fputs(_(" -P, --pairs use key=\"value\" output format\n"), out
);
729 fputs(_(" -r, --raw use raw output format\n"), out
);
730 fputs(_(" -t, --type <type> specify the partition type (dos, bsd, solaris, etc.)\n"), out
);
731 fputs(_(" -v, --verbose verbose mode\n"), out
);
733 fputs(USAGE_SEPARATOR
, out
);
734 fputs(USAGE_HELP
, out
);
735 fputs(USAGE_VERSION
, out
);
737 fputs(_("\nAvailable columns (for --show, --raw or --pairs):\n"), out
);
739 for (i
= 0; i
< NCOLS
; i
++)
740 fprintf(out
, " %10s %s\n", infos
[i
].name
, _(infos
[i
].help
));
742 fprintf(out
, USAGE_MAN_TAIL("partx(8)"));
744 exit(out
== stderr
? EXIT_FAILURE
: EXIT_SUCCESS
);
747 int main(int argc
, char **argv
)
749 int fd
, c
, what
= ACT_NONE
, lower
= 0, upper
= 0, rc
= 0;
752 char *device
= NULL
; /* pointer to argv[], ie: /dev/sda1 */
753 char *wholedisk
= NULL
; /* allocated, ie: /dev/sda */
755 dev_t disk_devno
= 0, part_devno
= 0;
757 static const struct option long_opts
[] = {
758 { "bytes", no_argument
, NULL
, 'b' },
759 { "noheadings", no_argument
, NULL
, 'g' },
760 { "raw", no_argument
, NULL
, 'r' },
761 { "list", no_argument
, NULL
, 'l' },
762 { "show", no_argument
, NULL
, 's' },
763 { "add", no_argument
, NULL
, 'a' },
764 { "delete", no_argument
, NULL
, 'd' },
765 { "update", no_argument
, NULL
, 'u' },
766 { "type", required_argument
, NULL
, 't' },
767 { "nr", required_argument
, NULL
, 'n' },
768 { "output", required_argument
, NULL
, 'o' },
769 { "pairs", no_argument
, NULL
, 'P' },
770 { "help", no_argument
, NULL
, 'h' },
771 { "version", no_argument
, NULL
, 'V' },
772 { "verbose", no_argument
, NULL
, 'v' },
776 static const ul_excl_t excl
[] = { /* rows and cols in in ASCII order */
777 { 'P','a','d','l','r','s' },
780 int excl_st
[ARRAY_SIZE(excl
)] = UL_EXCL_STATUS_INIT
;
782 setlocale(LC_ALL
, "");
783 bindtextdomain(PACKAGE
, LOCALEDIR
);
785 atexit(close_stdout
);
787 while ((c
= getopt_long(argc
, argv
,
788 "abdglrsuvn:t:o:PhV", long_opts
, NULL
)) != -1) {
790 err_exclusive_options(c
, long_opts
, excl
, excl_st
);
797 partx_flags
|= FL_BYTES
;
803 scols_flags
|= PARTX_NOHEADINGS
;
809 if (parse_range(optarg
, &lower
, &upper
, 0))
810 errx(EXIT_FAILURE
, _("failed to parse --nr <M-N> range"));
816 scols_flags
|= PARTX_EXPORT
;
820 scols_flags
|= PARTX_RAW
;
838 printf(UTIL_LINUX_VERSION
);
846 if (what
== ACT_NONE
)
849 /* --show default, could by modified by -o */
850 if (what
== ACT_SHOW
&& !ncolumns
) {
851 columns
[ncolumns
++] = COL_PARTNO
;
852 columns
[ncolumns
++] = COL_START
;
853 columns
[ncolumns
++] = COL_END
;
854 columns
[ncolumns
++] = COL_SECTORS
;
855 columns
[ncolumns
++] = COL_SIZE
;
856 columns
[ncolumns
++] = COL_NAME
;
857 columns
[ncolumns
++] = COL_UUID
;
860 if (what
== ACT_SHOW
&& outarg
&&
861 string_add_to_idarray(outarg
, columns
, ARRAY_SIZE(columns
),
862 &ncolumns
, column_name_to_id
) < 0)
866 * Note that 'partx /dev/sda1' == 'partx /dev/sda1 /dev/sda'
867 * so assume that the device and/or disk are always the last
868 * arguments to be passed to partx.
870 if (optind
== argc
- 2) {
871 /* passed 2 arguments:
872 * /dev/sda1 /dev/sda : partition + whole-disk
873 * -- /dev/sda1 : partition that should be used as a whole-disk
875 device
= argv
[optind
];
877 if (strcmp(device
, "-") == 0) {
879 wholedisk
= xstrdup(argv
[optind
+ 1]);
881 device
= argv
[optind
];
882 wholedisk
= xstrdup(argv
[optind
+ 1]);
884 } else if (optind
== argc
- 1) {
885 /* passed only one arg (ie: /dev/sda3 or /dev/sda) */
888 device
= argv
[optind
];
890 if (stat(device
, &sb
))
891 err(EXIT_FAILURE
, _("stat failed %s"), device
);
893 part_devno
= sb
.st_rdev
;
895 if (blkid_devno_to_wholedisk(part_devno
,
896 NULL
, 0, &disk_devno
) == 0 &&
897 part_devno
!= disk_devno
)
898 wholedisk
= blkid_devno_to_devname(disk_devno
);
901 wholedisk
= xstrdup(device
);
902 disk_devno
= part_devno
;
909 if (device
&& (upper
|| lower
))
910 errx(EXIT_FAILURE
, _("--nr and <partition> are mutually exclusive"));
915 /* use partno from given partition instead of --nr range, e.g:
918 * partx -d --nr 3 /dev/sda
922 if (!part_devno
&& !stat(device
, &sb
))
923 part_devno
= sb
.st_rdev
;
925 lower
= upper
= get_partno_from_device(device
, part_devno
);
929 printf(_("partition: %s, disk: %s, lower: %d, upper: %d\n"),
930 device
? device
: "none", wholedisk
, lower
, upper
);
932 if (what
== ACT_ADD
|| what
== ACT_DELETE
) {
935 if (stat(wholedisk
, &x
))
936 errx(EXIT_FAILURE
, "%s", wholedisk
);
938 if (S_ISREG(x
.st_mode
)) {
939 /* not a blkdev, try to associate it to a loop device */
940 if (what
== ACT_DELETE
)
941 errx(EXIT_FAILURE
, _("%s: cannot delete partitions"),
943 if (!loopmod_supports_partscan())
944 errx(EXIT_FAILURE
, _("%s: partitioned loop devices unsupported"),
946 assoc_loopdev(wholedisk
);
947 wholedisk
= xstrdup(lc
.device
);
948 } else if (!S_ISBLK(x
.st_mode
))
949 errx(EXIT_FAILURE
, _("%s: not a block device"), wholedisk
);
951 if ((fd
= open(wholedisk
, O_RDONLY
)) == -1)
952 err(EXIT_FAILURE
, _("cannot open %s"), wholedisk
);
954 if (what
== ACT_DELETE
)
955 rc
= del_parts(fd
, wholedisk
, disk_devno
, lower
, upper
);
957 blkid_probe pr
= blkid_new_probe();
958 blkid_partlist ls
= NULL
;
960 if (!pr
|| blkid_probe_set_device(pr
, fd
, 0, 0))
961 warnx(_("%s: failed to initialize blkid prober"),
964 ls
= get_partlist(pr
, wholedisk
, type
);
967 int n
= blkid_partlist_numof_partitions(ls
);
970 lower
= n
+ lower
+ 1;
972 upper
= n
+ upper
+ 1;
974 warnx(_("specified range <%d:%d> "
975 "does not make sense"), lower
, upper
);
976 rc
= -1, what
= ACT_NONE
;
981 rc
= show_parts(ls
, scols_flags
, lower
, upper
);
984 rc
= list_parts(ls
, lower
, upper
);
987 rc
= add_parts(fd
, wholedisk
, ls
, lower
, upper
);
990 rc
= upd_parts(fd
, wholedisk
, disk_devno
, ls
, lower
, upper
);
997 blkid_free_probe(pr
);
1001 loopcxt_deinit(&lc
);
1003 if (close_fd(fd
) != 0)
1004 err(EXIT_FAILURE
, _("write failed"));
1006 return rc
? EXIT_FAILURE
: EXIT_SUCCESS
;