-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Distinguish between fs types when mounting sdcards #8
Conversation
Currently only vfat formatted sdcards will get mounted, when using other formats like ext4 or btrfs the mount will fail since unsupported mount options are being passed (uid,gid).
Using user id instead of user name and making group explicit.
I've tried this with vfat and with btrfs plus received reports from users this also works fine with ext4. |
As a sidenote, on ext4/btrfs etc, if the user already has files on the card under a different owner/group (eg created on a PC) then obviously the files will not be writable by user nemo. A fix for that will be to do a recursive chown but don't think that will be wise on 32/64/128Gb partitions ... Plus I assume that users choosing to use these filesystems will understand what they are doing. |
I did some extra testing to make sure it all works well and noticed that this script gets called twice (haven't traced it), the first time getting passed an empty ID_FS_TYPE. This change checks if this value is set.
@misja how are you getting/setting ID_FS_TYPE? |
FWIW I found this to work: |
I try to help, this is my first post. #!/bin/bash mount_vfat() { mount_all() { USERMNT=manu while [ -n "$1" ] ; do MUID=$(getent passwd $USERMNT | cut -d ":" -f 3) if [ "$MUID" = "" ]; then # no user found MGID=$(getent passwd $USERMNT | cut -d ":" -f 4) if [[ "$DEVICE" =~ "/dev/mm*" ]] PARTNO=0 exit 0 |
I admit ignorance on the subject, all I know is that without this change the card did not mount for me, at the very least on boot. |
IMHO with the actual script, only one partition will be mounted, if we insert an MSD with more than one partition and different FS types, we will have a lot of problems, because udev will call /usr/sbin/mount-sd.sh for the whole device and for each partition. |
/etc/udev/rules.d/90 SUBSYSTEM=="block", KERNEL=="mmcblk_", ACTION=="add", MODE="0660", RUN+="/usr/sbin/mount-sd.sh %k %n" /usr/sbin/mount_sd.h #!/bin/bash if [ $# -lt 2 ]; then # No arguments if [ -z "$ID_FS_TYPE" ]; then # No FS to mount DEF_UID=$(grep "^UID_MIN" /etc/login.defs | tr -s " " | cut -d " " -f2) if [ "$ACTION" = "add" ]; then # Mount action
fi After inserting a SD card with two partitions (vfat & btrfs) ; /dev/mmcblk0p4 13459968 56 11334144 1% /run/user/503/media/sdcard4 Warning, removing the SD card without umounting previously the fs (btrfs), will hung your device. I think we need a GUI to umount safely all the FS presents in the SD before removing the card. |
LGTM |
[sd-utils] Distinguish between fs types when mounting sdcards
Currently only vfat formatted sdcards will get mounted, when using other formats like ext4 or btrfs the mount will fail since unsupported mount options are being passed (uid,gid).