Import xfce4-mount 0.5.5 :

This plugin allows for quick access to removable devices & mounted
partitions, giving a free space estimate, and allows to
mount/umount/eject devices. Lots of tweaks to replace getmntent() by
getmntinfo() calls.
This commit is contained in:
landry 2009-09-17 22:05:16 +00:00
parent 7a8edf88d0
commit b686df891f
9 changed files with 337 additions and 0 deletions

View File

@ -0,0 +1,26 @@
# $OpenBSD: Makefile,v 1.1.1.1 2009/09/17 22:05:16 landry Exp $
COMMENT= Xfce4 mount device panel plugin
XFCE_VERSION= 0.5.5
XFCE_PLUGIN= mount
# GPLv2
PERMIT_DISTFILES_CDROM= Yes
PERMIT_DISTFILES_FTP= Yes
PERMIT_PACKAGE_CDROM= Yes
PERMIT_PACKAGE_FTP= Yes
MODULES= x11/xfce4
WANTLIB= X11 Xdmcp Xrender Xau Xdamage fontconfig freetype m z c \
Xcursor Xext Xfixes Xi Xcomposite Xinerama Xrandr expat \
atk-1.0 gdk-x11-2.0 gdk_pixbuf-2.0 gio-2.0 glib-2.0 \
gmodule-2.0 gobject-2.0 gtk-x11-2.0 pango-1.0 \
pangoft2-1.0 pangocairo-1.0 cairo glitz png \
pixman-1 xfce4util xfcegui4 pthread-stubs xcb
# needed to correctly find bindtextdomain
CONFIGURE_ENV += LIBS="-liconv"
.include <bsd.port.mk>

View File

@ -0,0 +1,5 @@
MD5 (xfce4/xfce4-mount-plugin-0.5.5.tar.bz2) = HSN0aP4j5OjCkZXZuZxMXQ==
RMD160 (xfce4/xfce4-mount-plugin-0.5.5.tar.bz2) = YLdiSZp7qSNBRVbeBWKIXxIlz9U=
SHA1 (xfce4/xfce4-mount-plugin-0.5.5.tar.bz2) = EhUJPt035oRULcFDdaHDSe7mSiw=
SHA256 (xfce4/xfce4-mount-plugin-0.5.5.tar.bz2) = dvxOJxLNzjvuV76nAa/jhHclxin0dnB0HeFDZLg2+Kg=
SIZE (xfce4/xfce4-mount-plugin-0.5.5.tar.bz2) = 188141

View File

@ -0,0 +1,166 @@
$OpenBSD: patch-panel-plugin_devices_c,v 1.1.1.1 2009/09/17 22:05:16 landry Exp $
Rewrite all funcs using getmntent() to use getmntinfo()
use sudo for eject calls.
--- panel-plugin/devices.c.orig Sat May 17 11:49:21 2008
+++ panel-plugin/devices.c Thu Sep 17 23:48:57 2009
@@ -22,11 +22,15 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, U
#include <fstab.h>
#include <glib.h>
-#include <mntent.h>
#include <stdio.h>
#include <string.h>
-#include <sys/vfs.h>
+#include <sys/param.h>
+#include <sys/mount.h>
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
#include <libxfce4panel/xfce-panel-plugin.h>
#include <libxfce4util/libxfce4util.h>
#include <libxfcegui4/xfce-exec.h>
@@ -219,7 +223,7 @@ disk_mount (t_disk *pdisk, char *on_mount_cmd, char* m
deviceprintf (&tmp, mount_command, pdisk->device);
mountpointprintf (&tmp2, tmp, pdisk->mount_point);
if (eject)
- cmd = g_strconcat ("sh -c ' eject -t ", pdisk->device, " && ", tmp2, NULL);
+ cmd = g_strconcat ("sh -c ' sudo eject -t ", pdisk->device, " && ", tmp2, NULL);
else
cmd = g_strconcat ("sh -c ' ", tmp2, NULL);
@@ -280,7 +284,7 @@ disk_umount (t_disk *pdisk, char* umount_command, gboo
tmp = NULL;
if (eject)
- tmp = g_strconcat (cmd, " && eject ", pdisk->device, " '", NULL);
+ tmp = g_strconcat (cmd, " && sudo eject ", pdisk->device, " '", NULL);
else
tmp = g_strconcat (cmd, " '", NULL);
@@ -519,11 +523,10 @@ exclude_filesystem (GPtrArray *excluded_FSs, gchar *mo
void
disks_refresh(GPtrArray * pdisks, GPtrArray *excluded_FSs)
{
- /* using getmntent to get filesystems mount information */
+ /* using getfsstat to get filesystems mount information */
- FILE * fmtab = NULL; /* file /etc/mtab */
- struct mntent * pmntent = NULL; /* struct for mnt info */
struct statfs * pstatfs = NULL;
+ int i, nb_mounted_fs = 0;
gboolean exclude = FALSE;
TRACE("Entering disks_refresh\n");
@@ -534,60 +537,52 @@ disks_refresh(GPtrArray * pdisks, GPtrArray *excluded_
/* remove t_mount_info for all devices */
disks_free_mount_info (pdisks);
- /* allocate new struct statfs */
- pstatfs = g_new0 (struct statfs, 1);
+ /* get mounted fs */
+ nb_mounted_fs = getmntinfo(&pstatfs,MNT_WAIT);
- /* open file */
- fmtab = setmntent (MTAB, "r"); /* mtab file */
-
/* start looking for mounted devices */
- for (pmntent=getmntent(fmtab); pmntent!=NULL; pmntent=getmntent(fmtab)) {
+ for (i = 0; i < nb_mounted_fs ; i++) {
- DBG (" have entry: %s on %s \n", pmntent->mnt_fsname, pmntent->mnt_dir );
+ DBG (" have entry: %s on %s : type %s\n", pstatfs[i].f_mntfromname, pstatfs[i].f_mntonname, pstatfs[i].f_fstypename );
- statfs (pmntent->mnt_dir, pstatfs);
-
/* if we got the stat and the block number is non-zero */
/* get pointer on disk from pdisks */
/* CHANGED to reflect change in disk_search */
- pdisk = disks_search (pdisks, pmntent->mnt_dir);
+ pdisk = disks_search (pdisks, pstatfs[i].f_mntonname);
if (excluded_FSs!=NULL)
- exclude = exclude_filesystem (excluded_FSs, pmntent->mnt_dir, pmntent->mnt_fsname);
+ exclude = exclude_filesystem (excluded_FSs, pstatfs[i].f_mntonname, pstatfs[i].f_mntfromname);
if (pdisk == NULL) { /* if disk is not found in pdisks */
/* create a new struct t_disk and add it to pdisks */
/* test for mnt_dir==none or neither block device nor NFS or system device */
if ( exclude ||
- g_ascii_strcasecmp(pmntent->mnt_dir, "none") == 0 ||
- !(g_str_has_prefix(pmntent->mnt_fsname, "/dev/") ||
- g_str_has_prefix(pmntent->mnt_type, "fuse") ||
- g_str_has_prefix(pmntent->mnt_type, "nfs") ||
- g_str_has_prefix(pmntent->mnt_type, "smbfs") ||
- g_str_has_prefix(pmntent->mnt_type, "cifs") ||
- g_str_has_prefix(pmntent->mnt_type, "shfs") ) ||
- g_str_has_prefix(pmntent->mnt_dir, "/sys/")
+ g_ascii_strcasecmp(pstatfs[i].f_mntonname, "none") == 0 ||
+ !(g_str_has_prefix(pstatfs[i].f_mntfromname, "/dev/") ||
+ g_str_has_prefix(pstatfs[i].f_fstypename, "fuse") ||
+ g_str_has_prefix(pstatfs[i].f_fstypename, "nfs") ||
+ g_str_has_prefix(pstatfs[i].f_fstypename, "smbfs") ||
+ g_str_has_prefix(pstatfs[i].f_fstypename, "cifs") ||
+ g_str_has_prefix(pstatfs[i].f_fstypename, "shfs") ) ||
+ g_str_has_prefix(pstatfs[i].f_mntonname, "/sys/")
) continue;
/* else have valid entry reflecting block device or NFS */
- pdisk = disk_new (pmntent->mnt_fsname, pmntent->mnt_dir);
- pdisk->dc = disk_classify (pmntent->mnt_fsname, pmntent->mnt_dir);
+ pdisk = disk_new (pstatfs[i].f_mntfromname, pstatfs[i].f_mntonname);
+ pdisk->dc = disk_classify (pstatfs[i].f_mntfromname, pstatfs[i].f_mntonname);
g_ptr_array_add (pdisks, pdisk);
}
/* create new t_mount_info */
- mount_info = mount_info_new_from_stat (pstatfs, pmntent->mnt_type,
- pmntent->mnt_dir);
+ mount_info = mount_info_new_from_stat (&pstatfs[i], pstatfs[i].f_fstypename,
+ pstatfs[i].f_mntonname);
/* add it to pdisk */
pdisk->mount_info = mount_info ;
} /* end for */
- g_free (pstatfs);
- endmntent (fmtab); /* close file */
-
return;
}
@@ -627,25 +622,22 @@ disk_classify (char *device, char *mountpoint)
gboolean
disk_check_mounted (const char *disk)
{
- FILE *fmtab = NULL; /* file /etc/mtab */
- struct mntent *pmntent = NULL; /* struct for mnt info */
+ struct statfs * pstatfs = NULL;
+ int i, nb_mounted_fs = 0;
gboolean retval = FALSE;
- /* open file */
- fmtab = setmntent (MTAB, "r"); /* mtab file */
+ nb_mounted_fs = getmntinfo(&pstatfs,MNT_WAIT);
/* start looking for mounted devices */
- for (pmntent=getmntent(fmtab); pmntent!=NULL; pmntent=getmntent(fmtab))
+ for (i = 0; i < nb_mounted_fs ; i++)
{
- if (strcmp(pmntent->mnt_dir, disk)==0 ||
- strcmp(pmntent->mnt_fsname, disk)==0 )
+ if (strcmp(pstatfs[i].f_mntonname, disk)==0 ||
+ strcmp(pstatfs[i].f_mntfromname, disk)==0 )
{
retval = TRUE;
break;
}
}
-
- endmntent (fmtab); /* close file */
return retval;
}

View File

@ -0,0 +1,18 @@
$OpenBSD: patch-panel-plugin_devices_h,v 1.1.1.1 2009/09/17 22:05:16 landry Exp $
Permit to build with debug enabled
--- panel-plugin/devices.h.orig Thu Sep 17 23:32:22 2009
+++ panel-plugin/devices.h Thu Sep 17 23:32:28 2009
@@ -25,13 +25,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, U
#include "helpers.h"
-#ifdef DEBUG
-#undef DEBUG
-#endif
-#ifdef DEBUG_TRACE
-#undef DEBUG_TRACE
-#endif
-
/**
* An enum.
* NONE and ERROR as aliases.

View File

@ -0,0 +1,18 @@
$OpenBSD: patch-panel-plugin_mount-plugin_c,v 1.1.1.1 2009/09/17 22:05:16 landry Exp $
--- panel-plugin/mount-plugin.c.orig Thu Sep 17 22:56:11 2009
+++ panel-plugin/mount-plugin.c Thu Sep 17 22:56:25 2009
@@ -670,14 +670,6 @@ exlude_FSs_toggled (GtkWidget *widget, t_mounter_dialo
}
-static gboolean
-exclude_devicenames_toggled (GtkWidget *widget, t_mounter_dialog *md)
-{
-
-
- return TRUE;
-}
-
static void
mounter_create_options (XfcePanelPlugin *plugin, t_mounter *mt)
{

View File

@ -0,0 +1,36 @@
$OpenBSD: patch-panel-plugin_mount-plugin_h,v 1.1.1.1 2009/09/17 22:05:16 landry Exp $
Force the use of sudo & full path to mount/umount
--- panel-plugin/mount-plugin.h.orig Sat May 17 11:49:09 2008
+++ panel-plugin/mount-plugin.h Thu Sep 17 23:35:42 2009
@@ -27,19 +27,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, U
#include <config.h>
#endif
-#ifdef DEBUG
-#undef DEBUG
-#endif
-#ifdef DEBUG_TRACE
-#undef DEBUG_TRACE
-#endif
-
#include <gtk/gtk.h>
#include <libxfce4panel/xfce-panel-plugin.h>
#include <libxfce4util/libxfce4util.h>
#include <libxfcegui4/libxfcegui4.h>
#include <string.h>
+#include <stdlib.h>
#include "devices.h"
#include "helpers.h"
@@ -49,8 +43,8 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, U
#define BORDER 6
-#define DEFAULT_MOUNT_COMMAND "mount %d"
-#define DEFAULT_UMOUNT_COMMAND "umount %d"
+#define DEFAULT_MOUNT_COMMAND "sudo /sbin/mount %d"
+#define DEFAULT_UMOUNT_COMMAND "sudo /sbin/umount %d"
#define DEFAULT_ICON PACKAGE_DATA_DIR"/icons/hicolor/scalable/apps/xfce-mount.svg"

View File

@ -0,0 +1,12 @@
$OpenBSD: patch-po_fr_po,v 1.1.1.1 2009/09/17 22:05:16 landry Exp $
--- po/fr.po.orig Thu Sep 17 23:03:50 2009
+++ po/fr.po Thu Sep 17 23:04:09 2009
@@ -100,7 +100,7 @@ msgstr ""
#: ../panel-plugin/mount-plugin.c:220
msgid "<span foreground=\"#FF0000\">not mounted</span>"
-msgstr "<span foreground=\"#000000\" size=\"%s\">non monté</span>"
+msgstr "<span foreground=\"#FF0000\">non monté</span>"
#: ../panel-plugin/mount-plugin.c:525
msgid "devices"

View File

@ -0,0 +1,5 @@
This plugin will display a list of items representing your various
mounted and unmounted disk devices. If you click on an unmounted
devices it will mount it and vice versa. There is no warning in case
a device can't be mounted, but there is one when unmounting fails.
User needs proper sudo(1) rights to mount/umount/eject devices.

View File

@ -0,0 +1,51 @@
@comment $OpenBSD: PLIST,v 1.1.1.1 2009/09/17 22:05:16 landry Exp $
libexec/xfce4/
libexec/xfce4/panel-plugins/
@bin libexec/xfce4/panel-plugins/xfce4-mount-plugin
share/icons/
share/icons/hicolor/
share/icons/hicolor/48x48/
share/icons/hicolor/48x48/apps/
share/icons/hicolor/48x48/apps/xfce-mount.png
share/icons/hicolor/scalable/
share/icons/hicolor/scalable/apps/
share/icons/hicolor/scalable/apps/xfce-mount.svg
share/locale/ca/LC_MESSAGES/xfce4-mount-plugin.mo
share/locale/cs/LC_MESSAGES/xfce4-mount-plugin.mo
share/locale/de/LC_MESSAGES/xfce4-mount-plugin.mo
share/locale/el/LC_MESSAGES/xfce4-mount-plugin.mo
share/locale/en_GB/
share/locale/en_GB/LC_MESSAGES/
share/locale/en_GB/LC_MESSAGES/xfce4-mount-plugin.mo
share/locale/eu/LC_MESSAGES/xfce4-mount-plugin.mo
share/locale/fr/LC_MESSAGES/xfce4-mount-plugin.mo
share/locale/gl/LC_MESSAGES/xfce4-mount-plugin.mo
share/locale/hu/LC_MESSAGES/xfce4-mount-plugin.mo
share/locale/ja/LC_MESSAGES/xfce4-mount-plugin.mo
share/locale/ko/LC_MESSAGES/xfce4-mount-plugin.mo
share/locale/lt/
share/locale/lt/LC_MESSAGES/
share/locale/lt/LC_MESSAGES/xfce4-mount-plugin.mo
share/locale/lv/LC_MESSAGES/xfce4-mount-plugin.mo
share/locale/nb_NO/
share/locale/nb_NO/LC_MESSAGES/
share/locale/nb_NO/LC_MESSAGES/xfce4-mount-plugin.mo
share/locale/pl/LC_MESSAGES/xfce4-mount-plugin.mo
share/locale/pt_BR/LC_MESSAGES/xfce4-mount-plugin.mo
share/locale/pt_PT/
share/locale/pt_PT/LC_MESSAGES/
share/locale/pt_PT/LC_MESSAGES/xfce4-mount-plugin.mo
share/locale/ru/LC_MESSAGES/xfce4-mount-plugin.mo
share/locale/sq/
share/locale/sq/LC_MESSAGES/
share/locale/sq/LC_MESSAGES/xfce4-mount-plugin.mo
share/locale/uk/LC_MESSAGES/xfce4-mount-plugin.mo
share/locale/ur/
share/locale/ur/LC_MESSAGES/
share/locale/ur/LC_MESSAGES/xfce4-mount-plugin.mo
share/locale/vi/LC_MESSAGES/xfce4-mount-plugin.mo
share/locale/zh_CN/LC_MESSAGES/xfce4-mount-plugin.mo
share/locale/zh_TW/LC_MESSAGES/xfce4-mount-plugin.mo
share/xfce4/
share/xfce4/panel-plugins/
share/xfce4/panel-plugins/xfce4-mount-plugin.desktop