Hi, When assigning mount points to an already-partitioned disk without a its fstab handy, it's annoying to type the partition letters one after another. (And sing the alphabet each time or look at the output of 'p' for letters after 'f'. I blame hex.) I could go back to preeschool and learn the alphabet, but this seemed easier.
This patch makes the 'n' (set mount point) command provide the lowest partition of a mountable type without a set mount-point as the default in the partition-selection prompt. It also addresses the fact that get_mp() hadn't been updated in a while and wasn't aware that RAID partitions can't have mount points. Thoughts? Index: sys/sys/disklabel.h =================================================================== RCS file: /cvs/src/sys/sys/disklabel.h,v retrieving revision 1.60 diff -u -p -r1.60 disklabel.h --- sys/sys/disklabel.h 5 May 2014 13:32:15 -0000 1.60 +++ sys/sys/disklabel.h 15 Jun 2014 02:22:20 -0000 @@ -275,6 +275,10 @@ static char *dktypenames[] = { #define FS_NTFS 20 /* Windows/NT file system */ #define FS_UDF 21 /* UDF (DVD) filesystem */ +#define FS_ALLOWS_NAME(t) ((t) != FS_UNUSED && (t) != FS_SWAP && \ + (t) != FS_OTHER && (t) != FS_BOOT && \ + (t) != FS_RAID) + #ifdef DKTYPENAMES static char *fstypenames[] = { "unused", Index: sbin/disklabel/editor.c =================================================================== RCS file: /cvs/src/sbin/disklabel/editor.c,v retrieving revision 1.286 diff -u -p -r1.286 editor.c --- sbin/disklabel/editor.c 2 May 2014 23:17:29 -0000 1.286 +++ sbin/disklabel/editor.c 15 Jun 2014 02:22:20 -0000 @@ -933,12 +933,23 @@ void editor_name(struct disklabel *lp, char *p) { struct partition *pp; + char buf[2]; int partno; /* Change which partition? */ if (p == NULL) { + memset(buf, 0, sizeof(buf)); + pp = &lp->d_partitions[0]; + for (partno = 0; partno < MAXPARTITIONS; partno++, pp++) { + if (mountpoints[partno] == NULL && + partno != RAW_PART && + FS_ALLOWS_NAME(pp->p_fstype)) { + buf[0] = partno + 'a'; + break; + } + } p = getstring("partition to name", - "The letter of the partition to name, a - p.", NULL); + "The letter of the partition to name, a - p.", buf); } if (p == NULL) { fputs("Command aborted\n", stderr); @@ -958,9 +969,7 @@ editor_name(struct disklabel *lp, char * } /* Not all fstypes can be named */ - if (pp->p_fstype == FS_UNUSED || pp->p_fstype == FS_SWAP || - pp->p_fstype == FS_BOOT || pp->p_fstype == FS_OTHER || - pp->p_fstype == FS_RAID) { + if (!FS_ALLOWS_NAME(pp->p_fstype)) { fprintf(stderr, "You cannot name a filesystem of type %s.\n", fstypenames[lp->d_partitions[partno].p_fstype]); return; @@ -2166,9 +2175,7 @@ get_mp(struct disklabel *lp, int partno) char *p; int i; - if (fstabfile && pp->p_fstype != FS_UNUSED && - pp->p_fstype != FS_SWAP && pp->p_fstype != FS_BOOT && - pp->p_fstype != FS_OTHER) { + if (fstabfile && FS_ALLOWS_NAME(pp->p_fstype)) { for (;;) { p = getstring("mount point", "Where to mount this filesystem (ie: / /var /usr)",