LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 01-02-2012, 04:13 PM   #1
rhb327
Member
 
Registered: May 2004
Distribution: Slackware Current
Posts: 161

Rep: Reputation: 30
udev rule for ipod


Hi and thanks for readying!

I have some ipod devices that I'd like to have a programmed mount point. The rules I've set are in /etc/udev/rules.d/10_custom_rules.rules and are as follows:

Code:
# Rich's IPOD Shuffle
ATTRS{idVendor}=="05ac", ATTRS{idProduct}=="1301", ATTRS{serial}=="000A27001C5D29BC", MODE="0664", NAME="ipod_rich", OPTIONS+="last_rule"
ACTION=="add", ATTRS{idVendor}=="05ac", ATTRS{idProduct}=="1301", ATTRS{serial}=="000A27001C5D29BC", RUN+="/bin/mkdir -p /media/ipod_rich"
ACTION=="add", ATTRS{idVendor}=="05ac", ATTRS{idProduct}=="1301", ATTRS{serial}=="000A27001C5D29BC", RUN+="/bin/chown rich /media/ipod_rich"
ACTION=="add", ATTRS{idVendor}=="05ac", ATTRS{idProduct}=="1301", ATTRS{serial}=="000A27001C5D29BC", RUN+="/bin/mount -t auto -o sync,flush,rw,user /dev/ipod_rich /media/ipod_rich"
ACTION=="remove", ATTRS{idVendor}=="05ac", ATTRS{idProduct}=="1301", ATTRS{serial}=="000A27001C5D29BC", RUN+="/bin/umount  /media/ipod_rich"
ACTION=="remove", ATTRS{idVendor}=="05ac", ATTRS{idProduct}=="1301", ATTRS{serial}=="000A27001C5D29BC", RUN+="/bin/rmdir /media/ipod_rich"
So you can see I'm hooking on the serial number. The issue I'm having is that the chown command doesn't seem to work so when I run gtkpod I get a permissions error. It seems by default the /medial/ipod_rich directory will be root/root (user/group) vs. rich/root. When I disable the rule and let udev work in it's default format I notice that the permissions are setup as the same with rich/root vs. root/root.

1) Can mkdir set the owner upon execution? I didn't see this as an option.
2) Why does chown not work?

Just as a note I manually created the mount points with rich/root and only had the mount and umount actions above and the mount point was still root/root <<< that surprised me.

Thanks for your assistance.
 
Old 01-03-2012, 01:03 PM   #2
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507

Rep: Reputation: 128Reputation: 128
Moved to Slackware at the request of the OP.
 
Old 01-03-2012, 07:57 PM   #3
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,119

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
What about setting the owner on the initial device creation ?. See if udev propagates it as you want.
As for the later commands, how about setting up a script for each action - that way you can ensure the commands execute in the order you need.
 
Old 01-03-2012, 08:58 PM   #4
Erik_FL
Member
 
Registered: Sep 2005
Location: Boynton Beach, FL
Distribution: Slackware
Posts: 821

Rep: Reputation: 258Reputation: 258Reputation: 258
Setting mounted filesystem permissions

The device permissions control access to using the mount command on the device. Likewise, before mounting, the mount point (directory) permissions control access to using the mount command on the mount point (directory). After mounting, the mount point (filesystem root) and file access permissions are determined either by options to "mount", or from the filesystem being mounted.

The file permissions assigned to the mounted filesystem partly depend on the type of filesystem being mounted. You should not use "-t auto" and you should determine the type of filesystem on the device. Using "-t auto" is risky because the filesystem may be guessed incorrectly.

For ext2 or ext3 filesystems (being mounted) the permissions are taken from the super block of the filesystem. To set the permissions you must first mount the filesystem on the mount point and then set the permissions for the mount point directory (which actually sets the filesystem root permissions). You can also use "tune2fs" to set permissions.

For FAT, VFAT or NTFS filesystems you have to specify options on the mount command to provide the permissions. For example, I had to use these mount options to allow a group called "sharedfiles" to read and write my NTFS partition.

uid=root,gid=sharedfiles,dmask=0007,fmask=0117

If I didn't specify the "gid" option to mount, then the group remained "root" regardless of the group ID set on the mount point directory. The same was true for the permission bits. Changing the mount point directory permissions had no effect on the permissions of the mounted filesystem.

It makes more sense to create a group that has access to the mounted filesystem and then make users members of that group. The group does not have to be the primary group that a user belongs to. However, you can change the user ID with the "uid" option if you want.

What happens when you create files or directories on the mounted filesystem depends on the type of filesystem. If it isn't ext2/ext3 then the filesystem may ignore your user permissions completely and apply a default set of permissions.
 
Old 01-04-2012, 07:32 PM   #5
rhb327
Member
 
Registered: May 2004
Distribution: Slackware Current
Posts: 161

Original Poster
Rep: Reputation: 30
uid=rich worked fine...thank you!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] udev rule not working r_jr Linux - Hardware 5 05-13-2011 03:58 PM
First UDEV Rule, Not quite there ... orbit Slackware 7 02-22-2009 10:08 PM
udev rule: need help DPenguin Linux - Hardware 0 08-04-2008 07:29 PM
Udev Rule Help Please Toods Slackware 1 11-23-2007 08:55 AM
need help with udev rule hussam Linux - Software 2 12-05-2006 03:30 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 09:20 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration