Bug #136521



Looks like people post to bugzilla and to this list so I'm posting
info on bug #136521 below, portability fixes for AIX, HP-UX, IRIX, and
Tru64 UNIX:
  http://bugzilla.gnome.org/show_bug.cgi?id=136521

1. [libnautilus-private/nautilus-file-attributes.h,
   src/nautilus-information-panel.c,
   components/image_properties/nautilus-image-properties-view.c]
   IBM C compiler doesn't like a trailing comma after the last
   enum constant
2. [libnautilus-private/nautilus-volume-monitor.c, configure.in]
   Add getfsstat() support on Tru64 UNIX (I think I stole the
   configure.in changes from fileutils). Add support (or
   better support) for HP-UX, IRIX, and AIX.

   BTW, I think the way nautilus-volume-monitor.c handles AIX
   is wrong. Reading /etc/filesystems is like reading
   /etc/fstab. If a user mounts a volume on a running system,
   you won't see it in the list. I don't have time to fix this
   now though. coreutils already has code to read a list of
   mounted volumes on AIX so it shouldn't take too much work
   to get the correct solution implemented.

-- 
albert chin (china thewrittenword com)

-- snip snip
--- libnautilus-private/nautilus-file-attributes.h.orig	2003-04-02 05:50:53.000000000 -0600
+++ libnautilus-private/nautilus-file-attributes.h	2004-03-06 21:48:47.433914000 -0600
@@ -41,7 +41,7 @@
 	NAUTILUS_FILE_ATTRIBUTE_METADATA = 1 << 8,
 	NAUTILUS_FILE_ATTRIBUTE_MIME_TYPE = 1 << 9,
 	NAUTILUS_FILE_ATTRIBUTE_TOP_LEFT_TEXT = 1 << 10,
-	NAUTILUS_FILE_ATTRIBUTE_DISPLAY_NAME = 1 << 11,
+	NAUTILUS_FILE_ATTRIBUTE_DISPLAY_NAME = 1 << 11
 } NautilusFileAttributes;
 
 #endif /* NAUTILUS_FILE_ATTRIBUTES_H */
--- libnautilus-private/nautilus-volume-monitor.c.orig	1997-01-03 21:26:43.000000000 -0600
+++ libnautilus-private/nautilus-volume-monitor.c	2004-03-06 21:48:48.136300000 -0600
@@ -66,36 +66,37 @@
 #include <fstab.h>
 #endif
 
-#if defined(HAVE_SYS_MNTCTL_H) && defined(HAVE_SYS_VMOUNT_H) && defined(HAVE_SYS_VFS_H)
-
+#ifdef HAVE_FSHELP_H			/* AIX */
 #include <sys/mntctl.h>
 #include <sys/vfs.h>
 #include <sys/vmount.h>
 #include <fshelp.h>
-
-#define AIX_MNT 1
-
-#endif /* HAVE_SYS_MNTCTL_H && HAVE_SYS_VMOUNT_H && HAVE_SYS_VFS_H*/
+#endif
 
 #ifdef HAVE_MNTENT_H
 #include <mntent.h>
-#ifndef __CYGWIN__
-#define MOUNT_TABLE_PATH _PATH_MNTTAB
+#ifdef __CYGWIN__
+#define MOUNT_TABLE_PATH MOUNTED
 #else
+#if defined(HAVE_FSHELP_H)		/* AIX */
+#define MOUNT_TABLE_PATH MNTTAB
+#elif defined(_PATH_MNTTAB)
+#define MOUNT_TABLE_PATH _PATH_MNTTAB
+#elif defined(MNT_MNTTAB)		/* HP-UX */
+#define MOUNT_TABLE_PATH MNT_MNTTAB
+#elif defined(MOUNTED)			/* IRIX */
 #define MOUNT_TABLE_PATH MOUNTED
 #endif
-#elif defined (HAVE_SYS_MNTTAB_H)
-#define SOLARIS_MNT 1
+#endif
+#elif defined(HAVE_SYS_MNTTAB_H)
 #include <sys/mnttab.h>
 #define MOUNT_TABLE_PATH "/etc/mnttab"
-#elif defined (AIX_MNT)
-#define MOUNT_TABLE_PATH "/etc/filesystems"
 #else
 /* FIXME: How does this help anything? */
 #define MOUNT_TABLE_PATH ""
 #endif
 
-#ifdef SOLARIS_MNT
+#ifdef HAVE_SYS_MNTTAB_H
 #define USE_VOLRMMOUNT 1
 #endif
 
@@ -117,6 +118,10 @@
 #include <sys/mount.h>
 #endif
 
+#if HAVE_SYS_FS_TYPES_H
+#include <sys/fs_types.h>
+#endif
+
 #ifndef MNTOPT_RO
 #define MNTOPT_RO "ro"
 #endif
@@ -164,16 +169,21 @@
 #ifdef HAVE_SYS_MNTTAB_H
 typedef struct mnttab MountTableEntry;
 #define MOUNT_TABLE_ENTRY_TYPE(ent) ((ent)->mnt_fstype)
-#elif defined (HAVE_GETMNTINFO)
+#elif defined (HAVE_GETFSSTAT) || defined (HAVE_GETMNTINFO)
 typedef struct statfs MountTableEntry;
+#if HAVE_STRUCT_FSSTAT_F_FSTYPENAME
 #define MOUNT_TABLE_ENTRY_TYPE(ent) ((ent)->f_fstypename)
-#elif defined(AIX_MNT)
+#else
+#define MOUNT_TABLE_ENTRY_TYPE(ent) mnt_names[(ent).f_type]
+#endif
+#elif HAVE_FSHELP_H
 typedef struct {
         char mnt_mount[PATH_MAX];
         char mnt_special[PATH_MAX];
         char mnt_fstype[16];
         char mnt_options[128];
 } MountTableEntry;
+#define MOUNT_TABLE_ENTRY_TYPE(ent) ((ent)->mnt_fstype)
 #else
 typedef struct mntent MountTableEntry;
 #define MOUNT_TABLE_ENTRY_TYPE(ent) ((ent)->mnt_type)
@@ -436,7 +446,7 @@
 	} else {
 		noauto_string = "/dev/fd";
 	}
-	mnttab_exists = g_file_test ("/etc/mnttab",
+	mnttab_exists = g_file_test (MOUNT_TABLE_PATH,
 				     G_FILE_TEST_EXISTS);
 }
 
@@ -584,7 +594,8 @@
 	return NULL;
 }
 
-#if defined (HAVE_GETMNTINFO) || defined (HAVE_MNTENT_H) || defined (SOLARIS_MNT)
+#if defined (HAVE_GETMNTINFO) || defined (HAVE_MNTENT_H) || \
+defined (HAVE_SYS_MNTTAB_H)
 
 static gboolean
 has_removable_mntent_options (MountTableEntry *ent)
@@ -599,7 +610,7 @@
 	}
 #endif
 
-#ifdef SOLARIS_MNT
+#ifdef HAVE_SYS_MNTTAB_H
 	if (eel_str_has_prefix (ent->mnt_special, "/vol/")) {
 		return TRUE;
 	}
@@ -610,7 +621,7 @@
 
 #endif
 
-#if defined(AIX_MNT)
+#ifdef HAVE_FSHELP_H
 
 /*
  * functions to parse /etc/filesystems
@@ -742,36 +753,60 @@
 	MountTableEntry *ent;
 	NautilusVolume *volume;
 	char * fs_opt;
-#if defined(HAVE_SYS_MNTTAB_H) || defined(AIX_MNT)
+#if defined(HAVE_SYS_MNTTAB_H) || defined(HAVE_FSHELP_H)
         MountTableEntry ent_storage;
 #endif
-#ifdef HAVE_GETMNTINFO
+#if defined(HAVE_GETFSSTAT) || defined(HAVE_GETMNTINFO)
 	int count, index;
 #endif
 	ent = NULL;
 	volume = NULL;
 	volumes = NULL;
 
-#ifdef HAVE_GETMNTINFO
-	count = getmntinfo (&ent, MNT_WAIT);
-	/* getmentinfo returns a pointer to static data. Do not free. */
+#if defined(HAVE_GETFSSTAT)
+	count = getfsstat ((MountTableEntry *)NULL, 0, MNT_NOWAIT);
+	if (count > 0) {
+		long bufsize;
+
+		bufsize = (1 + count) * sizeof (MountTableEntry);
+		ent = g_malloc (bufsize);
+		count = getfsstat (ent, bufsize, MNT_NOWAIT);
+
+		for (index = 0; index < count; index++) {
+			if (has_removable_mntent_options (&ent[index])) {
+				volume = create_volume (ent[index].f_mntfromname,
+				ent[index].f_mntonname);
+				volume->is_removable = TRUE;
+				volumes = finish_creating_volume_and_prepend
+					(monitor, volume,
+					MOUNT_TABLE_ENTRY_TYPE(ent[index]),
+					volumes);
+			}
+		}
+
+		g_free (ent);
+	}
+#elif defined(HAVE_GETMNTINFO)
+	count = getmntinfo (&ent, MNT_NOWAIT);
+	/* getmntinfo returns a pointer to static data. Do not free. */
 	for (index = 0; index < count; index++) {
 		if (has_removable_mntent_options (&ent[index])) {
 			volume = create_volume (ent[index].f_mntfromname,
 						ent[index].f_mntonname);
 			volume->is_removable = TRUE;
 			volumes = finish_creating_volume_and_prepend
-				(monitor, volume, ent[index].f_fstypename, volumes);
+				(monitor, volume,
+				MOUNT_TABLE_ENTRY_TYPE(ent[index]), volumes);
 		}
 	}
-#endif
-	
+#else
+
 	file = setmntent (MOUNT_TABLE_PATH, "r");
 	if (file == NULL) {
 		return NULL;
 	}
 	
-#if defined(AIX_MNT)
+#if defined(HAVE_FSHELP_H)
         ent = &ent_storage;
 	while (!aix_fs_get (file, ent)) {
 		if (strcmp ("cdrfs", ent->mnt_fstype) == 0) {
@@ -796,7 +831,8 @@
 		if (has_removable_mntent_options (ent)) {
 #if defined (HAVE_HASMNTOPT)
 
-			if (eel_strcmp("supermount", ent->mnt_type) == 0) {
+			if (eel_strcmp("supermount",
+				       MOUNT_TABLE_ENTRY_TYPE(ent)) == 0) {
 				fs_opt = eel_str_strip_substring_and_after (hasmntopt (ent, "dev="),
 									    ",");
 				volume = create_volume (fs_opt+strlen("dev="), ent->mnt_dir);
@@ -809,13 +845,15 @@
 			}
 #endif
 			volumes = finish_creating_volume_and_prepend
-				(monitor, volume, ent->mnt_type, volumes);
+				(monitor, volume,
+				 MOUNT_TABLE_ENTRY_TYPE(ent), volumes);
 		}
 	}
 #endif
 			
 	endmntent (file);
-	
+#endif
+
 #ifdef HAVE_CDDA
 	volume = create_volume (CD_AUDIO_PATH, CD_AUDIO_PATH);
 	volumes = finish_creating_volume_and_prepend (monitor, volume, "cdda", volumes);
@@ -844,20 +882,53 @@
       return result;
 }
 
-#ifndef SOLARIS_MNT
-
 static gboolean
 volume_is_removable (const NautilusVolume *volume)
 {
 	gboolean removable;
 	FILE *file;
      	MountTableEntry *ent;
-#ifdef HAVE_SYS_MNTTAB_H
-	MountTableEntry ent_storage;
+#if defined(HAVE_SYS_MNTTAB_H) || defined(HAVE_FSHELP_H)
+        MountTableEntry ent_storage;
+#endif
+#if defined(HAVE_GETFSSTAT) || defined(HAVE_GETMNTINFO)
+	int count, index;
 #endif
 
 	ent = NULL;
 
+#if defined(HAVE_GETFSSTAT)
+	count = getfsstat ((MountTableEntry *)NULL, 0, MNT_NOWAIT);
+	if (count > 0) {
+		long bufsize;
+
+		bufsize = (1 + count) * sizeof (MountTableEntry);
+		ent = g_malloc (bufsize);
+		count = getfsstat (ent, bufsize, MNT_NOWAIT);
+
+		for (index = 0; index < count; index++) {
+			if (has_removable_mntent_options (&ent[index])
+			    && strcmp (volume->device_path,
+			    ent[index].f_mntfromname) == 0) {
+				removable = TRUE;
+				break;
+			}
+		}	
+
+		g_free (ent);
+	}
+#elif defined(HAVE_GETMNTINFO)
+	count = getmntinfo (&ent, MNT_NOWAIT);
+	/* getmntinfo returns a pointer to static data. Do not free. */
+	for (index = 0; index < count; index++) {
+		if (has_removable_mntent_options (&ent[index])
+		    && strcmp (volume->device_path,
+		    ent[index].f_mntfromname) == 0)
+			removable = TRUE;
+			break;
+		}
+	}
+#else
 	file = setmntent (MOUNT_TABLE_PATH, "r");
 	if (file == NULL) {
 		return FALSE;
@@ -870,12 +941,23 @@
 	ent = &ent_storage;
 	while (!getmntent (file, ent)) {
 		if (strcmp (volume->device_path, ent->mnt_special) == 0) {
-   		 	if (eel_str_has_prefix (ent->mnt_special, noauto_string)) {
+   		 	if (eel_str_has_prefix (ent->mnt_special,
+			    noauto_string)) {
 				removable = TRUE;
 				break;
 			}
 		}	
 	}
+#elif defined (HAVE_FSHELP_H)
+        while (!aix_fs_get (file, ent)) {
+		if ((strcmp (volume->device_path, ent->mnt_special) == 0
+		     || entry_is_supermounted_volume (ent, volume))
+		    && strcmp (volume->mount_path, ent->mnt_mount) == 0
+		    && has_removable_mntent_options (ent)) {
+			removable = TRUE;
+			break;
+		}	
+	}
 #elif defined (HAVE_MNTENT_H)
 	while ((ent = getmntent (file)) != NULL) {
 		if ((strcmp (volume->device_path, ent->mnt_fsname) == 0
@@ -889,11 +971,11 @@
 #endif
 	
 	endmntent (file);
+#endif
+
 	return removable;
 }
 
-#endif /* !SOLARIS_MNT */
-
 char *
 nautilus_volume_get_name (const NautilusVolume *volume)
 {
@@ -1234,7 +1316,7 @@
 
 
 
-#ifdef AIX_MNT
+#ifdef HAVE_FSHELP_H
  
 static GList *
 get_mount_list (NautilusVolumeMonitor *monitor)
@@ -1313,7 +1395,7 @@
         return volumes;
 }
 
-#elif defined(SOLARIS_MNT)
+#elif defined(HAVE_SYS_MNTTAB_H)
 
 static GList *
 get_mount_list (NautilusVolumeMonitor *monitor) 
@@ -1342,7 +1424,43 @@
         return volumes;
 }
 
-#else /* !AIX_MNT && !SOLARIS_MNT */
+#elif defined(HAVE_GETFSSTAT)
+
+static GList *
+get_mount_list (NautilusVolumeMonitor *monitor) 
+{
+        GList *volumes;
+        MountTableEntry *ent;
+        NautilusVolume *volume;
+	int count;
+
+	volumes = NULL;
+        
+	count = getfsstat ((MountTableEntry *)NULL, 0, MNT_NOWAIT);
+	if (count > 0) {
+		long bufsize;
+		int index;
+
+		bufsize = (1 + count) * sizeof (MountTableEntry);
+		ent = g_malloc (bufsize);
+		count = getfsstat (ent, bufsize, MNT_NOWAIT);
+
+		for (index = 0; index < count; index++) {
+			volume = create_volume (ent[index].f_mntfromname,
+			       ent[index].f_mntonname);
+			volume->is_removable = has_removable_mntent_options
+					     (&ent[index]);
+                	volumes = finish_creating_volume_and_prepend
+				(monitor, volume,
+				mnt_names [ent[index].f_type],
+				volumes);
+		}
+	}
+
+        return volumes;
+}
+
+#else
 
 static gboolean
 option_list_has_option (const char *optlist,
@@ -1386,7 +1504,7 @@
 	volumes = NULL;
         
 	if (mnttab_exists) { 
-		file_name = "/etc/mnttab";
+		file_name = MOUNT_TABLE_PATH;
 		separator = "\t";
 	} else {
 		file_name = "/proc/mounts";
@@ -1396,7 +1514,7 @@
 	/* /proc/mounts mtime never changes, so stat /etc/mtab.
 	 * Isn't this lame?
 	 */
-	if (stat ("/etc/mtab", &sb) < 0) {
+	if (stat (file_name, &sb) < 0) {
 		g_warning ("Unable to stat %s: %s", file_name,
 			   g_strerror (errno));
 		return NULL;
@@ -1411,7 +1529,8 @@
 	if (fh == NULL) {
                 fh = fopen (file_name, "r");
                 if (fh == NULL) {
-                        g_warning ("Unable to open %s: %s", file_name, strerror (errno));
+                        g_warning ("Unable to open %s: %s", file_name,
+				   strerror (errno));
                         return NULL;
                 }
         } else {		
@@ -1423,13 +1542,15 @@
                         continue;
 		}
 
-                list = eel_string_list_new_from_tokens (line, separator, FALSE);
+                list = eel_string_list_new_from_tokens (line, separator,
+		       FALSE);
                 if (list == NULL) {
                         continue;
 		}
                 
                 /* The string list needs to have at least 3 items per line.
-                 * We need to find at least device path, mount path and file system type.
+                 * We need to find at least device path, mount path and file
+                 * system type.
                  */
                 if (eel_string_list_get_length (list) >= 3) {
                         device_path = eel_string_list_nth (list, 0);
@@ -1469,7 +1590,7 @@
         return copy_mount_list (volumes);
 }
 
-#endif /* !SOLARIS_MNT */
+#endif /* !HAVE_SYS_MNTTAB_H */
 
 
 static GList *
@@ -1564,7 +1685,7 @@
 static int
 get_cdrom_type (const char *vol_dev_path, int* fd)
 {
-#ifdef SOLARIS_MNT	
+#ifdef HAVE_SYS_MNTTAB_H	
 	GString *new_dev_path;
 	struct cdrom_tocentry entry;
 	struct cdrom_tochdr header;
@@ -1601,7 +1722,7 @@
 	}
 
 	return type;
-#elif defined(AIX_MNT)
+#elif defined(HAVE_FSHELP_H)
 	return CDS_NO_INFO;
 #else
 	*fd = open (vol_dev_path, O_RDONLY|O_NONBLOCK);
@@ -2160,7 +2281,7 @@
 	for (node = volume_list; node != NULL; node = node->next) {
 		volume = node->data;
 		
-#if !defined(SOLARIS_MNT) && !defined(AIX_MNT)
+#if !defined(HAVE_SYS_MNTTAB_H) && !defined(HAVE_FSHELP_H)
 		/* These are set up by get_current_mount_list for Solaris&AIX.*/
 		volume->is_removable = volume_is_removable (volume);
 #endif
--- src/nautilus-information-panel.c.orig	2003-04-16 09:14:59.000000000 -0500
+++ src/nautilus-information-panel.c	2004-03-06 21:48:47.562955000 -0600
@@ -144,7 +144,7 @@
 typedef enum {
 	NO_PART,
 	BACKGROUND_PART,
-	ICON_PART,
+	ICON_PART
 } InformationPanelPart;
 
 EEL_CLASS_BOILERPLATE (NautilusInformationPanel, nautilus_information_panel, EEL_TYPE_BACKGROUND_BOX)
--- components/image_properties/nautilus-image-properties-view.c.orig	2003-06-08 03:45:09.000000000 -0500
+++ components/image_properties/nautilus-image-properties-view.c	2004-03-06 21:48:47.927112000 -0600
@@ -45,7 +45,7 @@
 };
 
 enum {
-	PROP_URI,
+	PROP_URI
 };
 
 static GObjectClass *parent_class = NULL;
--- configure.in.orig	2004-02-02 18:15:16.000000000 -0600
+++ configure.in	2004-03-06 21:48:48.080786000 -0600
@@ -145,8 +146,47 @@
 dnl ==========================================================================
 
 AC_CHECK_FUNCS(setmntent endmntent hasmntopt getmntinfo)
-AC_CHECK_HEADERS(mntent.h sys/mnttab.h sys/vfstab.h sys/cdio.h sys/mount.h sys/mntctl.h sys/vfs.h sys/vmount.h fstab.h)
-			      
+AC_CHECK_HEADERS(mntent.h sys/param.h sys/ucred.h sys/fs_types.h \
+sys/mnttab.h sys/vfstab.h sys/cdio.h sys/mount.h sys/mntctl.h \
+sys/vfs.h sys/vmount.h fstab.h fshelp.h)
+getfsstat_includes="\
+$ac_includes_default
+#if HAVE_SYS_PARAM_H
+# include <sys/param.h> /* needed by powerpc-apple-darwin1.3.7 */
+#endif
+#if HAVE_SYS_UCRED_H
+# include <sys/ucred.h> /* needed by powerpc-apple-darwin1.3.7 */
+#endif
+#if HAVE_SYS_MOUNT_H
+# include <sys/mount.h>
+#endif
+#if HAVE_SYS_FS_TYPES_H
+# include <sys/fs_types.h> /* needed by powerpc-apple-darwin1.3.7 */
+#endif
+"
+AC_CHECK_MEMBERS([struct fsstat.f_fstypename],,,[$getfsstat_includes])
+AC_MSG_CHECKING([for getfsstat function])
+AC_CACHE_VAL(fu_cv_sys_mounted_getfsstat,
+[AC_TRY_LINK([
+#include <sys/types.h>
+#if HAVE_STRUCT_FSSTAT_F_FSTYPENAME
+# define FS_TYPE(Ent) ((Ent).f_fstypename)
+#else
+# define FS_TYPE(Ent) mnt_names[(Ent).f_type]
+#endif
+]$getfsstat_includes,
+[struct statfs *stats;
+ int numsys = getfsstat ((struct statfs *)0, 0L, MNT_WAIT);
+ char *t = FS_TYPE (*stats); ],
+  fu_cv_sys_mounted_getfsstat=yes,
+  fu_cv_sys_mounted_getfsstat=no)])
+AC_MSG_RESULT($fu_cv_sys_mounted_getfsstat)
+if test $fu_cv_sys_mounted_getfsstat = yes; then
+  ac_list_mounted_fs=found
+  AC_DEFINE(HAVE_GETFSSTAT, 1,
+            [Define if there is a function named getfsstat for reading the list of mounted filesystems. (Tru64 UNIX)])
+fi
+
 dnl ==========================================================================
 
 AC_CHECK_FUNCS(setenv unsetenv putenv)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]