Index: src/manager.c =================================================================== --- src/manager.c (revision 1292) +++ src/manager.c (working copy) @@ -24,9 +24,12 @@ #include #include #include +#include #include #include #include +#include +#include #include @@ -1910,12 +1913,27 @@ MOUNT_UID = (1 << 15), MOUNT_UMASK = (1 << 16), MOUNT_UTF8 = (1 << 17), + MOUNT_LOCALE = (1 << 18), + MOUNT_LONGNAME = (1 << 19), }; static struct { const char *name; guint32 flag; } mount_options[] = { +#ifdef __FreeBSD__ + { "-D=", MOUNT_CODEPAGE }, /* vfat */ + { "-M=", MOUNT_DMASK }, /* vfat */ + { "-m=", MOUNT_FMASK }, /* vfat, ntfs */ + { "-L=", MOUNT_LOCALE }, /* vfat */ + { "-C=", MOUNT_IOCHARSET }, /* ntfs, iso9660 */ + { "noatime", MOUNT_NOATIME }, + { "noexec", MOUNT_NOEXEC }, + { "ro", MOUNT_READ_ONLY }, + { "longnames", MOUNT_LONGNAME }, /* vfat */ + { "sync", MOUNT_SYNC }, + { "-u=", MOUNT_UID }, /* vfat, ntfs */ +#else { "codepage=", MOUNT_CODEPAGE }, /* vfat */ { "data=", MOUNT_DATA }, /* ext3 */ { "dirsync", MOUNT_DIRSYNC }, @@ -1934,6 +1952,7 @@ { "uid=", MOUNT_UID }, /* vfat, ntfs, udf, iso9660 */ { "umask=", MOUNT_UMASK }, /* vfat, ntfs, udf */ { "utf8", MOUNT_UTF8 }, /* vfat, iso9660 */ +#endif }; @@ -2114,10 +2133,17 @@ g_slist_free_1 (l); } +#ifndef __FreeBSD__ if (opts & MOUNT_UID) { option = g_strdup_printf ("uid=%u", getuid ()); g_ptr_array_add (options, option); } +#else + if (opts & MOUNT_UID && (!strcmp (where, "vfat") || !strcmp (where, "ntfs"))) { + option = g_strdup_printf ("u=%u", getuid ()); + g_ptr_array_add (options, option); + } +#endif return TRUE; } @@ -2167,7 +2193,7 @@ return retval; } else { - char *mount_point, *fstype, *drive, **moptions, fmask_opt[12], *charset_opt = NULL; + char *mount_point, *fstype, *drive, **moptions, fmask_opt[12], *charset_opt = NULL, *locale_opt = NULL; DBusMessage *dmesg, *reply; gboolean freev = FALSE; GPtrArray *options; @@ -2247,21 +2273,85 @@ if (opts & MOUNT_FMASK) { mask = umask (0); +#ifndef __FreeBSD__ snprintf (fmask_opt, sizeof (fmask_opt), "fmask=%#o", mask | 0111); +#else + snprintf (fmask_opt, sizeof (fmask_opt), "-m=%#o", mask | 0111); +#endif g_ptr_array_add (options, fmask_opt); umask (mask); } if (opts & MOUNT_SHORTNAME) g_ptr_array_add (options, "shortname=lower"); + if (opts & MOUNT_LONGNAME) + g_ptr_array_add (options, "longnames"); + + if (opts & MOUNT_LOCALE) { + char *locale; + + locale = setlocale (LC_ALL, NULL); + if (!locale) { + locale = getenv ("LANG"); + } else { + locale_opt = g_strdup_printf ("-L=%s", locale); + g_ptr_array_add (options, locale_opt); + } + } + +#ifdef __FreeBSD__ + if (opts & MOUNT_CODEPAGE) { + if ((iocharset = gvm_iocharset ())) { + charset_opt = g_strdup_printf ("-D=%s", iocharset); + g_ptr_array_add (options, charset_opt); + } + } + + if (opts & MOUNT_UID) { + snprintf(uid, sizeof (uid) - 1, "-u=%s", getuid ()); + g_ptr_array_add (options, uid); + } +#endif } else if (!strcmp (fstype, "iso9660")) { /* only care about uid= and iocharset= */ +#ifdef __FreeBSD__ + if (opts & MOUNT_IOCHARSET) { + if ((iocharset = gvm_iocharset ())) { + charset_opt = g_strdup_printf ("-C=%s", iocharset); + g_ptr_array_add (options, charset_opt); + } + } +#endif } else if (!strcmp (fstype, "udf")) { /* also care about uid= and iocharset= */ if (opts & MOUNT_NOATIME) g_ptr_array_add (options, "noatime"); +#ifdef __FreeBSD__ + if (opts & MOUNT_IOCHARSET) { + if ((iocharset = gvm_iocharset ())) { + charset_opt = g_strdup_printf ("-C=%s", iocharset); + g_ptr_array_add (options, charset_opt); + } + } +#endif + } else if (!strcmp (fstype, "ntfs")) { + /* only care about uid= and iocharset= */ +#ifdef __FreeBSD__ + if (opts & MOUNT_IOCHARSET) { + if ((iocharset = gvm_iocharset ())) { + charset_opt = g_strdup_printf ("-C=%s", iocharset); + g_ptr_array_add (options, charset_opt); + } + } + + if (opts & MOUNT_UID) { + snprintf (uid, sizeof (uid) - 1, "-u=%s", getuid ()); + g_ptr_array_add (options, uid); + } +#endif } +#ifndef __FreeBSD__ if (opts & (MOUNT_IOCHARSET|MOUNT_UTF8)) { if ((iocharset = gvm_iocharset ())) { if ((opts & MOUNT_UTF8) && !strcmp (iocharset, "utf8")) { @@ -2277,6 +2367,7 @@ snprintf (uid, sizeof (uid) - 1, "uid=%u", getuid ()); g_ptr_array_add (options, uid); } +#endif libhal_free_string (fstype); } @@ -2301,6 +2392,7 @@ g_ptr_array_free (options, TRUE); g_free (charset_opt); + g_free (locale_opt); policy = g_new (struct _MountPolicy, 1); policy->udi = g_strdup (udi);