commit - 3103dec457d1a69422047e1eef4aae1c7d0cfc1c
commit + 8380cc51e12ea38e5cc609bfd9226905e5a3036a
blob - 6a3a8644b63bd2bb87b113f059ae3d9ea066e81d
blob + 5f5517620940cc53d22dab6a586393a78b4a344a
--- 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-04-30
+.TH LSBLK 8 lsblk-@VERSION@ 2023-05-01
.SH NAME
lsblk \- list block devices
.SH SYNOPSIS
-.B lsblk [-V]
+.B lsblk [-Vn]
.SH DESCRIPTION
The
.B lsblk
.TP
.B \-V
prints version information to stdout, then exits.
+.TP
+.B \-n
+don't print the header.
.SH SEE ALSO
.BR disklabel (8)
blob - a80183d89544445d1fe6e1614124fda08509c3e6
blob + 5cdd6db7b9dda8c564aafc9dd261b220f9e4049c
--- lsblk.c
+++ lsblk.c
#include <sys/mount.h>
#include <sys/dkio.h>
#include <inttypes.h>
+#include <stdbool.h>
#include <string.h>
#include <stdarg.h>
#include <stdint.h>
static int usage (void)
{
- fputs ("Usage: lsblk [-V]\n", stderr);
+ fputs ("Usage: lsblk [-Vn]\n", stderr);
return 1;
}
int main (int argc, char *argv[])
{
+ int option;
+ bool header = true;
+
if (unveil ("/dev", "r") == -1)
die ("unveil(/dev)");
if (unveil (NULL, NULL) == -1)
die ("unveil()");
- int option;
- while ((option = getopt (argc, argv, ":V")) != -1) {
+ while ((option = getopt (argc, argv, ":Vn")) != -1) {
switch (option) {
case 'V':
puts ("lsblk-" VERSION);
return 0;
+ case 'n':
+ header = false;
+ break;
default:
return usage ();
}
if (n_mounts == 0)
die ("getmntinfo()");
+ if (header)
+ puts ("NAME SIZE TYPE MOUNTPOINT");
+
for (char *disk; (disk = strsep (&names, ",")) != NULL;) {
struct disklabel label;
char *colon, *name = NULL;