diff options
author | Marcus Meissner <marcus@jet.franken.de> | 2006-09-09 13:42:21 +0000 |
---|---|---|
committer | Marcus Meissner <marcus@jet.franken.de> | 2006-09-09 13:42:21 +0000 |
commit | 146a98d77d5a88777ad6207d810380b8dc708e6a (patch) | |
tree | 67d8748c1afed232bcbd85d656a8ff3d38374761 /libgphoto2_port/disk | |
parent | a9d4ce4daf511c307c2d6b7b83168a1a6921028a (diff) | |
download | libgphoto2-146a98d77d5a88777ad6207d810380b8dc708e6a.tar.gz |
added solaris mnttab handling (untested)
git-svn-id: https://svn.code.sf.net/p/gphoto/code/trunk/libgphoto2@9155 67ed7778-7388-44ab-90cf-0a291f65f57c
Diffstat (limited to 'libgphoto2_port/disk')
-rw-r--r-- | libgphoto2_port/disk/disk.c | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/libgphoto2_port/disk/disk.c b/libgphoto2_port/disk/disk.c index 7c0cf25db..8484b6e3b 100644 --- a/libgphoto2_port/disk/disk.c +++ b/libgphoto2_port/disk/disk.c @@ -36,6 +36,20 @@ #ifdef HAVE_MNTENT_H # include <mntent.h> #endif +#ifdef HAVE_SYS_MNTENT_H +# include <sys/mntent.h> +#endif +#ifdef HAVE_SYS_MNTTAB_H +# include <sys/mnttab.h> +#endif + +/* on Solaris */ +#ifndef HAVE_SETMNTENT +#define setmntent(f,m) fopen(f,m) +#endif +#ifndef HAVE_ENDMNTENT +#define endmntent(f) close(f) +#endif #ifdef HAVE_HAL #include <hal/libhal.h> @@ -232,6 +246,62 @@ gp_port_library_list (GPPortInfoList *list) } endmntent(mnt); } +# else +# ifdef HAVE_MNTTAB + FILE *mnt; + struct mnttab mnttab; + char path[1024]; + struct stat stbuf; + + info.type = GP_PORT_DISK; + + mnt = fopen ("/etc/fstab", "r"); + if (mnt) { + while (! getmntent (mnt, &mntent)) { + /* detect floppies so we don't access them with the stat() below */ + if ( (NULL != strstr(mnttab.mnt_special,"fd")) || + (NULL != strstr(mnttab.mnt_special,"floppy")) + ) + continue; + + snprintf (path, sizeof(path), "%s/DCIM", mnttab.mnt_mountp); + if (-1 == stat(path, &stbuf)) { + snprintf (path, sizeof(path), "%s/dcim", mnttab.mnt_mountp); + if (-1 == stat(path, &stbuf)) + continue; + } + snprintf (info.name, sizeof(info.name), _("Media '%s'"), mntent.mnt_special), + snprintf (info.path, sizeof(info.path), "disk:%s", mntent.mnt_mountp); + if (gp_port_info_list_lookup_path (list, info.path) >= GP_OK) + continue; + CHECK (gp_port_info_list_append (list, info)); + } + fclose(mnt); + } + mnt = fopen ("/etc/mtab", "r"); + if (mnt) { + while (! getmntent (mnt, &mntent)) { + /* detect floppies so we don't access them with the stat() below */ + if ( (NULL != strstr(mnttab.mnt_special,"fd")) || + (NULL != strstr(mnttab.mnt_special,"floppy")) + ) + continue; + + snprintf (path, sizeof(path), "%s/DCIM", mnttab.mnt_mountp); + if (-1 == stat(path, &stbuf)) { + snprintf (path, sizeof(path), "%s/dcim", mnttab.mnt_mountp); + if (-1 == stat(path, &stbuf)) + continue; + } + snprintf (info.name, sizeof(info.name), _("Media '%s'"), mntent.mnt_special), + snprintf (info.path, sizeof(info.path), "disk:%s", mntent.mnt_mountp); + if (gp_port_info_list_lookup_path (list, info.path) >= GP_OK) + continue; + CHECK (gp_port_info_list_append (list, info)); + } + fclose(mnt); + } +# endif # endif #endif /* generic disk:/xxx/ matcher */ |