#!/usr/bin/awk -f # # Oliver Fromme # # This script prints the list of current mounts, similar # to the "mount" command, but in a more concise, human- # readable tabular format. # # This is written for FreeBSD. It probably won't work # correctly on other systems because of the different # format of the mount output. # BEGIN{ i = 0; devmax = pntmax = 6; while (("/sbin/mount" | getline) > 0) { dev[i] = $1; if (length($1) > devmax) devmax = length($1); pnt[i] = $3; if (length($3) > pntmax) pntmax = length($3); sub(/\(/, "", $4); sub(/\)/, "", $NF); for (j = 4; j <= NF; j++) { x = $j; gsub(/[,:]/, "", x); # Make some flags shorter to save some space. sub(/synchronous/, "sync", x) if (x == "writes") break; # Omit "writes: x sync y async". else if (x == "soft-updates") x = "s-upds"; else if (x == "with") x = ""; # This is for "with quotas". if (x) if (x == "exported") opt[i] = opt[i] "-exp"; else if (opt[i]) opt[i] = opt[i] " " x; else opt[i] = x; } i++; } printf "%-*s %-*s %s\n", devmax, "Device", pntmax, "MntPnt", "Flags"; printf "%-*s %-*s %s\n", devmax, "======", pntmax, "======", "====="; for (j = 0; j < i; j++) printf "%-*s %-*s %s\n", devmax, dev[j], pntmax, pnt[j], opt[j]; }