$NetBSD: patch-aa,v 1.5 2006/03/24 19:05:31 joerg Exp $ --- GWorkspace/Desktop/GWDesktopManager.m.orig 2005-04-01 09:43:39.000000000 +1000 +++ GWorkspace/Desktop/GWDesktopManager.m @@ -31,6 +31,14 @@ #include "GWorkspace.h" #include "GWViewersManager.h" #include "TShelf/TShelfWin.h" +#include +#include + +#if defined(__DragonFly__) +#include +#elif (defined(BSD) && BSD >= 199306) +#include +#endif #define RESV_MARGIN 10 @@ -748,9 +756,39 @@ static GWDesktopManager *desktopManager } if (removables == nil) { +#if (defined(BSD) && BSD >= 199306) + removables = [NSArray arrayWithObjects: @"/mnt", nil]; +#else removables = [NSArray arrayWithObjects: @"/mnt/floppy", @"/mnt/cdrom", nil]; +#endif } +#if (defined(BSD) && BSD >= 199306) +#if defined(__DragonFly__) + struct statfs *mntbuf; +#else + struct statvfs *mntbuf; +#endif + int mntsize = getmntinfo(&mntbuf, MNT_NOWAIT); + + for (i = 0; i < mntsize; i++) { + if (strcmp(mntbuf[i].f_mntfromname, [fullPath cString]) == 0 || + strcmp(mntbuf[i].f_mntonname, [fullPath cString]) == 0) { + *removableFlag = [removables containsObject: + [NSString stringWithCString: mntbuf[i].f_mntonname]]; +#if defined(__DragonFly__) + *writableFlag = ( mntbuf[i].f_flags & MNT_RDONLY ) ? NO : YES; +#else + *writableFlag = ( mntbuf[i].f_flag & MNT_RDONLY ) ? NO : YES; +#endif + *unmountableFlag = YES; + *fileSystemType = [NSString stringWithCString: mntbuf[i].f_fstypename]; + *description = *fileSystemType; + + return YES; + } + } +#else /* !BSD */ mtab = [NSString stringWithContentsOfFile: mtabpath]; mounts = [mtab componentsSeparatedByString: @"\n"]; @@ -782,6 +820,7 @@ static GWDesktopManager *desktopManager } } } +#endif return NO; } @@ -801,11 +840,31 @@ static GWDesktopManager *desktopManager } if (reserved == nil) { +#if (defined(BSD) && BSD >= 199306) + reserved = [NSArray arrayWithObjects: @"procfs", @"kernfs", nil]; +#else reserved = [NSArray arrayWithObjects: @"proc", @"devpts", @"shm", @"usbdevfs", @"devpts", @"sysfs", @"tmpfs", nil]; +#endif } +#if (defined(BSD) && BSD >= 199306) + names = [NSMutableArray array]; +#if defined(__DragonFly__) + struct statfs *mntbuf; +#else + struct statvfs *mntbuf; +#endif + int mntsize = getmntinfo(&mntbuf, MNT_NOWAIT); + + for (i = 0; i < mntsize; i++) { + if ([reserved containsObject: [NSString stringWithCString: + mntbuf[i].f_fstypename]] == NO) { + [names addObject: [NSString stringWithCString: mntbuf[i].f_mntonname]]; + } + } +#else mtab = [NSString stringWithContentsOfFile: mtabpath]; mounts = [mtab componentsSeparatedByString: @"\n"]; names = [NSMutableArray array]; @@ -825,6 +884,7 @@ static GWDesktopManager *desktopManager } } } +#endif return names; }