Fixing Sansa attributes

As previously mentioned, I have had some file attribute problems with my new Sansa e200 series MP3 player. Basically, when I plugged it in to charge, the "hidden" attribute on various directories on the device's FAT32 filesystem were being changed.

Well, I have now automated the correction of that particular annoyance. With a simple script and udev rule, the attributes are now reset automatically whenever I plug in the device.

The script to change the attributes is as follows:

#!/bin/bash

DEV_PATH="/dev/$1"
export MTOOLS_SKIP_CHECK=1

mattrib -i "$DEV_PATH" +h ::\TMP
mattrib -i "$DEV_PATH" -h ::\MUSIC
mattrib -i "$DEV_PATH" -h ::\PLAYLISTS

Note that this script requires no changes to the mtools configuration. Instead, the -i parameter and the environment variable take care of the stuff we did with .mtoolsrc last time.

To fire this script when the device is plugged in, I added to following to my /etc/udev/rules.d/80-programs.rules file:

KERNEL=="sd[a-z][0-9]", ACTION=="add", ATTRS{model}=="Sansa e2[0-9]0*", RUN+="/home/pageer/bin/sansa-perm-fix.sh %k"

This runs when a new SCSI drive device is added and the model string matches the Sansa e200 series. It then runs the above script, passing it the name of the device, e.g. sdb1.

So, that fixes that. Now I only see the files and directories I want to see in the Rockbox file browser. I consider this a small victory for the picky among us.

You can reply to this entry by leaving a comment below. You can send TrackBack pings to this URL. This entry accepts Pingbacks from other blogs. You can follow comments on this entry by subscribing to the RSS feed.

Related entries

Comments #

    mounting the micro-sd card on a sansa e280

    Hi,
    thank you for the tip on making the directories stay visible.
    Another problem:
    In Windows XP the sansa and the micro-sd card in the sansa show up as two different drives.
    In Linux (SLAMD64 12.0) I connect a usb cable to the device and then:
    ls /dev/disk/by-id/
    and it shows two partitions, the sansa operating system and the sansa music area:

    usb-SanDisk_Sansa_e280_00000000-00000000-8680b38a-d925e817-00000000-0:0
    usb-SanDisk_Sansa_e280_00000000-00000000-8680b38a-d925e817-00000000-0:0-part1
    usb-SanDisk_Sansa_e280_00000000-00000000-8680b38a-d925e817-00000000-0:0-part2

    I can mount the music area just fine
    mount /dev/disk/by-id/usb-SanDisk_Sansa_e280_00000000-00000000-8680b38a-d925e817-00000000-0:0-part1 /media/sansa-main

    but the micro-sd disk does not show up in /dev.

    This is a multi-lun device, so we tried to re-scan the LUNs with a sudo script that we use for 6-in-1 card readers:
    #!/bin/sh
    cd /sys/bus/usb/drivers/usb-storage/
    for x in `ls ?-* -d `
    do
    echo "found: "$x
    echo -n $x > /sys/bus/usb/drivers/usb-storage/unbind
    echo -n $x > /sys/bus/usb/drivers/usb-storage/bind
    echo "">/dev/null
    done
    this rescans the LUNS of found devices and reports what it finds. It fixes the problem of switching different cards on a 6-in-1 reader such as is built in my monitor, otherwise you have to reboot to switch types of cards.
    But the sansa card does not show up even scanning for all LUNs.

    Do you know a solution to mounting the Micro-sd card in a in Linux? I really would like the extra 4 gb capacity.

    • Comment posted on Saturday 29 Dec 2007 at 9:51pm
    • By Steve

    Um...works for me?

    Steve,

    Sorry I can't be more helpful, but I can't replicate your problem. Of course, I don't actually use the Sansa to put things on my microSD card, as the card is for my cell phone and I have an SD card reader anyway, but I tried it just now and it works perfectly. I'm using Kubuntu 7.10 (32-bit desktop version), and when I stick a card in my Sansa and plug it in, two file manager windows pop up: one for the internal flash and one for the microSD card.

    In my case, /dev/disk/by-id actually contains 5 files for the Sansa - a 2-partition device for the internal storage and a 1-partition one for the microSD card.
    usb-SanDisk_Sansa_e280_00000000-00000000-9844b4a4-b41fe817-00000000-0:0 -> ../../sdf
    usb-SanDisk_Sansa_e280_00000000-00000000-9844b4a4-b41fe817-00000000-0:0-part1 -> ../../sdf1
    usb-SanDisk_Sansa_e280_00000000-00000000-9844b4a4-b41fe817-00000000-0:0-part2 -> ../../sdf2
    usb-SanDisk_Sansa_e280_00000000-00000000-9844b4a4-b41fe817-00000000-0:1 -> ../../sdg
    usb-SanDisk_Sansa_e280_00000000-00000000-9844b4a4-b41fe817-00000000-0:1-part1 -> ../../sdg1
    I'm not sure why you don't see it. I'd guess it's a difference in default driver and/or udev configuration between SLAMD64 and Ubuntu, but I wouldn't even know where to start looking to fix it.

    But, if nothing else, I can tell you the microSD port can *definitely* be made to work in Linux. I just don't know how you'd do it.

Add your comments #

A comment body is required. No HTML code allowed. URLs starting with http:// or ftp:// will be automatically converted to hyperlinks.