#endif
static GList *
-_g_get_unix_mounts ()
+_g_get_unix_mounts (void)
{
#ifdef HAVE_GETMNTENT_R
struct mntent ent;
vmount_number--;
}
-
g_free (vmount_info);
return g_list_reverse (return_list);
)
mount_entry->is_user_mountable = TRUE;
-
return_list = g_list_prepend (return_list, mount_entry);
}
{
mount_entry = g_new0 (GUnixMountPoint, 1);
-
mount_entry->mount_path = g_strdup (mntent.mnt_mount);
mount_entry->device_path = g_strdup (mntent.mnt_special);
mount_entry->filesystem_type = g_strdup (mntent.mnt_fstype);
found = mount_entry;
else
g_unix_mount_free (mount_entry);
-
}
g_list_free (mounts);
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
gobject_class->finalize = g_unix_mount_monitor_finalize;
+
/**
* GUnixMountMonitor::mounts-changed:
* @monitor: the object on which the signal is emitted
*
* Emitted when the unix mounts have changed.
- **/
+ */
signals[MOUNTS_CHANGED] =
g_signal_new ("mounts-changed",
G_TYPE_FROM_CLASS (klass),
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
+
/**
* GUnixMountMonitor::mountpoints-changed:
* @monitor: the object on which the signal is emitted
*
* Emitted when the unix mount points have changed.
- **/
+ */
signals[MOUNTPOINTS_CHANGED] =
g_signal_new ("mountpoints-changed",
G_TYPE_FROM_CLASS (klass),
* consecutive change events to the mount and mount point entry files.
*
* Since: 2.18
- **/
+ */
void
g_unix_mount_monitor_set_rate_limit (GUnixMountMonitor *mount_monitor,
- int limit_msec)
+ gint limit_msec)
{
g_return_if_fail (G_IS_UNIX_MOUNT_MONITOR (mount_monitor));
* g_unix_mount_monitor_set_rate_limit() to change this.
*
* Returns: a #GUnixMountMonitor.
- **/
+ */
GUnixMountMonitor *
g_unix_mount_monitor_new (void)
{
* @mount_entry: a #GUnixMount.
*
* Frees a unix mount.
- **/
+ */
void
g_unix_mount_free (GUnixMountEntry *mount_entry)
{
* @mount_point: unix mount point to free.
*
* Frees a unix mount point.
- **/
+ */
void
g_unix_mount_point_free (GUnixMountPoint *mount_point)
{
*
* Returns: 1, 0 or -1 if @mount1 is greater than, equal to,
* or less than @mount2, respectively.
- **/
+ */
gint
g_unix_mount_compare (GUnixMountEntry *mount1,
GUnixMountEntry *mount2)
* Gets the mount path for a unix mount.
*
* Returns: the mount path for @mount_entry.
- **/
-const char *
+ */
+const gchar *
g_unix_mount_get_mount_path (GUnixMountEntry *mount_entry)
{
g_return_val_if_fail (mount_entry != NULL, NULL);
* Gets the device path for a unix mount.
*
* Returns: a string containing the device path.
- **/
-const char *
+ */
+const gchar *
g_unix_mount_get_device_path (GUnixMountEntry *mount_entry)
{
g_return_val_if_fail (mount_entry != NULL, NULL);
* Gets the filesystem type for the unix mount.
*
* Returns: a string containing the file system type.
- **/
-const char *
+ */
+const gchar *
g_unix_mount_get_fs_type (GUnixMountEntry *mount_entry)
{
g_return_val_if_fail (mount_entry != NULL, NULL);
* Checks if a unix mount is mounted read only.
*
* Returns: %TRUE if @mount_entry is read only.
- **/
+ */
gboolean
g_unix_mount_is_readonly (GUnixMountEntry *mount_entry)
{
* Checks if a unix mount is a system path.
*
* Returns: %TRUE if the unix mount is for a system path.
- **/
+ */
gboolean
g_unix_mount_is_system_internal (GUnixMountEntry *mount_entry)
{
*
* Returns: 1, 0 or -1 if @mount1 is greater than, equal to,
* or less than @mount2, respectively.
- **/
+ */
gint
g_unix_mount_point_compare (GUnixMountPoint *mount1,
GUnixMountPoint *mount2)
* Gets the mount path for a unix mount point.
*
* Returns: a string containing the mount path.
- **/
-const char *
+ */
+const gchar *
g_unix_mount_point_get_mount_path (GUnixMountPoint *mount_point)
{
g_return_val_if_fail (mount_point != NULL, NULL);
* Gets the device path for a unix mount point.
*
* Returns: a string containing the device path.
- **/
-const char *
+ */
+const gchar *
g_unix_mount_point_get_device_path (GUnixMountPoint *mount_point)
{
g_return_val_if_fail (mount_point != NULL, NULL);
* Gets the file system type for the mount point.
*
* Returns: a string containing the file system type.
- **/
-const char *
+ */
+const gchar *
g_unix_mount_point_get_fs_type (GUnixMountPoint *mount_point)
{
g_return_val_if_fail (mount_point != NULL, NULL);
* Checks if a unix mount point is read only.
*
* Returns: %TRUE if a mount point is read only.
- **/
+ */
gboolean
g_unix_mount_point_is_readonly (GUnixMountPoint *mount_point)
{
* Checks if a unix mount point is mountable by the user.
*
* Returns: %TRUE if the mount point is user mountable.
- **/
+ */
gboolean
g_unix_mount_point_is_user_mountable (GUnixMountPoint *mount_point)
{
* Checks if a unix mount point is a loopback device.
*
* Returns: %TRUE if the mount point is a loopback. %FALSE otherwise.
- **/
+ */
gboolean
g_unix_mount_point_is_loopback (GUnixMountPoint *mount_point)
{
* determined, returns %G_UNIX_MOUNT_TYPE_UNKNOWN.
*
* Returns: a #GUnixMountType.
- **/
+ */
static GUnixMountType
g_unix_mount_guess_type (GUnixMountEntry *mount_entry)
{
* returns %G_UNIX_MOUNT_TYPE_UNKNOWN.
*
* Returns: a #GUnixMountType.
- **/
+ */
static GUnixMountType
g_unix_mount_point_guess_type (GUnixMountPoint *mount_point)
{
* Returns: A newly allocated string that must
* be freed with g_free()
*/
-char *
+gchar *
g_unix_mount_guess_name (GUnixMountEntry *mount_entry)
{
char *name;
* Returns: A newly allocated string that must
* be freed with g_free()
*/
-char *
+gchar *
g_unix_mount_point_guess_name (GUnixMountPoint *mount_point)
{
char *name;
mount_path = mount_entry->mount_path;
if (mount_path != NULL)
{
- if (g_str_has_prefix (mount_path, "/media/")) {
- char *path;
- /* Avoid displaying mounts that are not accessible to the user.
- *
- * See http://bugzilla.gnome.org/show_bug.cgi?id=526320 for why we
- * want to avoid g_access() for mount points which can potentially
- * block or fail stat()'ing, such as network mounts.
- */
- path = g_path_get_dirname (mount_path);
- if (g_str_has_prefix (path, "/media/"))
- {
- if (g_access (path, R_OK|X_OK) != 0) {
- g_free (path);
- return FALSE;
+ if (g_str_has_prefix (mount_path, "/media/"))
+ {
+ char *path;
+ /* Avoid displaying mounts that are not accessible to the user.
+ *
+ * See http://bugzilla.gnome.org/show_bug.cgi?id=526320 for why we
+ * want to avoid g_access() for mount points which can potentially
+ * block or fail stat()'ing, such as network mounts.
+ */
+ path = g_path_get_dirname (mount_path);
+ if (g_str_has_prefix (path, "/media/"))
+ {
+ if (g_access (path, R_OK|X_OK) != 0)
+ {
+ g_free (path);
+ return FALSE;
+ }
}
- }
- g_free (path);
+ g_free (path);
- if (mount_entry->device_path && mount_entry->device_path[0] == '/')
+ if (mount_entry->device_path && mount_entry->device_path[0] == '/')
{
struct stat st;
if (g_stat (mount_entry->device_path, &st) == 0 &&
g_access (mount_path, R_OK|X_OK) != 0)
return FALSE;
}
- return TRUE;
- }
+ return TRUE;
+ }
- if (g_str_has_prefix (mount_path, g_get_home_dir ()) && mount_path[strlen (g_get_home_dir())] == G_DIR_SEPARATOR)
+ if (g_str_has_prefix (mount_path, g_get_home_dir ()) &&
+ mount_path[strlen (g_get_home_dir())] == G_DIR_SEPARATOR)
return TRUE;
}
f = g_strdup (file);
- while (g_file_test (f, G_FILE_TEST_IS_SYMLINK)) {
- link = g_file_read_link (f, &error);
- if (link == NULL) {
- g_error_free (error);
+ while (g_file_test (f, G_FILE_TEST_IS_SYMLINK))
+ {
+ link = g_file_read_link (f, &error);
+ if (link == NULL)
+ {
+ g_error_free (error);
+ g_free (f);
+ f = NULL;
+ goto out;
+ }
+
+ dir = g_path_get_dirname (f);
+ f1 = g_strdup_printf ("%s/%s", dir, link);
+ g_free (dir);
+ g_free (link);
g_free (f);
- f = NULL;
- goto out;
+ f = f1;
}
-
- dir = g_path_get_dirname (f);
- f1 = g_strdup_printf ("%s/%s", dir, link);
- g_free (dir);
- g_free (link);
- g_free (f);
- f = f1;
- }
out:
if (f != NULL)
/* otherwise we're going to find it right away.. */
have_real_dev_root = TRUE;
- if (stat ("/dev/root", &statbuf) == 0) {
- if (! S_ISLNK (statbuf.st_mode)) {
- dev_t root_dev = statbuf.st_dev;
- FILE *f;
- char buf[1024];
+ if (stat ("/dev/root", &statbuf) == 0)
+ {
+ if (! S_ISLNK (statbuf.st_mode))
+ {
+ dev_t root_dev = statbuf.st_dev;
+ FILE *f;
+ char buf[1024];
- /* see if device with similar major:minor as /dev/root is mention
- * in /etc/mtab (it usually is)
- */
- f = fopen ("/etc/mtab", "r");
- if (f != NULL) {
- struct mntent *entp;
+ /* see if device with similar major:minor as /dev/root is mention
+ * in /etc/mtab (it usually is)
+ */
+ f = fopen ("/etc/mtab", "r");
+ if (f != NULL)
+ {
+ struct mntent *entp;
#ifdef HAVE_GETMNTENT_R
- struct mntent ent;
- while ((entp = getmntent_r (f, &ent, buf, sizeof (buf))) != NULL) {
+ struct mntent ent;
+ while ((entp = getmntent_r (f, &ent, buf, sizeof (buf))) != NULL)
+ {
#else
- G_LOCK (getmntent);
- while ((entp = getmntent (f)) != NULL) {
+ G_LOCK (getmntent);
+ while ((entp = getmntent (f)) != NULL)
+ {
#endif
- if (stat (entp->mnt_fsname, &statbuf) == 0 &&
- statbuf.st_dev == root_dev) {
- strncpy (real_dev_root, entp->mnt_fsname, sizeof (real_dev_root) - 1);
- real_dev_root[sizeof (real_dev_root) - 1] = '\0';
- fclose (f);
- goto found;
- }
- }
+ if (stat (entp->mnt_fsname, &statbuf) == 0 &&
+ statbuf.st_dev == root_dev)
+ {
+ strncpy (real_dev_root, entp->mnt_fsname, sizeof (real_dev_root) - 1);
+ real_dev_root[sizeof (real_dev_root) - 1] = '\0';
+ fclose (f);
+ goto found;
+ }
+ }
- endmntent (f);
+ endmntent (f);
#ifndef HAVE_GETMNTENT_R
- G_UNLOCK (getmntent);
+ G_UNLOCK (getmntent);
#endif
- }
+ }
- /* no, that didn't work.. next we could scan /dev ... but I digress.. */
+ /* no, that didn't work.. next we could scan /dev ... but I digress.. */
- } else {
- char *resolved;
- resolved = _resolve_symlink ("/dev/root");
- if (resolved != NULL) {
- strncpy (real_dev_root, resolved, sizeof (real_dev_root) - 1);
- real_dev_root[sizeof (real_dev_root) - 1] = '\0';
- g_free (resolved);
- goto found;
- }
+ }
+ else
+ {
+ char *resolved;
+ resolved = _resolve_symlink ("/dev/root");
+ if (resolved != NULL)
+ {
+ strncpy (real_dev_root, resolved, sizeof (real_dev_root) - 1);
+ real_dev_root[sizeof (real_dev_root) - 1] = '\0';
+ g_free (resolved);
+ goto found;
+ }
+ }
}
- }
/* bah sucks.. */
strcpy (real_dev_root, "/dev/root");
- found:
+found:
return real_dev_root;
}
#endif