commit - 1abb1c5c81f95aa6b4f89c9a30117f7a68027c40
commit + 2b650bbafb20bb7ab50ebf01fe8df71ac2b15466
blob - a6eff56179843dd72fb4d75a56075ce55b88ac5c
blob + a02b9856bef290df3e828e9902cffaa26ac24240
--- ChangeLog.md
+++ ChangeLog.md
### Added
- Options:
- `-a` print all fields
+
+### Changed
+- Merge "LABEL" and "MOUNT" fields into "LABEL/MOUNT"
+ because disks can't be mounted but partitions can,
+ and disks can have a label but partitions don't
+ (at least through the disklabel interface).
+### Removed
+- Options:
+ - `-l`
+
## [1.1] - 2023-05-02
### Added
- Header
blob - f5fe2aafcb81080dafe5bcc38bc2e25e6e926488
blob + 8e263e611381f89b75158489e87a707e66504496
--- README.md
+++ README.md
## TODO
- [ ] Fancy unicodes: `├─` & `└─`
-- [ ] Where should "LABEL" go? After "NAME" or before "MOUNT"?
- [ ] `lsblk sd0`
blob - 6238bba72190c015d551b3e7f81b0c9d644e1c49
blob + 947e92a5ce56e2605e5dd19c0016587a2b7fe4ca
--- lsblk.8
+++ lsblk.8
.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-.TH LSBLK 8 lsblk-@VERSION@ 2023-05-01
+.TH LSBLK 8 lsblk-@VERSION@ 2023-05-04
.SH NAME
lsblk \- list block devices
.SH SYNOPSIS
.B \-a
print all fields.
.TP
-.B \-l
-also print the label (packname) of each disk.
-.TP
.B \-n
don't print the header.
.TP
blob - 3b3d9c5531656b7a10905d542f166791bc46f6cd
blob + 136f6741171ab966b7f00d656702373e038a37b3
--- lsblk.c
+++ lsblk.c
enum {
FIELD_NAME = 0x01,
- FIELD_LABEL = 0x02,
- FIELD_SIZE = 0x04,
- FIELD_USED = 0x08,
- FIELD_FREE = 0x10,
- FIELD_TYPE = 0x20,
- FIELD_MOUNT = 0x40,
+ FIELD_SIZE = 0x02,
+ FIELD_USED = 0x04,
+ FIELD_FREE = 0x08,
+ FIELD_TYPE = 0x10,
+ FIELD_LMNT = 0x20,
- FIELD_DEFAULT = FIELD_NAME | FIELD_SIZE | FIELD_TYPE | FIELD_MOUNT,
+ FIELD_DEFAULT = FIELD_NAME | FIELD_SIZE | FIELD_TYPE | FIELD_LMNT,
};
struct my_partinfo {
char name[4];
uint64_t size;
uint64_t used;
- const char *mount;
uint8_t num_parts;
struct my_partinfo parts[MAXPARTITIONS];
};
if (fields & FIELD_NAME)
printf ("%-6s ", "NAME");
- if (fields & FIELD_LABEL)
- printf ("%-16s ", "LABEL");
-
if (fields & FIELD_SIZE)
printf ("%-4s ", "SIZE");
if (fields & FIELD_TYPE)
printf ("%-8s ", "TYPE");
- if (fields & FIELD_MOUNT)
- printf ("MOUNT ");
+ if (fields & FIELD_LMNT)
+ printf ("LABEL/MOUNT ");
putchar ('\n');
}
if (fields & FIELD_NAME)
printf (" %s ", part->name);
- if (fields & FIELD_LABEL)
- printf ("%16s ", "");
-
if (fields & FIELD_SIZE)
print_size (part->size);
if (fields & FIELD_TYPE)
printf ("%-8.16s ", part->fstype);
- if (fields & FIELD_MOUNT && part->mount)
+ if (fields & FIELD_LMNT && part->mount)
printf ("%s ", part->mount);
putchar ('\n');
if (fields & FIELD_NAME)
printf ("%s ", disk->name);
- if (fields & FIELD_LABEL)
- printf ("%-16.16s ", disk->label);
-
if (fields & FIELD_SIZE)
print_size (disk->size);
if (fields & FIELD_TYPE)
printf ("%-8.16s ", disk->type);
- if (fields & FIELD_MOUNT && disk->mount)
- printf ("%s ", disk->mount);
+ if (fields & FIELD_LMNT)
+ printf ("%.16s ", disk->label);
putchar ('\n');
bzero (&disk, sizeof disk);
{ // Read disklabel.
- const struct statfs *mnt;
char path[5 + 4 + 1];
int fd;
if (ioctl (fd, DIOCGDINFO, &label) < 0)
die ("ioctl(%s, DIOCGDINFO)", path);
close (fd);
-
- mnt = find_mount (path);
- if (mnt)
- disk.mount = mnt->f_mntonname;
}
memcpy (disk.name, name, 3);
static int usage (void)
{
- fputs ("Usage: lsblk [-Valnu]\n", stderr);
+ fputs ("Usage: lsblk [-Vanu]\n", stderr);
return 1;
}
if (unveil (NULL, NULL) == -1)
die ("unveil()");
- while ((option = getopt (argc, argv, ":Valnu")) != -1) {
+ while ((option = getopt (argc, argv, ":Vanu")) != -1) {
switch (option) {
case 'V':
puts ("lsblk-" VERSION);
case 'a':
fields = -1;
break;
- case 'l':
- fields |= FIELD_LABEL;
- break;
case 'n':
header = false;
break;