[Ocfs2-tools-commits] manish commits r670 -
trunk/ocfs2console/ocfs2interface
svn-commits at oss.oracle.com
svn-commits at oss.oracle.com
Fri Mar 18 00:06:12 CST 2005
Author: manish
Date: 2005-03-18 00:06:10 -0600 (Fri, 18 Mar 2005)
New Revision: 670
Modified:
trunk/ocfs2console/ocfs2interface/format.py
trunk/ocfs2console/ocfs2interface/main.py
trunk/ocfs2console/ocfs2interface/ocfs2module.c
trunk/ocfs2console/ocfs2interface/ocfsplist.c
trunk/ocfs2console/ocfs2interface/ocfsplist.h
Log:
Pass the fstype to the partition list function
Modified: trunk/ocfs2console/ocfs2interface/format.py
===================================================================
--- trunk/ocfs2console/ocfs2interface/format.py 2005-03-18 06:01:55 UTC (rev 669)
+++ trunk/ocfs2console/ocfs2interface/format.py 2005-03-18 06:06:10 UTC (rev 670)
@@ -146,7 +146,7 @@
def format_partition(parent, device):
partitions = []
- def add_partition(device):
+ def add_partition(device, fstype):
partitions.append(device)
ocfs2.partition_list(add_partition, unmounted=True)
Modified: trunk/ocfs2console/ocfs2interface/main.py
===================================================================
--- trunk/ocfs2console/ocfs2interface/main.py 2005-03-18 06:01:55 UTC (rev 669)
+++ trunk/ocfs2console/ocfs2interface/main.py 2005-03-18 06:06:10 UTC (rev 670)
@@ -125,12 +125,12 @@
store.set_sort_column_id(COLUMN_DEVICE, gtk.SORT_ASCENDING)
ocfs2.partition_list(self.add_partition, data=old_device,
- filter=filter, type='ocfs2', async=True)
+ filter=filter, fstype='ocfs2', async=True)
if len(store) and not self.selected:
self.sel.select_iter(store.get_iter_first())
- def add_partition(self, device, mountpoint, old_device):
+ def add_partition(self, device, mountpoint, fstype, old_device):
iter = self.store.append((device, mountpoint))
if device == old_device:
Modified: trunk/ocfs2console/ocfs2interface/ocfs2module.c
===================================================================
--- trunk/ocfs2console/ocfs2interface/ocfs2module.c 2005-03-18 06:01:55 UTC (rev 669)
+++ trunk/ocfs2console/ocfs2interface/ocfs2module.c 2005-03-18 06:06:10 UTC (rev 670)
@@ -51,7 +51,8 @@
{
ProxyData *data = pdata;
- PyObject_CallFunction (data->func, "ss", info->device, info->mountpoint);
+ PyObject_CallFunction (data->func, "sss",
+ info->device, info->mountpoint, info->fstype);
}
static void
@@ -60,8 +61,9 @@
{
ProxyData *data = pdata;
- PyObject_CallFunction (data->func, "ssO",
- info->device, info->mountpoint, data->data);
+ PyObject_CallFunction (data->func, "sssO",
+ info->device, info->mountpoint, info->fstype,
+ data->data);
}
static void
@@ -70,7 +72,7 @@
{
ProxyData *data = pdata;
- PyObject_CallFunction (data->func, "s", info->device);
+ PyObject_CallFunction (data->func, "ss", info->device, info->fstype);
}
static void
@@ -79,7 +81,8 @@
{
ProxyData *data = pdata;
- PyObject_CallFunction (data->func, "sO", info->device, data->data);
+ PyObject_CallFunction (data->func, "ssO", info->device, info->fstype,
+ data->data);
}
@@ -91,19 +94,19 @@
ProxyData proxy_data;
OcfsPartitionListFunc func;
PyObject *py_func, *py_data = NULL;
- gchar *filter = NULL, *type = NULL;
+ gchar *filter = NULL, *fstype = NULL;
gboolean unmounted = FALSE, async = FALSE;
static gchar *kwlist[] = {
"callback", "data",
- "filter", "type", "unmounted", "async",
+ "filter", "fstype", "unmounted", "async",
NULL
};
if (!PyArg_ParseTupleAndKeywords (args, kwargs,
"O|Ossii:partition_list", kwlist,
&py_func, &py_data,
- &filter, &type, &unmounted, &async))
+ &filter, &fstype, &unmounted, &async))
return NULL;
if (!PyCallable_Check (py_func))
@@ -131,7 +134,7 @@
func = proxy_partition_func;
}
- ocfs_partition_list (func, &proxy_data, filter, type, unmounted, async);
+ ocfs_partition_list (func, &proxy_data, filter, fstype, unmounted, async);
Py_INCREF (Py_None);
return Py_None;
Modified: trunk/ocfs2console/ocfs2interface/ocfsplist.c
===================================================================
--- trunk/ocfs2console/ocfs2interface/ocfsplist.c 2005-03-18 06:01:55 UTC (rev 669)
+++ trunk/ocfs2console/ocfs2interface/ocfsplist.c 2005-03-18 06:06:10 UTC (rev 670)
@@ -1,9 +1,9 @@
/*
* ocfsplist.c
*
- * Create a list of valid partitions
+ * Walk the partition list on a system
*
- * Copyright (C) 2002 Oracle Corporation. All rights reserved.
+ * Copyright (C) 2002, 2005 Oracle Corporation. All rights reserved.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
@@ -23,7 +23,6 @@
* Author: Manish Singh
*/
-#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -53,7 +52,7 @@
gpointer data;
GPatternSpec *filter;
- const gchar *type;
+ const gchar *fstype;
gboolean unmounted;
gboolean async;
@@ -64,15 +63,15 @@
};
-static gboolean type_check (const gchar *device,
- WalkData *wdata);
-static gboolean valid_device (const gchar *device,
- WalkData *wdata);
-static void partition_info_fill (GHashTable *info,
- gboolean async);
-static gboolean partition_walk (gpointer key,
- gpointer value,
- gpointer user_data);
+static gchar *fstype_check (const gchar *device,
+ WalkData *wdata);
+static gchar *get_device_fstype (const gchar *device,
+ WalkData *wdata);
+static void partition_info_fill (GHashTable *info,
+ gboolean async);
+static gboolean partition_walk (gpointer key,
+ gpointer value,
+ gpointer user_data);
static inline void
@@ -89,16 +88,13 @@
}
}
-static gboolean
-type_check (const gchar *device,
+static gchar *
+fstype_check (const gchar *device,
WalkData *wdata)
{
- blkid_dev dev;
- gboolean found = FALSE;
+ blkid_dev dev;
+ gchar *fstype = NULL;
- if (wdata->type == NULL)
- return TRUE;
-
dev = blkid_get_dev(wdata->cache, device, BLKID_DEV_NORMAL);
if (dev)
@@ -110,22 +106,29 @@
while (blkid_tag_next (iter, &type, &value) == 0)
{
- if (!strcmp (type, "TYPE") && !strcmp (value, wdata->type))
+ if (strcmp (type, "TYPE") == 0)
{
- found = TRUE;
- break;
+ if ((wdata->fstype == NULL) ||
+ (strcmp (value, wdata->fstype) == 0))
+ {
+ fstype = g_strdup (value);
+ break;
+ }
}
}
blkid_tag_iterate_end (iter);
}
- return found;
+ if (fstype == NULL && wdata->fstype == NULL)
+ fstype = g_strdup ("unknown");
+
+ return fstype;
}
-static gboolean
-valid_device (const gchar *device,
- WalkData *wdata)
+static gchar *
+get_device_fstype (const gchar *device,
+ WalkData *wdata)
{
gboolean is_bad = FALSE;
struct stat sbuf;
@@ -134,17 +137,17 @@
gint i, fd;
if (wdata->filter && !g_pattern_match_string (wdata->filter, device))
- return FALSE;
+ return NULL;
if ((stat (device, &sbuf) != 0) ||
(!S_ISBLK (sbuf.st_mode)) ||
((sbuf.st_mode & 0222) == 0))
- return FALSE;
+ return NULL;
if (strncmp ("/dev/hd", device, 7) == 0)
{
i = strlen (device) - 1;
- while (i > 5 && isdigit (device[i]))
+ while (i > 5 && g_ascii_isdigit (device[i]))
i--;
d = g_strndup (device + 5, i + 1);
@@ -162,15 +165,15 @@
fclose (f);
if (is_bad)
- return FALSE;
+ return NULL;
}
fd = open (device, O_RDWR);
if (fd == -1)
- return FALSE;
+ return NULL;
close (fd);
- return type_check (device, wdata);
+ return fstype_check (device, wdata);
}
static void
@@ -196,9 +199,9 @@
device = g_strconcat ("/dev/", name, NULL);
i = strlen (device) - 1;
- if (isdigit (device[i]))
+ if (g_ascii_isdigit (device[i]))
{
- while (i > 0 && isdigit (device[i]))
+ while (i > 0 && g_ascii_isdigit (device[i]))
i--;
p = g_strndup (device, i + 1);
@@ -256,7 +259,9 @@
{
device = list->data;
- if (valid_device (device, wdata))
+ info.fstype = get_device_fstype (device, wdata);
+
+ if (info.fstype)
{
info.device = device;
@@ -274,6 +279,8 @@
if (!wdata->unmounted || !info.mountpoint)
wdata->func (&info, wdata->data);
+
+ g_free (info.fstype);
}
last = list;
@@ -309,16 +316,19 @@
ocfs_partition_list (OcfsPartitionListFunc func,
gpointer data,
const gchar *filter,
- const gchar *type,
+ const gchar *fstype,
gboolean unmounted,
gboolean async)
{
GHashTable *info;
- WalkData wdata = { func, data, NULL, type, unmounted, async, 0 };
+ WalkData wdata = { func, data, NULL, fstype, unmounted, async, 0 };
if (blkid_get_cache (&wdata.cache, NULL) < 0)
return;
+ if (fstype && *fstype == '\0')
+ wdata.fstype = NULL;
+
if (filter && *filter)
wdata.filter = g_pattern_spec_new (filter);
@@ -354,10 +364,10 @@
OcfsPartitionInfo *info;
g_print ("All:\n");
- ocfs_partition_list (list_func, NULL, FALSE);
+ ocfs_partition_list (list_func, NULL, NULL, FALSE, FALSE);
g_print ("Unmounted:\n");
- plist = ocfs_partition_list (list_func, NULL, TRUE);
+ plist = ocfs_partition_list (list_func, NULL, NULL, TRUE, FALSE);
return 0;
}
Modified: trunk/ocfs2console/ocfs2interface/ocfsplist.h
===================================================================
--- trunk/ocfs2console/ocfs2interface/ocfsplist.h 2005-03-18 06:01:55 UTC (rev 669)
+++ trunk/ocfs2console/ocfs2interface/ocfsplist.h 2005-03-18 06:06:10 UTC (rev 670)
@@ -35,6 +35,7 @@
{
gchar *device;
gchar *mountpoint;
+ gchar *fstype;
};
@@ -45,7 +46,7 @@
void ocfs_partition_list (OcfsPartitionListFunc func,
gpointer data,
const gchar *filter,
- const gchar *type,
+ const gchar *fstype,
gboolean unmounted,
gboolean async);
More information about the Ocfs2-tools-commits
mailing list