[Ocfs2-tools-commits] manish commits r779 -
trunk/ocfs2console/ocfs2interface
svn-commits at oss.oracle.com
svn-commits at oss.oracle.com
Sat Apr 2 02:52:51 CST 2005
Author: manish
Date: 2005-04-02 02:52:49 -0600 (Sat, 02 Apr 2005)
New Revision: 779
Modified:
trunk/ocfs2console/ocfs2interface/ocfsplist.c
Log:
Attempt to filter out extended partitions or raw devices with partition
tables in the unmounted partition list
Modified: trunk/ocfs2console/ocfs2interface/ocfsplist.c
===================================================================
--- trunk/ocfs2console/ocfs2interface/ocfsplist.c 2005-04-02 06:44:58 UTC (rev 778)
+++ trunk/ocfs2console/ocfs2interface/ocfsplist.c 2005-04-02 08:52:49 UTC (rev 779)
@@ -40,6 +40,9 @@
#include "ocfsplist.h"
+#define RAW_PARTITION_FSTYPE "partition table"
+#define UNKNOWN_FSTYPE "unknown"
+
#define FILL_ASYNC_ITERATIONS 20
#define WALK_ASYNC_ITERATIONS 10
@@ -63,6 +66,8 @@
};
+static gboolean is_partition_data (const gchar *device);
+static gboolean used_unmounted (const gchar *fstype);
static gchar *fstype_check (const gchar *device,
WalkData *wdata);
static gchar *get_device_fstype (const gchar *device,
@@ -88,9 +93,36 @@
}
}
+static gboolean
+is_partition_data (const gchar *device)
+{
+ guchar buf[512];
+ gint fd;
+ gssize count;
+
+ fd = open (device, O_RDWR);
+ if (fd == -1)
+ return FALSE;
+
+ count = read (fd, buf, 512);
+ close (fd);
+
+ if (count != 512)
+ return FALSE;
+
+ return (buf[510] == 0x55) && (buf[511] == 0xaa);
+}
+
+static gboolean
+used_unmounted (const gchar *fstype)
+{
+ return (strcmp (fstype, "oracleasm") == 0) ||
+ (strcmp (fstype, RAW_PARTITION_FSTYPE) == 0);
+}
+
static gchar *
fstype_check (const gchar *device,
- WalkData *wdata)
+ WalkData *wdata)
{
blkid_dev dev;
gchar *fstype = NULL;
@@ -121,7 +153,12 @@
}
if (fstype == NULL && wdata->fstype == NULL)
- fstype = g_strdup ("unknown");
+ {
+ if (device && is_partition_data (device))
+ fstype = g_strdup (RAW_PARTITION_FSTYPE);
+ else
+ fstype = g_strdup (UNKNOWN_FSTYPE);
+ }
return fstype;
}
@@ -279,8 +316,7 @@
if (wdata->unmounted)
{
- if ((info.mountpoint == NULL) &&
- (strcmp (info.fstype, "oracleasm") != 0))
+ if ((info.mountpoint == NULL) && !used_unmounted (info.fstype))
wdata->func (&info, wdata->data);
}
else
@@ -366,14 +402,11 @@
main (int argc,
char **argv)
{
- GList *plist, *list;
- OcfsPartitionInfo *info;
-
g_print ("All:\n");
- ocfs_partition_list (list_func, NULL, NULL, FALSE, FALSE);
+ ocfs_partition_list (list_func, NULL, "ocfs2", NULL, FALSE, FALSE);
g_print ("Unmounted:\n");
- plist = ocfs_partition_list (list_func, NULL, NULL, TRUE, FALSE);
+ ocfs_partition_list (list_func, NULL, NULL, NULL, TRUE, FALSE);
return 0;
}
More information about the Ocfs2-tools-commits
mailing list