| Summary: | cannot write to usb using File Manager on Atom-pc | ||
|---|---|---|---|
| Product: | [Build System, Metadata & Runtime] OE-Core | Reporter: | Alexandru Georgescu <alexandru.c.georgescu> |
| Component: | core | Assignee: | Hongxu Jia <hongxu.jia> |
| Status: | VERIFIED FIXED | QA Contact: | |
| Severity: | normal | ||
| Priority: | Medium | CC: | bluelightning, hongxu.jia, liezhi.yang, mark.hatle, meta.mr.watcher, meta.watcher, ning.zhang, Qi.Chen, razvanx.ionescu, ross.burton, sen.zhang, sgw, tom.zanussi, yi.zhao |
| Version: | 1.3.1 | ||
| Target Milestone: | 1.5 M3 | ||
| Hardware: | x86 | ||
| OS: | Multiple | ||
| Whiteboard: | |||
| OS type for building Yocto: | --- | Type of Regression: | --- |
| Verified: | Documentation change: | Don't know | |
|
Description
Alexandru Georgescu
2013-03-11 09:31:03 UTC
This really isn't a BSP or a kernel issue, this is about how the images themselves are created. Moved to deployment and proxied through Saul for the moment. Investigate udev rules. The problem is xuser doesn't have permissions to write usb storage when the type of filesystem is not one of ext2/3/4 or btrfs. ... mount /dev/sdb1 on /media/sdb1 type ext4 /dev/sdb2 on /media/sdb2 type vfat /dev/sdb3 on /media/sdb3 type ntfs /dev/sdb4 on /media/sdb4 type btrfs /dev/sdb5 on /media/sdb5 type jfs /dev/sdb6 on /media/sdb6 type xfs ... ls /media/ -al drwx------ 3 xuser xuser 1024 Apr 10 09:08 sdb1 drwxr-xr-x 2 root root 16384 Jan 1 1970 sdb2 drwx------ 1 root root 4096 Apr 10 09:12 sdb3 drwx------ 1 xuser xuser 0 Apr 10 09:14 sdb4 drwxr-xr-x 2 root root 6 Apr 10 09:39 sdb5 drwxr-xr-x 2 root root 256 Apr 10 09:39 sdb6 ... The usb storage is mounted to dir `/media/sd**' by a udev's mount.sh script, Modify the script to change the owner of dir to xuser could fix this problem. There are two solutions to do according to the type of USB's filesystem. 1, For vfat, fat, ntfs, add mount option `uid'. 2, For others, invoke chown after mount. diff --git a/meta/recipes-core/udev/udev-extraconf/mount.sh b/meta/recipes-core/udev/udev-extraconf/mount.sh
index 99c76b2..4c8f4a8 100644
--- a/meta/recipes-core/udev/udev-extraconf/mount.sh
+++ b/meta/recipes-core/udev/udev-extraconf/mount.sh
@@ -18,15 +18,42 @@ do
done
automount() {
+ local mount_opt=""
+ local invoke_chown=""
+ local xusername=""
+
+ # Setting for rootless X
+ if [ -f /etc/X11/Xusername ]; then
+ xusername="`cat /etc/X11/Xusername`"
+
+ # There are two solutions to let rootless X to have rights to access
+ # the storage according to the type of filesystem.
+ case $ID_FS_TYPE in
+ vfat|fat|ntfs)
+ # Set uid by mount.
+ mount_opt="-o uid=`grep "$xusername" /etc/passwd | cut -d':' -f3`"
+ ;;
+ # Such as btrfs, minix, xfs, jfs, ext2, ext3, ext4, nilfs2.
+ *)
+ # Set uid by invoking chown after mount.
+ invoke_chown="1"
+ ;;
+ esac
+ fi
+
name="`basename "$DEVNAME"`"
! test -d "/media/$name" && mkdir -p "/media/$name"
- if ! $MOUNT -t auto $DEVNAME "/media/$name"
+ if ! $MOUNT -t auto $mount_opt $DEVNAME "/media/$name"
then
- #logger "mount.sh/automount" "$MOUNT -t auto $DEVNAME \"/media/$name\" failed!"
+ #logger "mount.sh/automount" "$MOUNT -t auto $mount_opt $DEVNAME \"/media/$name\" failed!"
rm_dir "/media/$name"
else
+ # Setting for rootless X to have rights to access the storage.
+ if [ $invoke_chown = "1" ]; then
+ chown "$xusername" "/media/$name"
+ fi
logger "mount.sh/automount" "Auto-mount of [/media/$name] successful"
touch "/tmp/.automount-$name"
fi
I think the solution needs to be generic, rather than hard-coding knowledge of rootless X in the udev scripts. Hi Paul, How about this solution: 1, Change the group of `/media/sd**' to `disk', and let group `disk' has w/r/x rights about `/media/sd**'. 2, Add xuser to `disk' group, so it could have enough rights to access the usb storage. ... xuser@atom-pc:/home/root$ groups tty input audio video xuser disk ls /media/ -al drwxrwx--- 3 xuser disk 1024 Apr 10 09:08 sdb1 drwxrwxr-x 2 root disk 16384 Jan 1 1970 sdb2 ... Maybe this solution be more generic, but I am not sure if it is proper to let group `disk' have w/r/x rights to access the usb storage? //Hongxu I guess we should be doing whatever other distributions do. Here on Ubuntu, /dev/sd* have the disk group but my user account is not a member of that group, yet I can mount and unmount external drives without problems. Didn't this get fixed in dylan? Hi Ross, Just tested this on 1.4 M6 RC2. http://autobuilder.yoctoproject.org/pub/nightly/20130418-1/ poky 789b2b7e0cca404ff8ba8ed5ba823d215e6ba5b4 The issue is still here. Regards, Alex. (In reply to comment #9) > Hi Ross, > > Just tested this on 1.4 M6 RC2. > http://autobuilder.yoctoproject.org/pub/nightly/20130418-1/ > poky 789b2b7e0cca404ff8ba8ed5ba823d215e6ba5b4 > > > The issue is still here. > > Regards, > Alex. The previous patch has been rejected, I will resend another one later with referencing other distro. //Hongxu According to the type of filesystem, there are several different situations: *1,If vfat(fat16/fat32): 1)On my distribution(Ubuntu 12.10), usb storage is auto mounted by gnome rather than udev, udev detects the plugin event and notify gnome to mount the device, the UID and GID of usb storage is inherited from the gnome's. Login with username `jiahongxu', it has permissions to write usb storage: ...ubuntu log....... $ mount /dev/sdb1 on /media/jiahongxu/fat type vfat (uid=1000,gid=1000,dmask=0077) $ ls /media/jiahongxu/ -al drwx------ 2 jiahongxu jiahongxu 16384 Jan 1 1970 fat .................... Login with username `tester', it has permissions to write usb storage: ...ubuntu log....... $ mount /dev/sdb1 on /media/tester/fat type vfat (uid=1001,gid=1002,dmask=0077) $ ls /media/root/ -al drwx------ 2 tester tester 16384 Jan 1 1970 fat .................... 2)Plug in the previous usb storage to yocto atom which rootless X is enable, xuser doesn't have permissions to write usb storage, the UID and GID of usb storage is inherited from udev's (root): ...yocto atom log... $mount /dev/sdb2 on /media/sdb2 type vfat $ls /media/ -al drwxr-xr-x 2 root root 16384 Jan 1 1970 sdb2 .................... 3)In this situation to reference ubuntu, if rootless X is enable, grant xuser's UID and GID to usb storage while auto mounting by udev. *2, If ext2/3/4: 1)On my distribution(Ubuntu 12.10), login with username `jiahongxu', format usb storage with ext4, the UID and GID of usb storage is jiahongxu's. ...ubuntu log....... $ mount /dev/sdb2 on /media/jiahongxu/ext4 type ext4 (rw,nosuid,nodev,uhelper=udisks2) $ ls /media/jiahongxu/ -al drwx------ 3 jiahongxu jiahongxu 1024 Apr 28 10:20 ext4 .................... 2)On my distribution(Ubuntu 12.10), login with username `tester', plug in the previous usb storage, access the storage is failed. ...ubuntu log....... $ mount /dev/sdb2 on /media/tester/ext4 type ext4 (rw,nosuid,nodev,uhelper=udisks2) $ ls /media/tester/ -al drwx------ 3 jiahongxu jiahongxu 1024 Apr 28 10:20 ext4 $ touch /media/tester/ext4/abc touch: cannot touch `/media/tester/ext4/abc': Permission denied .................... 3)Plug in the same usb storage into yocto atom which rootless X is enable, it could access the storage because `xuser' has the same UID and GID with `jiahongxu' which the value is 1000. ...yocto atom log... $ mount /dev/sdb1 on /media/sdb1 type ext4 $ ls /media/ -al drwx------ 3 xuser xuser 1024 Apr 10 09:08 sdb1 .................... 4) In this situation, there is no need to modify yocto udev automount. *3, If exfat: It needs install module FUSE and sub-module `exfat-fuse' on linux, this will be supported in 1.5. *4, If ntfs: The kernel built-in driver to support ntfs write is partial, see linux/fs/ntfs/Kconfig: ... 51 config NTFS_RW 52 bool "NTFS write support" 53 depends on NTFS_FS 54 help 55 This enables the partial, but safe, write support in the NTFS driver. 56 57 The only supported operation is overwriting existing files, without 58 changing the file length. No file or directory creation, deletion or 59 renaming is possible. Note only non-resident files can be written to 60 so you may find that some very small files (<500 bytes or so) cannot 61 be written to. ... To support ntfs write, it needs install module FUSE and sub-module `ntfs-3g' on linux, this will be supported in 1.5. Hi Saul, As Otavio suggested, we should look at pmount. It is an easy way to handle it without udisks. It could mount removable devices as normal user. It is a wrapper around the standard mount program in which invokes mount with different options according to the type of filesystem. * I have done the following: 1, Add package pmount_0.9.23 to oe-core. 2, Investigate udev script `mount.sh' to invoke pmount instead at automount while rootless X is enable. But it needs more test and debug. * Question 1, Is it necessary to add package pmount to oe-core? If yes, I suggest to do this as an enhancement. 2, Is it necessary to use pmount instead of mount at automount in udev script? If yes, it needs to change user ID while invoking pmount, because pmount is used for normal user and udev is started by root. Thanks, Hongxu Merged into master: http://git.yoctoproject.org/cgit/cgit.cgi/poky/commit/?id=e23d5a0e34c8a55f30619b0777ad8e004b37d9e7 Verfied with: dora:a02280f99f05b1c21de2a78de9222a2f62a0dabc (1.5 M5 RC6) which includes the fixing patch. |