Hi folks,
after swapping my sata cables and fixing the fstab, the /dev/sda* mounted
as /dev/sdb* (and so on..) got me all confused and made me think: heck
cfdisk is such a nice tool to get an overview of my partitions but it
really would be great if it did display the mount point for each partition.
Well, now it does ;)
regards marcel
--
<div id="signature">
"Obstacles are those frightful things you see when you take your eyes
off your goal."
-- Henry
Ford (1863-1947)
Change the world! Vote revolution: http://hfopi.org/vote-future
</div>
--- fdisk/cfdisk.c.orig 2008-05-29 01:01:02.000000000 +0200
+++ fdisk/cfdisk.c 2008-06-29 23:33:15.000000000 +0200
@@ -53,6 +53,8 @@
* ext3 and ReiserFS recognition.
* Sun Oct 12 17:43:43 CEST 2003 <flavio.stanchina@xxxxxx>
* JFS recognition; ReiserFS label recognition.
+ * Sun Jun 29 22:30:56 CEST 2008 <mpartap@xxxxxxx>
+ * Show mount point for mounted partitions
*
****************************************************************************/
@@ -78,6 +80,7 @@
#include <string.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
+#include <mntent.h>
#include "nls.h"
#include "blkdev.h"
@@ -289,6 +292,8 @@
char ostype[OSTYPESZ+1];
#define FSTYPESZ 8
char fstype[FSTYPESZ+1];
+#define MNTPTHSZ 16
+ char mntpath[MNTPTHSZ+1];
} partition_info;
char *disk_device = DEFAULT_DEVICE;
@@ -327,10 +332,11 @@
int COMMAND_LINE_Y = 21;
/* X coordinates */
-int NAME_START = 4;
-int FLAGS_START = 16;
-int PTYPE_START = 28;
-int FSTYPE_START = 38;
+int NAME_START = 2;
+int MNTPATH_START = 8;
+int FLAGS_START = 22;
+int PTYPE_START = 30;
+int FSTYPE_START = 40;
int LABEL_START = 54;
int SIZE_START = 68;
int COMMAND_LINE_X = 5;
@@ -737,6 +743,28 @@
}
static void
+get_mount_point(int i) {
+ FILE *mtab;
+ struct mntent *entry;
+#define MAXDEVSZ 32
+ char devname[MAXDEVSZ+1];
+ char *mntpoint = NULL;
+
+ int l = strlen(disk_device);
+ int digitend = isdigit(disk_device[l-1]);
+ snprintf(devname, MAXDEVSZ, "%s%s%d", disk_device, (digitend ? "p" : "") , p_info[i].num+1);
+
+ if ((mtab = setmntent(_PATH_MNTTAB, "r")) != NULL)
+ while ((entry = getmntent(mtab)) != NULL)
+ if (strcmp(devname, entry->mnt_fsname) == 0)
+ if (strcmp(entry->mnt_dir, "none") == 0)
+ strncpy(p_info[i].mntpath, "(act. swap)", MNTPTHSZ);
+ else
+ strncpy(p_info[i].mntpath, entry->mnt_dir, MNTPTHSZ);
+ endmntent(mtab);
+}
+
+static void
check_part_info(void) {
int i, pri = 0, log = 0;
@@ -845,6 +873,7 @@
p_info[i].volume_label[0] = 0;
p_info[i].fstype[0] = 0;
p_info[i].ostype[0] = 0;
+ p_info[i].mntpath[0] = 0;
num_parts++;
}
@@ -988,6 +1017,7 @@
ext_info.volume_label[0] = 0;
ext_info.fstype[0] = 0;
ext_info.ostype[0] = 0;
+ ext_info.mntpath[0] = 0;
return 0;
} else {
return -1; /* explicit extended logical */
@@ -1046,12 +1076,14 @@
p_info[i].volume_label[0] = 0;
p_info[i].fstype[0] = 0;
p_info[i].ostype[0] = 0;
+ p_info[i].mntpath[0] = 0;
if (want_label) {
if (may_have_dos_label(id))
get_dos_label(i);
else if (id == LINUX)
get_linux_label(i);
}
+ get_mount_point(i);
check_part_info();
@@ -2549,6 +2581,7 @@
mvprintw(y, NAME_START,
"%s%s%d", dbn, (digit_last ? "p" : ""),
p_info[i].num+1);
+ mvprintw(y, MNTPATH_START, "%s", p_info[i].mntpath);
if (p_info[i].flags) {
if (p_info[i].flags == ACTIVE_FLAG)
mvaddstr(y, FLAGS_START, _("Boot"));
@@ -2586,7 +2619,7 @@
if (p_info[i].volume_label[0]) {
int l = strlen(p_info[i].volume_label);
- int s = SIZE_START-5-l;
+ int s = SIZE_START-2-l;
mvprintw(y, (s > LABEL_START) ? LABEL_START : s,
" [%s] ", p_info[i].volume_label);
}
@@ -2610,6 +2643,7 @@
init_const(void) {
if (!defined) {
NAME_START = (((float)NAME_START)/COLUMNS)*COLS;
+ MNTPATH_START = (((float)MNTPATH_START)/COLUMNS)*COLS;
FLAGS_START = (((float)FLAGS_START)/COLUMNS)*COLS;
PTYPE_START = (((float)PTYPE_START)/COLUMNS)*COLS;
FSTYPE_START = (((float)FSTYPE_START)/COLUMNS)*COLS;
@@ -2670,6 +2704,7 @@
mvaddstr(HEADER_START+4, (COLS-strlen(line))/2, line);
mvaddstr(DISK_TABLE_START, NAME_START, _("Name"));
+ mvaddstr(DISK_TABLE_START, MNTPATH_START, _("Mount Point"));
mvaddstr(DISK_TABLE_START, FLAGS_START, _("Flags"));
mvaddstr(DISK_TABLE_START, PTYPE_START-1, _("Part Type"));
mvaddstr(DISK_TABLE_START, FSTYPE_START, _("FS Type"));