* [gentoo-user] How to set udev rule? @ 2009-08-27 7:22 Song Zhiwei 2009-08-27 10:01 ` KH 0 siblings, 1 reply; 13+ messages in thread From: Song Zhiwei @ 2009-08-27 7:22 UTC (permalink / raw To: gentoo-user Hi all, I complied a driver esdcan_usb331.so. I'd like use udev to create character devices /dev/can0 and /dev/can1 with major 50 and minor 0/1 for the driver. How to write the udev rule for it? The dmesg is: esd CAN driver: CAN_USB331 esd CAN driver: baudrate not set esd CAN driver: mode = 0x00000000, major = 50, verbose = 0x00000001 esd CAN driver: version 3.8.3 06:03:32 Aug 24 2009: successfully loaded usbcore: registered new interface driver CAN_USB331 ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [gentoo-user] How to set udev rule? 2009-08-27 7:22 [gentoo-user] How to set udev rule? Song Zhiwei @ 2009-08-27 10:01 ` KH 2009-08-28 1:51 ` Song Zhiwei 0 siblings, 1 reply; 13+ messages in thread From: KH @ 2009-08-27 10:01 UTC (permalink / raw To: gentoo-user Song Zhiwei schrieb: > Hi all, > > I complied a driver esdcan_usb331.so. I'd like use udev to create > character devices /dev/can0 and /dev/can1 with major 50 and minor 0/1 > for the driver. How to write the udev rule for it? > > The dmesg is: > esd CAN driver: CAN_USB331 > esd CAN driver: baudrate not set > esd CAN driver: mode = 0x00000000, major = 50, verbose = 0x00000001 > esd CAN driver: version 3.8.3 06:03:32 Aug 24 2009: successfully loaded > usbcore: registered new interface driver CAN_USB331 > Hi, there are two good guides for this: http://www.gentoo.org/doc/en/udev-guide.xml http://www.reactivated.net/writing_udev_rules.html Regards kh ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [gentoo-user] How to set udev rule? 2009-08-27 10:01 ` KH @ 2009-08-28 1:51 ` Song Zhiwei 2009-08-28 3:33 ` David Relson 0 siblings, 1 reply; 13+ messages in thread From: Song Zhiwei @ 2009-08-28 1:51 UTC (permalink / raw To: gentoo-user Actually, I have read the guilds and tried, but it didnot work. So I asked here. Two devices related with "can usb" were found when I used the udevadm: #udevadm info -a -p /sys/devices/pci0000\:00/0000\:00\:0f.4/usb2/2- 2/2-2\:1.0 looking at device '/devices/pci0000:00/0000:00:0f.4/usb2/2-2/2-2:1.0': KERNEL=="2-2:1.0" SUBSYSTEM=="usb" DRIVER=="CAN_USB331" ATTR{bInterfaceNumber}=="00" ATTR{bAlternateSetting}==" 0" ATTR{bNumEndpoints}=="04" ATTR{bInterfaceClass}=="00" ATTR{bInterfaceSubClass}=="00" ATTR{bInterfaceProtocol}=="00" ATTR{modalias}=="usb:v0AB4p0001d0002dc00dsc00dp00ic00isc00ip00" looking at parent device '/devices/pci0000:00/0000:00:0f.4/usb2/2-2': KERNELS=="2-2" SUBSYSTEMS=="usb" DRIVERS=="usb" ATTRS{configuration}=="" ATTRS{bNumInterfaces}==" 1" ATTRS{bConfigurationValue}=="1" ATTRS{bmAttributes}=="80" ATTRS{bMaxPower}=="500mA" ATTRS{urbnum}=="20" ATTRS{idVendor}=="0ab4" ATTRS{idProduct}=="0001" ATTRS{bcdDevice}=="0002" ATTRS{bDeviceClass}=="00" ATTRS{bDeviceSubClass}=="00" ATTRS{bDeviceProtocol}=="00" ATTRS{bNumConfigurations}=="1" ATTRS{bMaxPacketSize0}=="16" ATTRS{speed}=="12" ATTRS{busnum}=="2" ATTRS{devnum}=="2" ATTRS{version}==" 1.00" ATTRS{maxchild}=="0" ATTRS{quirks}=="0x0" ATTRS{authorized}=="1" ATTRS{manufacturer}=="esd-gmbh" ATTRS{product}=="CAN-USB 543" ATTRS{serial}=="GD001494" The module was loaded by an alias in /etc/modules.d/esdcan: alias char-major-50 esdcan-usb331 But I cannot find the major:minor informations in the udev info above. I tried the rules: SUBSYSTEM=="usb", DRIVER=="CAN_USB331", ATTR{serial}=="GD001494", NAME="can0" SUBSYSTEM=="usb", DRIVER=="CAN_USB331", NAME="can0" DRIVER=="CAN_USB331", NAME="can0" and SUBSYSTEM=="usb", ATTR{serial}=="GD001494", NAME="can%n" But any one of them does not work. Anyone can help me? 2009/8/27 KH <gentoo-user@konstantinhansen.de>: > Song Zhiwei schrieb: >> Hi all, >> >> I complied a driver esdcan_usb331.so. I'd like use udev to create >> character devices /dev/can0 and /dev/can1 with major 50 and minor 0/1 >> for the driver. How to write the udev rule for it? >> >> The dmesg is: >> esd CAN driver: CAN_USB331 >> esd CAN driver: baudrate not set >> esd CAN driver: mode = 0x00000000, major = 50, verbose = 0x00000001 >> esd CAN driver: version 3.8.3 06:03:32 Aug 24 2009: successfully loaded >> usbcore: registered new interface driver CAN_USB331 >> > > Hi, > > there are two good guides for this: > > http://www.gentoo.org/doc/en/udev-guide.xml > http://www.reactivated.net/writing_udev_rules.html > > Regards kh > > ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [gentoo-user] How to set udev rule? 2009-08-28 1:51 ` Song Zhiwei @ 2009-08-28 3:33 ` David Relson 2009-08-30 17:29 ` Alex Schuster 0 siblings, 1 reply; 13+ messages in thread From: David Relson @ 2009-08-28 3:33 UTC (permalink / raw To: gentoo-user Don't know if the following will help, but it's a rule that I successfully use to mount a USB memory stick: BUS=="usb", SYSFS{manufacturer}=="STECH", SYMLINK+="STECH", run+="/bin/mount -a" ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [gentoo-user] How to set udev rule? 2009-08-28 3:33 ` David Relson @ 2009-08-30 17:29 ` Alex Schuster 2009-08-30 19:38 ` Dirk Heinrichs 0 siblings, 1 reply; 13+ messages in thread From: Alex Schuster @ 2009-08-30 17:29 UTC (permalink / raw To: gentoo-user David Relson writes: > Don't know if the following will help, but it's a rule that I > successfully use to mount a USB memory stick: > > BUS=="usb", SYSFS{manufacturer}=="STECH", SYMLINK+="STECH", > run+="/bin/mount -a" I have to change the bus from usb to scsi, then it works. But what about unmounting? Is is possible to have it unmounted after I pull the memory stick? Wonko ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [gentoo-user] How to set udev rule? 2009-08-30 17:29 ` Alex Schuster @ 2009-08-30 19:38 ` Dirk Heinrichs 2009-08-30 20:15 ` Jesús Guerrero 0 siblings, 1 reply; 13+ messages in thread From: Dirk Heinrichs @ 2009-08-30 19:38 UTC (permalink / raw To: gentoo-user [-- Attachment #1: Type: Text/Plain, Size: 345 bytes --] Am Sonntag 30 August 2009 19:29:39 schrieb Alex Schuster: > I have to change the bus from usb to scsi, then it works. But what about > unmounting? Is is possible to have it unmounted after I pull the memory > stick? How do want to umount something that's not there anymore? You have to umount _before_ you pull it. Bye... Dirk [-- Attachment #2: This is a digitally signed message part. --] [-- Type: application/pgp-signature, Size: 190 bytes --] ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [gentoo-user] How to set udev rule? 2009-08-30 19:38 ` Dirk Heinrichs @ 2009-08-30 20:15 ` Jesús Guerrero 2009-08-30 21:13 ` Dale 2009-08-30 21:26 ` Alex Schuster 0 siblings, 2 replies; 13+ messages in thread From: Jesús Guerrero @ 2009-08-30 20:15 UTC (permalink / raw To: gentoo-user On Sun, August 30, 2009 21:38, Dirk Heinrichs wrote: > Am Sonntag 30 August 2009 19:29:39 schrieb Alex Schuster: > > >> I have to change the bus from usb to scsi, then it works. But what >> about unmounting? Is is possible to have it unmounted after I pull the >> memory stick? > > How do want to umount something that's not there anymore? You have to > umount _before_ you pull it. You can force the umount using -l (no, it's not documented in the man page). You can use this to umount a volume *after* it has been physically removed. And some people use this crap on udev rules to remove the volume when they unplug the pendrive. Then they wonder why the heck the file is not where it should be. I guess they never heard of cached writes. The correct thing to do is of course to umount it before, and then unplug it or whatever. If you truly want to umount after, you should at least do a sync before removing the device. In any case, if you don't follow the logical order of the things don't complain if then you find that the files that should be there are not there when you need them. If you truly love risk, just use umount -l, but you have to promise not to cry if the fs breaks or your files are not writen when you sudenly unplug the device. -- Jesús Guerrero ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [gentoo-user] How to set udev rule? 2009-08-30 20:15 ` Jesús Guerrero @ 2009-08-30 21:13 ` Dale 2009-08-30 21:26 ` Alex Schuster 1 sibling, 0 replies; 13+ messages in thread From: Dale @ 2009-08-30 21:13 UTC (permalink / raw To: gentoo-user Jesús Guerrero wrote: > On Sun, August 30, 2009 21:38, Dirk Heinrichs wrote: > >> Am Sonntag 30 August 2009 19:29:39 schrieb Alex Schuster: >> >> >> >>> I have to change the bus from usb to scsi, then it works. But what >>> about unmounting? Is is possible to have it unmounted after I pull the >>> memory stick? >>> >> How do want to umount something that's not there anymore? You have to >> umount _before_ you pull it. >> > > You can force the umount using -l (no, it's not documented in the man > page). You can use this to umount a volume *after* it has been physically > removed. And some people use this crap on udev rules to remove the > volume when they unplug the pendrive. Then they wonder why the heck > the file is not where it should be. I guess they never heard of cached > writes. > > The correct thing to do is of course to umount it before, > and then unplug it or whatever. > > If you truly want to umount after, you should at least do a sync before > removing the device. In any case, if you don't follow the logical > order of the things don't complain if then you find that the files that > should be there are not there when you need them. > > If you truly love risk, just use umount -l, but you have to promise not > to cry if the fs breaks or your files are not writen when you sudenly > unplug the device. > > Basically, if he is going to do this the way he is thinking of doing it, use cp NOT mv. o_O If he uses mv and then unpkugs it without unmounting or syncing, the file is gone for good. At least with cp you still have the original file. Just thinking this through a little here. Dale :-) :-) ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [gentoo-user] How to set udev rule? 2009-08-30 20:15 ` Jesús Guerrero 2009-08-30 21:13 ` Dale @ 2009-08-30 21:26 ` Alex Schuster 2009-08-31 5:38 ` Jesús Guerrero 2009-08-31 16:41 ` Dirk Heinrichs 1 sibling, 2 replies; 13+ messages in thread From: Alex Schuster @ 2009-08-30 21:26 UTC (permalink / raw To: gentoo-user Jesús Guerrero writes: > On Sun, August 30, 2009 21:38, Dirk Heinrichs wrote: > > Am Sonntag 30 August 2009 19:29:39 schrieb Alex Schuster: > >> I have to change the bus from usb to scsi, then it works. But what > >> about unmounting? Is is possible to have it unmounted after I pull the > >> memory stick? > > > > How do want to umount something that's not there anymore? You have to > > umount _before_ you pull it. > > You can force the umount using -l (no, it's not documented in the man > page). You can use this to umount a volume *after* it has been physically > removed. The -l is not necessary here, a simple umount is enough. > And some people use this crap on udev rules to remove the > volume when they unplug the pendrive. Yes, this very rule would be nice to have :) > Then they wonder why the heck > the file is not where it should be. I guess they never heard of cached > writes. > > The correct thing to do is of course to umount it before, > and then unplug it or whatever. I do so, it makes me feel better, but I wonder whether it is _really_ necessary. I see Windows users do this all the time, without any problem yet. Of course, the wait a little after writing to it, but a few seconds after the blinking stops seem to be enough. And people are lazy, I know my Linux users _will_ just plug the stick. Using the KDE4 automounter, the device will be unmounted automatically in this case, but I am looking for a solution without KDE4, and as few user interaction as possible. The udev mouting rule is nice, but it leaves a lot of mounts when plugging in and out repeatedly. When the system is mostly idle, I guess the writing to the stick would not be delayed for a long time, so this should be quite safe. At least if the data is not that important. And if there are no writes, I see no problem at all. There also is the sync option to mount, it should not be used on media with limited number of write cycles, but I also guess that for my purposes this would not matter. Wonko ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [gentoo-user] How to set udev rule? 2009-08-30 21:26 ` Alex Schuster @ 2009-08-31 5:38 ` Jesús Guerrero 2009-08-31 14:32 ` Stroller 2009-08-31 16:41 ` Dirk Heinrichs 1 sibling, 1 reply; 13+ messages in thread From: Jesús Guerrero @ 2009-08-31 5:38 UTC (permalink / raw To: gentoo-user On Sun, August 30, 2009 23:26, Alex Schuster wrote: > Jesús Guerrero writes: > > >> Then they wonder why the heck >> the file is not where it should be. I guess they never heard of cached >> writes. >> >> The correct thing to do is of course to umount it before, >> and then unplug it or whatever. > > I do so, it makes me feel better, but I wonder whether it is _really_ > necessary. It is. Nothing can guarantee that the data has been dumped to the disk unless you umount it first. You can reduce the chances of losing information by waiting before removing it. But if the system is loaded the writes can be deferred to a later time, when the system is idle. This can be partially mitigated by using the "sync" mount option, as you say below. :) Of course then the performance will drop, and the i/o scheduler will not have a chance to work as usual either because i/o ops will not be queued, which is the bad part of the deal. > I see Windows users do this all the time, without any problem > yet. Of course, the wait a little after writing to it, but a few seconds > after the blinking stops seem to be enough. Lucky guys. That, or when the file is not on the drive they come back and copy it again without you noticing it. This happens lots of times. I've seen it and I'll continue to see it as long as users don't understand what's going under the hood. That's what the safe removal feature in Windows is about, it's not there just to decorate your try, it exists for a reason. > And people are lazy, Yes, I am as well. But when integrity matters you really want to umount or at least sync before unplugging. I am a lazy guy, lazy like hell, but I always fasten my seat belt when I am going to drive. ;) > The > udev mouting rule is nice, but it leaves a lot of mounts when plugging in > and out repeatedly. Mmmm, I am not sure I follow you. If you use a rule as described above you can remove the mount and even the mount point when the device is detached. Is not that what you mean? > When the system is mostly idle, I guess the writing to the stick would > not be delayed for a long time, so this should be quite safe. At least if > the data is not that important. And if there are no writes, I see no > problem at all. If you don't have a problem with the chance to lose files that's ok. I just thought I'd point it out just in case, because the chance is there. A write operation can be deferred for a number of reasons. That's why "sync" (both as a command and as a mount option) was invented in first place. > There also is the sync option to mount, it should not be used on media > with limited number of write cycles, but I also guess that for my purposes > this would not matter. Nowadays this shouldn't matter too much. The life cycle of ssd devices has been greatly expanded, and they also do some kind of balancing so all the blocks get the same usage. Even journal fs's shouldn't be much of a problem with any recent flash device. -- Jesús Guerrero ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [gentoo-user] How to set udev rule? 2009-08-31 5:38 ` Jesús Guerrero @ 2009-08-31 14:32 ` Stroller 0 siblings, 0 replies; 13+ messages in thread From: Stroller @ 2009-08-31 14:32 UTC (permalink / raw To: gentoo-user On 31 Aug 2009, at 06:38, Jesús Guerrero wrote: > ... >> I see Windows users do this all the time, without any problem >> yet. Of course, the wait a little after writing to it, but a few >> seconds >> after the blinking stops seem to be enough. > > Lucky guys. That, or when the file is not on the drive they come back > and copy it again without you noticing it. This happens lots of times. > I've seen it and I'll continue to see it as long as users don't > understand what's going under the hood. That's what the safe removal > feature in Windows is about, it's not there just to decorate your > try, it exists for a reason. Indeed. Macs complain if you pull a USB drive without safely removing it first, and this warns users against doing it again in the future. The problem with XP is that the "safely remove" icon is so small that typical users don't ever notice it, and consequently don't know any better. They're used to hot-plugging USB mice, keyboards & printers into & from their laptops, so they don't see why a USB drive should be any different. XP doesn't complain about a USB drive unsafely removed; Vista's "safely remove" is slightly more obvious (available from a right-click menu) but I don't know if any other improvements (IMO a warning is important) have been made in Vista or Windows 7. Windows does have an option which implies immediate syncs to USB drives, and I'd guess that if this is selected the copy or save file dialogues should remain on the screen until the whole file has been written, thus discouraging the user from unplugging the drive mid- write. I'm sceptical, however. Stroller. ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [gentoo-user] How to set udev rule? 2009-08-30 21:26 ` Alex Schuster 2009-08-31 5:38 ` Jesús Guerrero @ 2009-08-31 16:41 ` Dirk Heinrichs 2009-08-31 19:40 ` Mick 1 sibling, 1 reply; 13+ messages in thread From: Dirk Heinrichs @ 2009-08-31 16:41 UTC (permalink / raw To: gentoo-user [-- Attachment #1: Type: Text/Plain, Size: 2354 bytes --] Am Sonntag 30 August 2009 23:26:52 schrieb Alex Schuster: > Jesús Guerrero writes: > > On Sun, August 30, 2009 21:38, Dirk Heinrichs wrote: > > > Am Sonntag 30 August 2009 19:29:39 schrieb Alex Schuster: > > >> I have to change the bus from usb to scsi, then it works. But what > > >> about unmounting? Is is possible to have it unmounted after I pull the > > >> memory stick? > > > > > > How do want to umount something that's not there anymore? You have to > > > umount _before_ you pull it. > > > > You can force the umount using -l (no, it's not documented in the man > > page). You can use this to umount a volume *after* it has been physically > > removed. > > The -l is not necessary here, a simple umount is enough. > > > And some people use this crap on udev rules to remove the > > volume when they unplug the pendrive. > > Yes, this very rule would be nice to have :) No, it would not. It can (and most likely will) lead to data loss. > I do so, it makes me feel better, but I wonder whether it is _really_ > necessary. Yes, it is. You never know when your data is written to physical storage unless you explicitely synced or umounted it while the device was still connected. > I see Windows users do this all the time, without any problem > yet. Of course, the wait a little after writing to it, but a few seconds > after the blinking stops seem to be enough. Usually it is, but you never know. Windows users don't have that broad choice of filesystems. They have NTFS and that's it, so they may know they're save. Linux filesystems may handle this differently, depending on which one you've chosen. > And people are lazy, I know my > Linux users _will_ just plug the stick. Using the KDE4 automounter, the > device will be unmounted automatically in this case, You mount filesystems, not devices. If you plug the device which holds the filesystem you've mounted, the fs can't be umounted anymore. There's nothing KDE automounter (aka HAL/DBUS) can do about it. > but I am looking for a > solution without KDE4, and as few user interaction as possible. The udev > mouting rule is nice, but it leaves a lot of mounts when plugging in and > out repeatedly. Use the kernel automounter (autofs). It also umounts automatically (after a configurable time). Bye... Dirk [-- Attachment #2: This is a digitally signed message part. --] [-- Type: application/pgp-signature, Size: 190 bytes --] ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [gentoo-user] How to set udev rule? 2009-08-31 16:41 ` Dirk Heinrichs @ 2009-08-31 19:40 ` Mick 0 siblings, 0 replies; 13+ messages in thread From: Mick @ 2009-08-31 19:40 UTC (permalink / raw To: gentoo-user [-- Attachment #1: Type: text/plain, Size: 884 bytes --] On Monday 31 August 2009, Dirk Heinrichs wrote: > > I see Windows users do this all the time, without any problem > > yet. Of course, the wait a little after writing to it, but a few seconds > > after the blinking stops seem to be enough. > > Usually it is, but you never know. Windows users don't have that broad > choice of filesystems. They have NTFS and that's it, so they may know > they're save. Linux filesystems may handle this differently, depending on > which one you've chosen. Nope, NTFS can't cure user stupidity. Only a couple of days ago a friend at work was reprimanded for not clicking on "safely remove", or whatever it's called in WinXP, after I used photorec to recover 350 photographs that she managed to 'lose' from her USB stick. I bet she won't remove another USB drive without unmounting first in a haste ... ;-) -- Regards, Mick [-- Attachment #2: This is a digitally signed message part. --] [-- Type: application/pgp-signature, Size: 198 bytes --] ^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2009-08-31 14:31 UTC | newest] Thread overview: 13+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2009-08-27 7:22 [gentoo-user] How to set udev rule? Song Zhiwei 2009-08-27 10:01 ` KH 2009-08-28 1:51 ` Song Zhiwei 2009-08-28 3:33 ` David Relson 2009-08-30 17:29 ` Alex Schuster 2009-08-30 19:38 ` Dirk Heinrichs 2009-08-30 20:15 ` Jesús Guerrero 2009-08-30 21:13 ` Dale 2009-08-30 21:26 ` Alex Schuster 2009-08-31 5:38 ` Jesús Guerrero 2009-08-31 14:32 ` Stroller 2009-08-31 16:41 ` Dirk Heinrichs 2009-08-31 19:40 ` Mick
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox