All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hongxu Jia <hongxu.jia@windriver.com>
To: <openembedded-core@lists.openembedded.org>
Subject: [PATCH 1/6] pmount: add version 0.9.23
Date: Fri, 12 Jul 2013 17:29:25 +0800	[thread overview]
Message-ID: <2b5a435eb3dcc6b7325364faa8c8eba9d8491195.1373599041.git.hongxu.jia@windriver.com> (raw)
In-Reply-To: <cover.1373599041.git.hongxu.jia@windriver.com>

The pmount is a wrapper around the standard mount program which permits
normal users to mount removable devices without a matching /etc/fstab
entry.

Add option -f to mount already mounted device, while option -f is used,
if the device has already been mounted, it will umount the exist mountpoint
and then mount the current.

Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
---
 ...-option-f-to-mount-already-mounted-device.patch | 115 +++++++++++++++++++++
 meta/recipes-extended/pmount/pmount_0.9.23.bb      |  29 ++++++
 2 files changed, 144 insertions(+)
 create mode 100644 meta/recipes-extended/pmount/files/pmount-add-option-f-to-mount-already-mounted-device.patch
 create mode 100644 meta/recipes-extended/pmount/pmount_0.9.23.bb

diff --git a/meta/recipes-extended/pmount/files/pmount-add-option-f-to-mount-already-mounted-device.patch b/meta/recipes-extended/pmount/files/pmount-add-option-f-to-mount-already-mounted-device.patch
new file mode 100644
index 0000000..ca6fbbc
--- /dev/null
+++ b/meta/recipes-extended/pmount/files/pmount-add-option-f-to-mount-already-mounted-device.patch
@@ -0,0 +1,115 @@
+pmount:add option -f to mount already mounted device
+
+While option -f is used, if the device has already been mounted,
+it will umount the exist mountpoint and then mount the current.
+
+Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
+Upstream-Status: Pending
+---
+ src/pmount.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++++-
+ 1 file changed, 48 insertions(+), 1 deletion(-)
+
+diff --git a/src/pmount.c b/src/pmount.c
+--- a/src/pmount.c
++++ b/src/pmount.c
+@@ -79,6 +79,8 @@ usage( const char* exename )
+     puts( _("Options:\n"
+     "  -r          : force <device> to be mounted read-only\n"
+     "  -w          : force <device> to be mounted read-write\n"
++    "  -f          : force <device> to be mounted even if it has been mounted,\n"
++    "                the previous mounted will be umounted.\n"
+     "  -s, --sync  : mount <device> with the 'sync' option (default: 'async')\n"
+     "  -A, --noatime\n"
+     "                mount <device> with the 'noatime' option (default: 'atime')\n"
+@@ -102,6 +104,31 @@ usage( const char* exename )
+ }
+ 
+ /**
++ * Check whether the given device has already been mounted.
++ * @return 1 if mounted, 0 if not mounted, -1 on failure
++ */
++int
++check_device_mounted(const char* device)
++{
++    int result = device_valid( device ) &&
++        ( device_whitelisted( device ) || device_removable( device ) ) &&
++        !device_locked( device );
++
++    if ( result )
++    {
++        result = device_mounted( device, 0, NULL );
++        if ( result )
++            debug ( "device already mounted\n" );
++    }
++    else
++    {
++        result = -1;
++        perror( _("Error: check device failed") );
++    }
++    return result;
++}
++
++/**
+  * Check whether the user is allowed to mount the given device to the given
+  * mount point. Creates the mount point if it does not exist yet. 
+  * @return 0 on success, -1 on failure
+@@ -618,6 +645,7 @@ main( int argc, char** argv )
+     int noatime = 0;
+     int exec = 0;
+     int force_write = -1; /* 0: ro, 1: rw, -1: default */
++    int force_mount = 0; /* 0: not force mount, 1: force mount */
+     const char* use_fstype = NULL;
+     const char* iocharset = NULL;
+     const char* umask = NULL;
+@@ -646,6 +674,7 @@ main( int argc, char** argv )
+         { "passphrase", 1, NULL, 'p' },
+         { "read-only", 0, NULL, 'r' },
+         { "read-write", 0, NULL, 'w' },
++        { "force-mount", 0, NULL, 'f'},
+         { "version", 0, NULL, 'V' },
+         { NULL, 0, NULL, 0}
+     };
+@@ -678,7 +707,7 @@ main( int argc, char** argv )
+ 
+     /* parse command line options */
+     do {
+-        switch( option = getopt_long( argc, argv, "+hdelLsArwp:t:c:u:V", long_opts, NULL ) ) {
++        switch( option = getopt_long( argc, argv, "+hdelLsArwfp:t:c:u:V", long_opts, NULL ) ) {
+             case -1:  break;          /* end of arguments */
+             case ':':
+             case '?': return E_ARGS;  /* unknown argument */
+@@ -713,6 +742,8 @@ main( int argc, char** argv )
+ 
+             case 'w': force_write = 1; break;
+ 
++            case 'f': force_mount = 1; break;
++
+             case 'V': puts(VERSION); return 0;
+ 
+             default:
+@@ -829,6 +860,22 @@ main( int argc, char** argv )
+             /* clean stale locks */
+             clean_lock_dir( device );
+ 
++            /* if device has already been mounted, umount it */
++            if (force_mount)
++            {
++                result = check_device_mounted(device);
++                if (result < 0)
++                    return E_POLICY;
++                else if (result == 1)
++                {
++                    debug("device alreasy mounted, umount it\n");
++                    result = spawnl( SPAWN_EROOT|SPAWN_RROOT, UMOUNTPROG, UMOUNTPROG, device, NULL );
++                    if( result != 0 ) {
++                        fprintf( stderr, _("Error: umount failed at force mount moment\n") );
++                        return -1;
++                    }
++                }
++            }
+             if( check_mount_policy( device, mntpt )  )
+                 return E_POLICY;
+ 
+-- 
+1.8.1.2
+
diff --git a/meta/recipes-extended/pmount/pmount_0.9.23.bb b/meta/recipes-extended/pmount/pmount_0.9.23.bb
new file mode 100644
index 0000000..0d357b9
--- /dev/null
+++ b/meta/recipes-extended/pmount/pmount_0.9.23.bb
@@ -0,0 +1,29 @@
+SUMMARY = "mount removable devices as normal user"
+DESCRIPTION = "pmount is a wrapper around the standard mount program which \
+permits normal users to mount removable devices without a matching /etc/fstab \
+entry. This provides a robust basis for automounting frameworks like GNOME's \
+Utopia project and confines the amount of code that runs as root to a minimum. \
+"
+HOMEPAGE = "http://pmount.alioth.debian.org/"
+SECTION = "console/utils"
+LICENSE = "GPLv3"
+LIC_FILES_CHKSUM = "file://COPYING;md5=d32239bcb673463ab874e80d47fae504"
+SRC_URI = "${DEBIAN_MIRROR}/main/p/pmount/pmount_${PV}.orig.tar.bz2 \
+          file://pmount-add-option-f-to-mount-already-mounted-device.patch \
+"
+
+DEPENDS = "glib-2.0-native intltool-native util-linux virtual/libc"
+
+# 1) Busybox's mount/umount doesn't support pmount very well, so
+# explicitly choose util-linux's mount/umount.
+# 2) It needs the existence of `/var/lock, /etc/mtab, /etc/fstab', so
+# explicitly choose base-files.
+RDEPENDS_${PN} = "util-linux-mount \
+                  util-linux-umount \
+                  base-files \
+"
+
+inherit autotools
+
+SRC_URI[md5sum] = "db19f5bf3151b1b41705ec7bafa439d3"
+SRC_URI[sha256sum] = "db38fc290b710e8e9e9d442da2fb627d41e13b3ee80326c15cc2595ba00ea036"
-- 
1.8.1.2



  reply	other threads:[~2013-07-12  9:29 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-12  9:29 [PATCH 0/6] fix xuser write to usb storage failed Hongxu Jia
2013-07-12  9:29 ` Hongxu Jia [this message]
2013-07-12  9:29 ` [PATCH 2/6] atom-pc:fix " Hongxu Jia
2013-07-15  7:14   ` Saul Wold
2013-07-15  7:42     ` Hongxu Jia
2013-07-12  9:29 ` [PATCH 3/6] udev-extraconf:fix " Hongxu Jia
2013-07-12  9:29 ` [PATCH 4/6] udev: fix invoking pmount failed based on sysvinit Hongxu Jia
2013-07-12  9:29 ` [PATCH 5/6] pmount: allow users in disk group to perform pmount/pumount Hongxu Jia
2013-07-12  9:29 ` [PATCH 6/6] xuser-account: add xuser to disk group Hongxu Jia

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2b5a435eb3dcc6b7325364faa8c8eba9d8491195.1373599041.git.hongxu.jia@windriver.com \
    --to=hongxu.jia@windriver.com \
    --cc=openembedded-core@lists.openembedded.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.