[maybe-ITP] gamin

Yaakov S (Cygwin Ports) yselkowitz@users.sourceforge.net
Thu Feb 2 02:22:00 GMT 2006


Lapo Luchini wrote:
> Yes, probably checking dinamically if the disk is FAT and ignore
> permission issues in that case is the best solution.

How about this; gamin_check_not_fat() can be an additional condition to 
the "wrong permissions" errors.

(Believe it or not, my C programming isn't that strong.  So please check 
this over, although this was mostly borrowed from Corinna.)

#ifdef __CYGWIN__

/* Code adapted from Corinna Vinschen's getvolumeinfo.c:
    http://www.cygwin.com/ml/cygwin/2006-01/msg00818.html */

#include <stdio.h>
#include <string.h>
#include <sys/cygwin.h>
#define _WIN32_WINNT 0x0500
#include <windows.h>

#ifndef FILE_READ_ONLY_VOLUME
#define FILE_READ_ONLY_VOLUME 0x80000
#endif

#endif  /* __CYGWIN__ */

/**
  * gamin_check_not_fat:
  *
  * On Cygwin, check if socket dir is on not a FAT drive.  This is
  * necessary because gamin_check_secure_{dir,path} check permissions,
  * and FAT drives do not have a permissions model; everything is 755.
  *
  * On other platforms, we assume that the socket dir is not on FAT.
  *
  * Returns 1 if NOT on a FAT drive, 0 if on FAT, -1 in case of error.
  */
static int
gamin_check_not_fat (void)
{
#ifdef __CYGWIN__
   const char *cygpath;
   char winpath[256];
   char rootdir[256];
   char volname[256];
   char fsname[256];
   DWORD sernum = 0;
   DWORD maxlen = 0;
   DWORD flags = 0;

   cygpath = gamin_get_socket_dir();

   cygwin_conv_to_full_win32_path (cygpath, winpath);
   if (!GetVolumePathName(winpath, rootdir, 256))
     {
       fprintf (stderr, "GetVolumePathName: %d\n", GetLastError ());
       return -1;
     }
   if (!GetVolumeInformation (rootdir, volname, 256, &sernum,
                              &maxlen, &flags, fsname, 256))
     {
       fprintf (stderr, "GetVolumeInformation: %d\n", GetLastError ());
       return -1;
     }
   if (strcmp(fsname, "FAT") == 0)
     {
       return 0;
     }
#endif  /* __CYGWIN__ */
   return 1;
}

> If you mean "no one else will do that for you" I do perfectly agree, my
> message was maybe a bit unclear about that, but I wasn't asking anyone
> actually ;-)

Exactly.

> Alex already ported the patches to 0.1.7 but it seems that 0.1.7 breaks
> polling itself, probably because there are no more linuxes without
> dnotify or inotify around, so the author didn't notice. We are
> investigating this problem, anyway.

And it looks like FreeBSD has yet to figure it out themselves either, so 
at least we have good company. :-)


Yaakov



More information about the Cygwin-apps mailing list