diff options
author | Artem Kachitchkine <artem@aja.(none)> | 2006-08-02 12:09:15 -0700 |
---|---|---|
committer | Artem Kachitchkine <artem@aja.(none)> | 2006-08-02 12:09:15 -0700 |
commit | 60aba3087f6d4376961882f79f034fe7e3ba1cd2 (patch) | |
tree | 1a37070607be13e09b6feb19d5fa2a5dbee37e04 /tools/hal-storage-shared.c | |
parent | b412caf1175bf3fcea51ef1b5ed3db1e946bf0d8 (diff) | |
download | hal-60aba3087f6d4376961882f79f034fe7e3ba1cd2.tar.gz |
* configure.in: don't PKG_CHECK volume_id on Solaris
and check for asprintf()
* hald/property.c: C99 compilers do not support anonymous unions
* hald/util.h: redefine gcc macros if not using gcc
* libhal/libhal.c: C99 compilers do not support anonymous unions
* tools/hal-device: C99 compilers do not support anonymous unions,
handle no-asprintf() case, use "a ? a : b" instead of "a ?: b"
* tools/hal-storage-mount.c
tools/hal-storage-shared.c
tools/hal-system-power-pmu.c: added Solaris ifdefs
Diffstat (limited to 'tools/hal-storage-shared.c')
-rw-r--r-- | tools/hal-storage-shared.c | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/tools/hal-storage-shared.c b/tools/hal-storage-shared.c index ecd7dd3d..dced6639 100644 --- a/tools/hal-storage-shared.c +++ b/tools/hal-storage-shared.c @@ -38,6 +38,10 @@ #include <sys/mount.h> #include <limits.h> #include <pwd.h> +#elif sun +#include <fcntl.h> +#include <sys/mnttab.h> +#include <sys/vfstab.h> #else #include <mntent.h> #endif @@ -74,6 +78,9 @@ mtab_open (gpointer *handle) *handle = mtab; return TRUE; +#elif sun + *handle = fopen (MNTTAB, "r"); + return *handle != NULL; #else *handle = fopen ("/proc/mounts", "r"); return *handle != NULL; @@ -90,6 +97,10 @@ mtab_next (gpointer handle) return mtab->mounts[mtab->iter++].f_mntfromname; else return NULL; +#elif sun + static struct mnttab mnt; + + return getmntent (handle, &mnt) == 0 ? mnt.mnt_special : NULL; #else struct mntent *mnt; @@ -116,6 +127,9 @@ fstab_open (gpointer *handle) { #ifdef __FreeBSD__ return setfsent () == 1; +#elif sun + *handle = fopen (VFSTAB, "r"); + return *handle != NULL; #else *handle = fopen ("/etc/fstab", "r"); return *handle != NULL; @@ -136,6 +150,10 @@ fstab_next (gpointer handle, char **mount_point) } return fstab ? fstab->fs_spec : NULL; +#elif sun + static struct vfstab v; + + return getvfsent (handle, &v) == 0 ? v.vfs_special : NULL; #else struct mntent *mnt; @@ -161,6 +179,8 @@ fstab_close (gpointer handle) #ifdef __FreeBSD__ #define UMOUNT "/sbin/umount" +#elif sun +#define UMOUNT "/sbin/umount" #else #define UMOUNT "/bin/umount" #endif @@ -458,13 +478,17 @@ lock_hal_mtab (void) printf ("%d: XYA attempting to get lock on /media/.hal-mtab-lock\n", getpid ()); - lock_mtab_fd = open ("/media/.hal-mtab-lock", O_CREAT); + lock_mtab_fd = open ("/media/.hal-mtab-lock", O_CREAT | O_RDWR); if (lock_mtab_fd < 0) return FALSE; tryagain: +#if sun + if (lockf (lock_mtab_fd, F_LOCK, 0) != 0) { +#else if (flock (lock_mtab_fd, LOCK_EX) != 0) { +#endif if (errno == EINTR) goto tryagain; return FALSE; @@ -479,7 +503,11 @@ tryagain: void unlock_hal_mtab (void) { +#if sun + lockf (lock_mtab_fd, F_ULOCK, 0); +#else flock (lock_mtab_fd, LOCK_UN); +#endif close (lock_mtab_fd); lock_mtab_fd = -1; printf ("%d: XYA released lock on /media/.hal-mtab-lock\n", getpid ()); |