Re: [PATCH]: Re: [Nautilus-list] Re: must not ship Nautilus 1.0.4 until we fix FAM support



On 17Jun2001 01:41PM (+0200), Yoann Vandoorselaere wrote:
> 
> [Put Ramiro in CC for approval]
> 
> The problem was the wrong assumption that g_module_build_path() would 
> lookup the module for you. It does not.   
> 
> Can I commit ?
> 

Hi Yoann,

Your patch is not correct. g_module_build_path will result in a name
like "libfam.so", which should get looked up in LD_LIBRARY_PATH and
the system hardcoded library locations by g_module_open (). Your patch
will look up the library only in "/usr" and "/usr/lib", which is wrong
when you have fam built in a custom prefix (as for example I do), in
addition to unnecessarily scanning a bunch of huge directories.

Further, Nautilus is meant to work with a particular version of FAM,
which appears as libfam.so.0 on Linux, and your patch just checks for
"libfam" as a prefix, so it could find "libfam.so.1" which would not
work, or heck, even "libfamily.so".

A better fix might be to pass "libfam.so.0" instead of "fam" to
g_module_open, but only on systems that use this style of shared
library naming (I'm not sure what a good way to tell is).

Regards,

Maciej

> 
> Index: libnautilus-private/nautilus-monitor.c
> ===================================================================
> RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-monitor.c,v
> retrieving revision 1.11
> diff -u -p -r1.11 nautilus-monitor.c
> --- libnautilus-private/nautilus-monitor.c	2001/04/28 01:51:32	1.11
> +++ libnautilus-private/nautilus-monitor.c	2001/06/17 11:37:14
> @@ -23,6 +23,11 @@
>              Darin Adler <darin eazel com>
>  */
>  
> +#include <stdio.h>
> +#include <string.h>
> +#include <sys/types.h>
> +#include <dirent.h>
> +
>  #include <config.h>
>  #include "nautilus-monitor.h"
>  
> @@ -99,6 +104,75 @@ static void process_fam_notifications (g
>  				       int               fd,
>  				       GdkInputCondition condition);
>  
> +/*
> + * return a filename generated from 'dirname' & 'file'.
> + */
> +static char *
> +generate_filename (const char *dirname, const char *file) 
> +{
> +        int len;
> +        char *filename;
> +
> +        len = strlen(dirname) + strlen(file) + 2;
> +        
> +        filename = malloc (len);
> +        if ( ! filename ) {
> +                g_error ("memory exhausted.\n");
> +                return NULL;
> +        }
> +        
> +        sprintf (filename, "%s/%s", dirname, file);
> +
> +        return filename;
> +}
> +
> +static char *
> +lookup_fam_library_in_directory (const char *directory) 
> +{
> +        int ret;
> +        DIR *dir;
> +        struct dirent *d;
> +        char *filename = NULL;
> +        
> +        dir = opendir (directory);
> +        if ( ! dir ) {
> +                g_warning ("couldn't open %s directory.\n", directory);
> +                return NULL;
> +        }
> +        
> +        while ( (d = readdir (dir) ) ) {
> +                
> +                ret = strncmp (d->d_name, "libfam", 6);
> +                if ( ret == 0 ) {
> +                        filename = generate_filename (directory, d->d_name);
> +                        break;
> +                }
> +        }
> +
> +        closedir (dir);
> +
> +        return filename;
> +}
> +
> +
> +static char *
> +lookup_fam_library_path (void) 
> +{
> +        int i;
> +        char *filename = NULL;
> +        const char *directory[] = { "/usr/lib", "/usr/local/lib", NULL };
> +
> +        for ( i = 0; directory[i] != NULL; i++ ) {
> +                
> +                filename = lookup_fam_library_in_directory (directory[i]);
> +                if ( filename )
> +                        break;
> +        }
> +        
> +        return filename;
> +}
> +
> +
>  /* singleton object, instantiate and connect if it doesn't already exist */
>  static FAMConnection *
>  get_fam_connection (void)
> @@ -119,10 +193,14 @@ get_fam_connection (void)
>  	} else {
>                  tried_connection = TRUE;
>  #ifdef USE_FAM_AS_MODULE
> -		path = g_module_build_path (NULL, "fam");
> +		path = lookup_fam_library_path ();
> +                if ( ! path )
> +                        return NULL;
> +                
>  		module = g_module_open (path, 0);
> -		g_free (path);
> -		if (module == NULL) {
> +		free (path);
> +
> +                if (module == NULL) {
>  			return NULL;
>  		}
>  		for (i = 0; i < EEL_N_ELEMENTS (fam_symbols); i++) {
> 
> 
> -- 
> Yoann Vandoorselaere | Unix IS user friendly. It's just selective about who its
> MandrakeSoft         | friends are.
> 
> 
> 
> 
> 
> 
> 
> _______________________________________________
> Nautilus-list mailing list
> Nautilus-list lists eazel com
> http://lists.eazel.com/mailman/listinfo/nautilus-list




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