Re: [systemd-devel] [libudev] Obtaining /dev/input/eventx

2016-01-24 Thread Robert Milasan
On Sun, 24 Jan 2016 15:23:59 +0100
"Hans-Jacob Enemark" <hjenem...@gmail.com> wrote:

> Is it possible to obtain the /dev/input/eventx path from a given USB
> VID:PID combo or similar info, using libudev?
> If so, how ?
> 

Try examples: https://github.com/robertalks/udev-examples

udev_example2.c can help you get what you want by enumerating all USB
or input (probably the second you want) devices and just getting the
device you want based on attributes.

:~> udevadm info /dev/input/event0|egrep 'SUBSYSTEM|DEVNAME'
E: DEVNAME=/dev/input/event0
E: SUBSYSTEM=input


NOTE: not sure how much of the info you can get, but give it a try.

-- 
Robert Milasan

L3 Support Engineer
SUSE Linux (http://www.suse.com)
email: rmila...@suse.com
GPG fingerprint: B6FE F4A8 0FA3 3040 3402  6FE7 2F64 167C 1909 6D1A
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] udevd detect and list ata devices

2015-12-06 Thread Robert Milasan
On Sun, 6 Dec 2015 01:49:41 +0100
"Marek" <mlf.c...@gmail.com> wrote:

> 
> udev_device_get_sysname(block)
> /sys/devices/pci:00/:00:11.0/ata1/host0/target0:0:0/0:0:0:0/block/sda
> /sys/devices/pci:00/:00:12.2/usb1/1-1/1-1:1.0/host8/target8:0:0/8:0:0:0/block/sdg

Try this examples: https://github.com/robertalks/udev-examples.git

Might help with what you are trying or give you an idea.

-- 
Robert Milasan

L3 Support Engineer
SUSE Linux (http://www.suse.com)
email: rmila...@suse.com
GPG fingerprint: B6FE F4A8 0FA3 3040 3402  6FE7 2F64 167C 1909 6D1A
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] udevd detect and list ata devices

2015-12-06 Thread Robert Milasan
On Sun, 6 Dec 2015 17:46:09 +0100
"Marek" <mlf.c...@gmail.com> wrote:

> thanks Robert, eample2 does list all disks but doens't differentiate
> between ata and usb.

You could add a little hack like this in the udev_example2.c code:

  if (strstr(udev_device_get_syspath(dev), "/ata") != NULL) {

  }

-- 
Robert Milasan

L3 Support Engineer
SUSE Linux (http://www.suse.com)
email: rmila...@suse.com
GPG fingerprint: B6FE F4A8 0FA3 3040 3402  6FE7 2F64 167C 1909 6D1A
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Can udev assist?

2015-11-20 Thread Robert Milasan
On Fri, 20 Nov 2015 09:08:35 -0800
<aaron_wri...@selinc.com> wrote:

> I have a script that creates a partition (using pyparted) and then
> tries to format it (using mkfs.ext4). Most of the time this works OK.
> However, sometimes the format fails because it can't find the device.
> There seems to be a race condition due to a delay between creating a
> partition and the device node in /dev being created.
> Is there a tool in udev or udevadm that can help my script know when
> it safe to proceed?

Try to use:


udevadm settle --exit-if-exists=/dev/


True, you need to come up with the , but if you are using
mkfs.ext4, you need to know the  anyway.

Or you can do a loop for about 5-10 seconds and you
watch /dev/, but is about the same thing as with 'udevadm
settle'.

-- 
Robert Milasan

L3 Support Engineer
SUSE Linux (http://www.suse.com)
email: rmila...@suse.com
GPG fingerprint: B6FE F4A8 0FA3 3040 3402  6FE7 2F64 167C 1909 6D1A
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] udev event on usb unpluged

2015-08-26 Thread Robert Milasan
On Wed, 26 Aug 2015 14:43:35 +0200 (CEST)
christophe.jal...@free.fr wrote:

 can you show how you confirmed your script receive the add event,
 or how the script catch the event?
 
 Sure: basically I do echo USB_$ACTION  /tmp/jc.log.
 After plug/wait/unplugged/wait I only see lines USB_add.
 See attached my .rules and .sh scripts.
 
 
 Can you paste run `udevadm monitor`, plug in your cable/device, wait
 for a second, unplug it, and paste the output?
 
 Well, this is the trick: I cannot add a connection to my device _and_
 the usb cable connected to it. So I am not able to monitor the
 process directly from my device. Does the scripts provided are enough
 to help you understanding my problem ?
 
 Christophe

They are not referring to your device, but the machine on which you are
running the rule.

In a terminal/console you run: udevadm monitor

The do the removal itself and see what 'udevadm monitor' says.


-- 
Robert Milasan

L3 Support Engineer
SUSE Linux (http://www.suse.com)
email: rmila...@suse.com
GPG fingerprint: B6FE F4A8 0FA3 3040 3402  6FE7 2F64 167C 1909 6D1A
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] udev event on usb unpluged

2015-08-26 Thread Robert Milasan
On Wed, 26 Aug 2015 15:32:13 +0200 (CEST)
christophe.jal...@free.fr wrote:

 They are not referring to your device, but the machine on which you
 are
 running the rule.
 In a terminal/console you run: udevadm monitor
 The do the removal itself and see what 'udevadm monitor' says.
 
 this is the problem: the machine which are running the rule is a
 specific robotic device with one usb port and no screen (and no
 network device). Either I connect through ssh using the usb cable
 (eth over usb) or I use the usb cable to test my plug/unplug process.
 I cannot have a console _and_ test the unplugging at the same time.

Then login into that machine and run screen, in which you run:
'udevadm monitor -u -p  /tmp/udev.log 21'

Do the necessary removal of the usb cable or whatever, then attach
the usb cable again, login again and check the log.

 
 Christophe
 


-- 
Robert Milasan

L3 Support Engineer
SUSE Linux (http://www.suse.com)
email: rmila...@suse.com
GPG fingerprint: B6FE F4A8 0FA3 3040 3402  6FE7 2F64 167C 1909 6D1A
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] udev uaccess tag does not support hotplug for some devices

2015-08-20 Thread Robert Milasan
On Thu, 20 Aug 2015 03:26:21 +0800
Tom Yan tom.t...@gmail.com wrote:

 Woo it's a win of almighty grawity again! \o/
 
 My rules works perfectly fine with the 70- prefix just as the shipped
 70-uaccess.rules. Should have thought about it. Any pointer for
 details about the consumed here btw?

Don't get it? consumed what?

P.S. You should restrict your rule a bit, even if it works. Maybe for a
certain subsystem and/or action.

-- 
Robert Milasan

L3 Support Engineer
SUSE Linux (http://www.suse.com)
email: rmila...@suse.com
GPG fingerprint: B6FE F4A8 0FA3 3040 3402  6FE7 2F64 167C 1909 6D1A
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] udev uaccess tag does not support hotplug for some devices

2015-08-19 Thread Robert Milasan
On Wed, 19 Aug 2015 17:45:28 +0800
Tom Yan tom.t...@gmail.com wrote:

 Hi all!
 
 So I added the following rules:
 [tom@localhost ~]$ grep . /etc/udev/rules.d/*
 /etc/udev/rules.d/uas.rules:DRIVERS==uas, TAG+=uaccess
 /etc/udev/rules.d/usb-storage.rules:DRIVERS==usb-storage,
 TAG+=uaccess

Can you try:

ACTION==add|change, SUBSYSTEMS==usb,
ENV{ID_USB_DRIVER}==usb-storage, TAG+=uaccess

in usb-storage.rules ?

You might wanna rename the rule to something like 90-usb-storage.rules,
but thats besides the point.

-- 
Robert Milasan

L3 Support Engineer
SUSE Linux (http://www.suse.com)
email: rmila...@suse.com
GPG fingerprint: B6FE F4A8 0FA3 3040 3402  6FE7 2F64 167C 1909 6D1A
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] udev uaccess tag does not support hotplug for some devices

2015-08-19 Thread Robert Milasan
On Wed, 19 Aug 2015 17:45:28 +0800
Tom Yan tom.t...@gmail.com wrote:

 Hi all!
 
 So I added the following rules:
 [tom@localhost ~]$ grep . /etc/udev/rules.d/*
 /etc/udev/rules.d/uas.rules:DRIVERS==uas, TAG+=uaccess
 /etc/udev/rules.d/usb-storage.rules:DRIVERS==usb-storage,
 TAG+=uaccess
 

I think using DRIVERS is incorrect, but as I dont have all info.

 The rules basically works, but it doesn't support hotplug, that is,
 I have to re-login for newly plugged devices to get the ACLs, and I
 have to do that as well if I replugged the device after I logged in.
 
 However, it doesn't seem to be a universal limitation, because it does
 support hotplug for my SATA optical drive. I enabled hotplug of that
 SATA port in BIOS, unplugged the SATA cable, made sure cdrom
 (symlink) and sr0 are no longer in /dev, then plugged it in again,
 the ACLs remains. I also tried to boot without the optical drive
 connected, and plugged in after login, it also works fine.

Because the rule is different, not implemented the same way as you did.

 
 So could it be a bug of udev or logind, or something wrong with
 certain kernel drivers?
 ___
 systemd-devel mailing list
 systemd-devel@lists.freedesktop.org
 http://lists.freedesktop.org/mailman/listinfo/systemd-devel



-- 
Robert Milasan

L3 Support Engineer
SUSE Linux (http://www.suse.com)
email: rmila...@suse.com
GPG fingerprint: B6FE F4A8 0FA3 3040 3402  6FE7 2F64 167C 1909 6D1A
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Weird udev issue: char device replaced by regular file on suspend

2015-06-26 Thread Robert Milasan
On Thu, 25 Jun 2015 22:07:27 +0200
Johannes Bauer dfnsonfsdu...@gmx.de wrote:

 
 Oh, okay, this would be insanely weird then if it were a kernel bug.
 Do you think LKML is the right place to post this to then?
 


No, I think the suspend-to-RAM scripts should be checked or asked on
the mailing list of the upstream project.

P.S. I didn't say is the kernel to blame, just said that udev is not
involved in creating device nodes anymore and because of this is more
likely whatever scripts are running to do the suspend-to-RAM and not
udev or the kernel.

-- 
Robert Milasan

L3 Support Engineer
SUSE Linux (http://www.suse.com)
email: rmila...@suse.com
GPG fingerprint: B6FE F4A8 0FA3 3040 3402  6FE7 2F64 167C 1909 6D1A
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Weird udev issue: char device replaced by regular file on suspend

2015-06-25 Thread Robert Milasan
On Thu, 25 Jun 2015 21:15:18 +0200
Johannes Bauer dfnsonfsdu...@gmx.de wrote:

 Hi list,
 
 I'm seeing a very odd issue with udev and I'm not really sure which
 component could/would be responsible -- udev is pretty much my only
 hope.
 
 Here's the situation: I have a USB/serial converter attached to my
 computer. It's detected as /dev/ttyUSB0. A program is started as my
 local user (UID 1000) and forks into the background. Every now and
 then it sends one of four characters to this device and reads a bit
 of data back. So far, so good, everything working as expected.
 
 Now the odd thing: When I put my computer into suspend-to-RAM, I'm
 seeing something very odd when the thing wakes back up (about 3 in 4
 times this happens, nondeterministically). The character device
 /dev/ttyUSB0 is replaced by a regular file with 0644 permissions which
 is owned by root:root:
 
 joequad joe [~]: ls /dev/ttyUSB0
 -rw-r--r-- 1 root root 1   25.06.2015 18:09:29 /dev/ttyUSB0
 joequad joe [~]: cat /dev/ttyUSB0 | hexdump -C
   24|$|
 0001
 
 It's one byte long and this one byte is exactly the data that my
 userspace program tried to send. But obviously my user space program
 could not have created that node (no permission to write in /dev,
 obviously, and my program has no suid or anything, runs just as UID
 1000).
 
 Here's what dmesg says when suspending/waking up:
 
 [...] lots of output [...]
 [186649.272605] ark3116 ttyUSB0: ark3116 converter now disconnected
 from ttyUSB0
 [186649.272619] ark3116 7-2.2:1.0: device disconnected
 [186650.452061] ata7: SATA link up 6.0 Gbps (SStatus 133 SControl 300)
 [186650.888603] ACPI Error: [DSSP] Namespace lookup failure,
 AE_NOT_FOUND (20131115/psargs-359)
 [186650.888605] ACPI Error: Method parse/execution failed
 [\_SB_.PCI0.SAT1.SPT2._GTF] (Node 880893e1ae38), AE_NOT_FOUND
 (20131115/psparse-536)
 [186651.030846] ACPI Error: [DSSP] Namespace lookup failure,
 AE_NOT_FOUND (20131115/psargs-359)
 [186651.030849] ACPI Error: Method parse/execution failed
 [\_SB_.PCI0.SAT1.SPT2._GTF] (Node 880893e1ae38), AE_NOT_FOUND
 (20131115/psparse-536)
 [186651.031003] ata7.00: configured for UDMA/133
 [186651.031097] sd 6:0:0:0: [sdc] Starting disk
 [186652.988078] ata6: link is slow to respond, please be patient
 (ready=0) [186655.676059] ata6: SATA link up 3.0 Gbps (SStatus 123
 SControl 300) [186655.679062] ACPI Error: [DSSP] Namespace lookup
 failure, AE_NOT_FOUND (20131115/psargs-359)
 [186655.679069] ACPI Error: Method parse/execution failed
 [\_SB_.PCI0.SAT1.SPT1._GTF] (Node 880893e1adc0), AE_NOT_FOUND
 (20131115/psparse-536)
 [186655.712350] ACPI Error: [DSSP] Namespace lookup failure,
 AE_NOT_FOUND (20131115/psargs-359)
 [186655.712356] ACPI Error: Method parse/execution failed
 [\_SB_.PCI0.SAT1.SPT1._GTF] (Node 880893e1adc0), AE_NOT_FOUND
 (20131115/psparse-536)
 [186655.712521] ata6.00: configured for UDMA/133
 [186655.712640] sd 5:0:0:0: [sdb] Starting disk
 [186655.720875] PM: resume of devices complete after 8128.520 msecs
 [186655.720895] ark3116 7-2.2:1.0: ark3116 converter detected
 [186655.721740] usb 7-2.2: ark3116 using RS232 mode
 [186655.721822] usb 7-2.2: ark3116 converter now attached to ttyUSB0
 [186655.722165] PM: Finishing wakeup.
 
 My userspace program happens to hang in a call to write(2) when the PC
 is put in suspend. The write returns with errno = 5 (I/O error) when
 the PC comes back up.
 
 Another clue is here: I've seen this issue with my old (much slower
 PC) before. But it happened very sporadically, about once every 30
 suspend/wakeup-cycles. I thought this was odd, but blamed some weird
 random component to do this. Now I've switched to a much faster
 computer and am seeing this issue in around 75% of all
 suspend/wakeup-cycles and it's really annoying the hell out of me. So
 I'm guessing there's some kind of race condition involved which hits
 much more often now that my PC is fast enough.
 
 Oh, I'm running Linux Mint on x86_64. udev is version 204.
 
 If you have any hints whatsoever on how I could debug this really
 weird issue, please let me know. I really just don't have a clue how
 to debug udev/this weird phaenomenon.
 

Don't think udev is creating those char devices in such a new version.
I think is handled by the kernel.

I've seen such a bug once, but it was related to /dev/null, some script
or app was remove /dev/null and creating a normal file, don't know why.

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] 60-persistent-storage.rules: add NVMe disks and partitions (again)

2015-05-14 Thread Robert Milasan
On Thu, 14 May 2015 09:10:40 +0200
Per Bergqvist p...@bst.lu wrote:
 
 +KERNEL==nvme*,ENV{DEVTYPE}==disk, ENV{ID_SCSI_SERIAL}==?*,

Wouldn't this make sense: KERNEL==nvme*[!0-9] (this is disk)

 +KERNEL==nvme*,ENV{DEVTYPE}==partition, ENV{ID_SCSI_SERIAL}==?*,

and this KERNEL==nvme*[0-9] (this is partition) ?


-- 
Robert Milasan

L3 Support Engineer
SUSE Linux (http://www.suse.com)
email: rmila...@suse.com
GPG fingerprint: B6FE F4A8 0FA3 3040 3402  6FE7 2F64 167C 1909 6D1A
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH] ata_id: remove unused header files

2015-02-09 Thread Robert Milasan
On Thu, 5 Feb 2015 14:19:35 +0100
Robert Milasan rmila...@suse.com wrote:

 Signed-off-by: Robert Milasan rmila...@suse.com
 ---
  src/udev/ata_id/ata_id.c | 4 
  1 file changed, 4 deletions(-)
 
 diff --git a/src/udev/ata_id/ata_id.c b/src/udev/ata_id/ata_id.c
 index 31bc167..9e4f674 100644
 --- a/src/udev/ata_id/ata_id.c
 +++ b/src/udev/ata_id/ata_id.c
 @@ -34,12 +34,8 @@
  #include sys/ioctl.h
  #include sys/types.h
  #include sys/stat.h
 -#include linux/types.h
  #include linux/hdreg.h
 -#include linux/fs.h
 -#include linux/cdrom.h
  #include linux/bsg.h
 -#include arpa/inet.h
  
  #include libudev.h
  #include libudev-private.h

Ping on this one!

-- 
Robert Milasan

L3 Support Engineer
SUSE Linux (http://www.suse.com)
email: rmila...@suse.com
GPG fingerprint: B6FE F4A8 0FA3 3040 3402  6FE7 2F64 167C 1909 6D1A
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH] ata_id: remove unused header files

2015-02-05 Thread Robert Milasan
Signed-off-by: Robert Milasan rmila...@suse.com
---
 src/udev/ata_id/ata_id.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/src/udev/ata_id/ata_id.c b/src/udev/ata_id/ata_id.c
index 31bc167..9e4f674 100644
--- a/src/udev/ata_id/ata_id.c
+++ b/src/udev/ata_id/ata_id.c
@@ -34,12 +34,8 @@
 #include sys/ioctl.h
 #include sys/types.h
 #include sys/stat.h
-#include linux/types.h
 #include linux/hdreg.h
-#include linux/fs.h
-#include linux/cdrom.h
 #include linux/bsg.h
-#include arpa/inet.h
 
 #include libudev.h
 #include libudev-private.h
-- 
1.8.4.5
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH] udevadm-settle: exit if event execution is disable, even if queue is not empty.

2015-01-23 Thread Robert Milasan
On Fri, 23 Jan 2015 14:31:28 +0100
Kay Sievers k...@vrfy.org wrote:
 
 How does udev_ctrl_get_stop_exec_queue() operate on a ctrl object and
 not a msg?
 
 How would udevadm process incoming control packets, or know that way
 about the state of the running daemon?
 
 If the event execution is disabled, there are pending events and
 settle should block.
 
 The entire idea of disabling the even handling is very questionable,
 what are you trying to do/fix here?
 
 Kay
 

Ahh, damn, I didn't even notice that. Sorry, ignore the patch, but at
least maybe --timeout option in man pages should be rewritten, its not
very clear if for example we stop the exec_queue.

-- 
Robert Milasan

L3 Support Engineer
SUSE Linux (http://www.suse.com)
email: rmila...@suse.com
GPG fingerprint: B6FE F4A8 0FA3 3040 3402  6FE7 2F64 167C 1909 6D1A
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH] udevadm-settle: exit if event execution is disable, even if queue is not empty.

2015-01-23 Thread Robert Milasan
How to reproduce:

run: udevadm control --stop-exec-queue
add: new device, for example a usb stick/disk 
 (it will create /run/udev/queue)
run: udevadm settle --timeout=10

The last command will hang/stall, because it checks constantly
for /run/udev/queue, which exists and always will unless the user
doesn't start the event execution or deletes manually /run/udev/queue.

Signed-off-by: Robert Milasan rmila...@suse.com
---
 src/udev/udevadm-settle.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/src/udev/udevadm-settle.c b/src/udev/udevadm-settle.c
index 6bcb3a9..80529ce 100644
--- a/src/udev/udevadm-settle.c
+++ b/src/udev/udevadm-settle.c
@@ -116,6 +116,11 @@ static int adm_settle(struct udev *udev, int argc,
char *argv[]) { udev_ctrl_unref(uctrl);
 return EXIT_SUCCESS;
 }
+if (udev_ctrl_get_stop_exec_queue(uctrl)  0) {
+log_debug(event execution disabled);
+udev_ctrl_unref(uctrl);
+return EXIT_SUCCESS;
+}
 udev_ctrl_unref(uctrl);
 }
 }
-- 
1.8.4.5
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH] cdrom_id: unmount media on --eject-media if media mounted

2015-01-15 Thread Robert Milasan
On Thu, 15 Jan 2015 17:05:54 +0100
Lennart Poettering lenn...@poettering.net wrote:
 
 I think the best way to fix this is in the kernel properly. And if the
 kernel folks are not willing to do add code for that, then I think
 it's still better to make sure systemd unmounts it. It can do so
 asynchronously, simply via the right dependencies. In fact, are you
 sure that this isn't handled properly yet anyway? The .mount units
 would just need a BindsTo= on the .device units, and the right thing
 should happen?
 

Got no clue, didn't try.

I never said that adding the code to cdrom_id is the best idea, but
it's an idea. If there are better ways, I prefer them too.


-- 
Robert Milasan

L3 Support Engineer
SUSE Linux (http://www.suse.com)
email: rmila...@suse.com
GPG fingerprint: B6FE F4A8 0FA3 3040 3402  6FE7 2F64 167C 1909 6D1A
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] cdrom_id and 60-cdrom_id.rules behavior

2015-01-15 Thread Robert Milasan
On Thu, 15 Jan 2015 11:38:33 +0100
Martin Pitt martin.p...@ubuntu.com wrote:

 Oliver Neukum [2015-01-15 11:31 +0100]:
  No, the events are generated. And it is processed.
  There is just no unmounting.
 
 That sounds like a bug/missing feature in cdrom_id --eject-media then.
 You could try and replace it with /usr/bin/eject, which does the
 unmounting of all partitions first, fail on busy, and does the eject
 at last?
 
  But what is the motivation of in effect disabling door locking?
 
 We don't -- we specifically leave it locked so that we get the eject
 button pressed events. (See my other response for some details).
 
 Martin

We could add the unmount functionality also to cdrom_id if we are on
the subject.

-- 
Robert Milasan

L3 Support Engineer
SUSE Linux (http://www.suse.com)
email: rmila...@suse.com
GPG fingerprint: B6FE F4A8 0FA3 3040 3402  6FE7 2F64 167C 1909 6D1A
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] cdrom_id and 60-cdrom_id.rules behavior

2015-01-15 Thread Robert Milasan
On Thu, 15 Jan 2015 11:39:36 +0100
Robert Milasan rmila...@suse.com wrote:

 On Thu, 15 Jan 2015 11:31:48 +0100
 Oliver Neukum oneu...@suse.de wrote:
 
  On Thu, 2015-01-15 at 09:03 +0100, Martin Pitt wrote:
- udev rules (60-cdrom_id.rules) picks that up and calls eject
  /dev/srX on the device; the eject program takes care to
   unmount everything before physical ejection.
   
   Note that the kernel will *not* generate DISK_EJECT_REQUEST
   uevents if the tray is not locked. Your case sounds exactly like
   that?
  
  No, the events are generated. And it is processed.
  There is just no unmounting.
  
  But what is the motivation of in effect disabling door locking?
  
  Regards
  Oliver
  
  
 
 Unmounting usually happens, but only in the desktop environment, most
 probably because of udisk2 or whatever is called.
 In console mode or server mode lets say, if the media is mounted
 (usually manually) it is not unmounted if I press the eject button on
 the driver, on the other hand it is not unmounted even if I would use
 eject command, because none of this commands or the hardware button
 are aware of the media being mounted and it also makes sense. In
 Gnome/KDE the mount is not done by user but by the actual software,
 using most probably fuse or something like that and Gnome/KDE is
 aware when the disk is ejected, similar to a USB stick (I might be
 wrong).
 
 

Sorry, eject command is aware and it will unmount the media if mounted.
My bad.

-- 
Robert Milasan

L3 Support Engineer
SUSE Linux (http://www.suse.com)
email: rmila...@suse.com
GPG fingerprint: B6FE F4A8 0FA3 3040 3402  6FE7 2F64 167C 1909 6D1A
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] cdrom_id and 60-cdrom_id.rules behavior

2015-01-15 Thread Robert Milasan
On Thu, 15 Jan 2015 12:22:50 +0100
Robert Milasan rmila...@suse.com wrote:

 On Thu, 15 Jan 2015 12:00:15 +0100
 Oliver Neukum oneu...@suse.de wrote:
 
  On Thu, 2015-01-15 at 11:38 +0100, Martin Pitt wrote:
   Oliver Neukum [2015-01-15 11:31 +0100]:
No, the events are generated. And it is processed.
There is just no unmounting.
   
   That sounds like a bug/missing feature in cdrom_id --eject-media
   then. You could try and replace it with /usr/bin/eject, which does
   the unmounting of all partitions first, fail on busy, and does the
   eject at last?
  
  That does work.
  
But what is the motivation of in effect disabling door locking?
   
   We don't -- we specifically leave it locked so that we get the
   eject button pressed events. (See my other response for some
   details).
  
  Well, yes, but why is policy that should be left to the GUI placed
  into udev?
  
  Regards
  Oliver
  
  
 
 What about this little bundle of joy, the patch I mean, of course.
 Please check attachment :)
 
 Might need work, but the basic idea seems to work, at least in my
 tests.
 

Forget about the patch. If we are using cdrom_id from the console, it
actually works and unmounts the media, but not from within a udev rule.
Need to see why and will get back.

-- 
Robert Milasan

L3 Support Engineer
SUSE Linux (http://www.suse.com)
email: rmila...@suse.com
GPG fingerprint: B6FE F4A8 0FA3 3040 3402  6FE7 2F64 167C 1909 6D1A
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH] cdrom_id: unmount media on --eject-media if media mounted

2015-01-15 Thread Robert Milasan
Signed-off-by: Robert Milasan rmila...@suse.com
---
 src/udev/cdrom_id/cdrom_id.c | 35 +++
 1 file changed, 35 insertions(+)

diff --git a/src/udev/cdrom_id/cdrom_id.c b/src/udev/cdrom_id/cdrom_id.c
index 6052f6a..72a1357 100644
--- a/src/udev/cdrom_id/cdrom_id.c
+++ b/src/udev/cdrom_id/cdrom_id.c
@@ -217,6 +217,39 @@ static int media_eject(struct udev *udev, int fd)
 return 0;
 }
 
+static int media_umount(const char *node)
+{
+int err = 0;
+
+if (!node) {
+err = -1;
+goto exit;
+}
+
+if (is_mounted(node)) {
+pid_t pid;
+
+pid = fork();
+switch (pid) {
+case 0:
+err = execl(/bin/umount, /bin/umount,
node, NULL);
+if (err  0) {
+log_error(umount failed\n);
+goto exit;
+}
+case -1:
+log_error(failed to fork\n);
+err = -1;
+break;
+default:
+break;
+}
+}
+
+exit:
+return err;
+}
+
 static int cd_capability_compat(struct udev *udev, int fd)
 {
 int capability;
@@ -969,6 +1002,8 @@ work:
 }
 
 if (eject) {
+log_debug(UNMOUNT_MEDIA (umount)\n);
+media_umount(node);
 log_debug(PREVENT_ALLOW_MEDIUM_REMOVAL (unlock));
 media_lock(udev, fd, false);
 log_debug(START_STOP_UNIT (eject));
-- 
1.8.4.5
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] cdrom_id and 60-cdrom_id.rules behavior

2015-01-12 Thread Robert Milasan
Hello, a while back, around 2011, in cdrom_id was added --eject-media,
--lock-media and --unlock-media for not much explanation.

Now, recently some people noticed that this might actually be a
problem. 

Reference: http://bugzilla.opensuse.org/show_bug.cgi?id=909418

Here is a scenario:

1. add a CD/DVD into the driver
2. mount the driver: mount /dev/sr0 /mnt/my_cd (ensure you don't
use the Gnome/KDE auto-mounting or reproduce this in a server setup)
3. eject the media (using the hardware button) and add a new one media
(different disk)
4. ls /mnt/my_cd (it will be an empty output or the previous media)

Is this expected? Also, I remember a while back (long time ago) that
once you added a media into the driver and it was properly mounted, you
couldn't eject the media until you unmounted the media.

NOTE: This works somewhat OK in the desktop setup, probably due to
udisks (using Gnome/KDE), but in the console not really.

-- 
Robert Milasan

L3 Support Engineer
SUSE Linux (http://www.suse.com)
email: rmila...@suse.com
GPG fingerprint: B6FE F4A8 0FA3 3040 3402  6FE7 2F64 167C 1909 6D1A
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH] improve help/usage for some more programs

2015-01-01 Thread Robert Milasan
On Thu, 1 Jan 2015 18:07:59 +0100
Zbigniew J*drzejewski-Szmek zbys...@in.waw.pl wrote:

 Patch is wrapped. Please resend, (git send-email preferably,
 as an attachment otherwise).
 
 Zbyszek
 

-- 
Robert Milasan

L3 Support Engineer
SUSE Linux (http://www.suse.com)
email: rmila...@suse.com
GPG fingerprint: B6FE F4A8 0FA3 3040 3402  6FE7 2F64 167C 1909 6D1A
From 9cd266590dbf1d22b1a7fc184ecc8c3868f280f9 Mon Sep 17 00:00:00 2001
From: Robert Milasan rmila...@suse.com
Date: Wed, 31 Dec 2014 13:17:23 +0100
Subject: [PATCH] improve help/usage for some more programs

---
 src/udev/ata_id/ata_id.c |  4 ++--
 src/udev/cdrom_id/cdrom_id.c | 10 +-
 src/udev/collect/collect.c   | 10 ++
 src/udev/scsi_id/scsi_id.c   |  2 +-
 src/udev/v4l_id/v4l_id.c |  2 +-
 5 files changed, 15 insertions(+), 13 deletions(-)

diff --git a/src/udev/ata_id/ata_id.c b/src/udev/ata_id/ata_id.c
index e6344f9..31bc167 100644
--- a/src/udev/ata_id/ata_id.c
+++ b/src/udev/ata_id/ata_id.c
@@ -450,8 +450,8 @@ int main(int argc, char *argv[])
 break;
 case 'h':
 printf(Usage: ata_id [--export] [--help] device\n
- --exportprint values as environment keys\n
- --help  print this help text\n\n);
+ -x,--exportprint values as environment keys\n
+ -h,--help  print this help text\n\n);
 return 0;
 }
 }
diff --git a/src/udev/cdrom_id/cdrom_id.c b/src/udev/cdrom_id/cdrom_id.c
index 8a41c4f..6052f6a 100644
--- a/src/udev/cdrom_id/cdrom_id.c
+++ b/src/udev/cdrom_id/cdrom_id.c
@@ -891,11 +891,11 @@ int main(int argc, char *argv[])
 break;
 case 'h':
 printf(Usage: cdrom_id [options] device\n
- --lock-medialock the media (to enable eject request events)\n
- --unlock-media  unlock the media\n
- --eject-media   eject the media\n
- --debug debug to stderr\n
- --help  print this help text\n\n);
+ -l,--lock-medialock the media (to enable eject request events)\n
+ -u,--unlock-media  unlock the media\n
+ -e,--eject-media   eject the media\n
+ -d,--debug debug to stderr\n
+ -h,--help  print this help text\n\n);
 goto exit;
 default:
 rc = 1;
diff --git a/src/udev/collect/collect.c b/src/udev/collect/collect.c
index 16675fb..11a618c 100644
--- a/src/udev/collect/collect.c
+++ b/src/udev/collect/collect.c
@@ -68,15 +68,17 @@ noreturn static void sig_alrm(int signo)
 
 static void usage(void)
 {
-printf(usage: collect [--add|--remove] [--debug] checkpoint id idlist\n
-   \n
+printf(Usage: collect [options] checkpoint id idlist\n
+ -a,--add add ID id to the list idlist\n
+ -r,--remove  remove ID id from the list idlist\n
+ -d,--debug   debug to stderr\n
+ -h,--helpprint this help text\n\n
  Adds ID id to the list governed by checkpoint.\n
  id must be part of the list idlist.\n
  If all IDs given by idlist are listed (ie collect has been\n
  invoked for each ID in idlist) collect returns 0, the\n
  number of missing IDs otherwise.\n
- On error a negative number is returned.\n
-   \n);
+ On error a negative number is returned.\n\n);
 }
 
 /*
diff --git a/src/udev/scsi_id/scsi_id.c b/src/udev/scsi_id/scsi_id.c
index 27adb09..5270233 100644
--- a/src/udev/scsi_id/scsi_id.c
+++ b/src/udev/scsi_id/scsi_id.c
@@ -313,7 +313,7 @@ static void help(void) {
  -g,--whitelisted treat device as whitelisted\n
  -u,--replace-whitespace  replace all whitespace by underscores\n
  -v,--verbose verbose logging\n
---version print version\n
+ -V,--version print version\n
  -x,--export  print values as environment keys\n
  -h,--helpprint this help text\n\n);
 
diff --git a/src/udev/v4l_id/v4l_id.c b/src/udev/v4l_id/v4l_id.c
index d5463b2..08d3efa 100644
--- a/src/udev/v4l_id/v4l_id.c
+++ b/src/udev/v4l_id/v4l_id.c
@@ -45,7 +45,7 @@ int main (int argc, char *argv[])
 
 switch (option) {
 case 'h':
-printf(Usage

[systemd-devel] [PATCH] improve help/usage for some more programs

2014-12-31 Thread Robert Milasan
---
 src/udev/ata_id/ata_id.c |  4 ++--
 src/udev/cdrom_id/cdrom_id.c | 10 +-
 src/udev/collect/collect.c   | 10 ++
 src/udev/scsi_id/scsi_id.c   |  2 +-
 src/udev/v4l_id/v4l_id.c |  2 +-
 5 files changed, 15 insertions(+), 13 deletions(-)

diff --git a/src/udev/ata_id/ata_id.c b/src/udev/ata_id/ata_id.c
index e6344f9..31bc167 100644
--- a/src/udev/ata_id/ata_id.c
+++ b/src/udev/ata_id/ata_id.c
@@ -450,8 +450,8 @@ int main(int argc, char *argv[])
 break;
 case 'h':
 printf(Usage: ata_id [--export] [--help]
device\n
- --exportprint values as
environment keys\n
- --help  print this help
text\n\n);
+ -x,--exportprint values as
environment keys\n
+ -h,--help  print this help
text\n\n); return 0;
 }
 }
diff --git a/src/udev/cdrom_id/cdrom_id.c b/src/udev/cdrom_id/cdrom_id.c
index 8a41c4f..6052f6a 100644
--- a/src/udev/cdrom_id/cdrom_id.c
+++ b/src/udev/cdrom_id/cdrom_id.c
@@ -891,11 +891,11 @@ int main(int argc, char *argv[])
 break;
 case 'h':
 printf(Usage: cdrom_id [options] device\n
- --lock-medialock the media (to
enable eject request events)\n
- --unlock-media  unlock the media\n
- --eject-media   eject the media\n
- --debug debug to stderr\n
- --help  print this help
text\n\n);
+ -l,--lock-medialock the media
(to enable eject request events)\n
+ -u,--unlock-media  unlock the
media\n
+ -e,--eject-media   eject the media\n
+ -d,--debug debug to stderr\n
+ -h,--help  print this help
text\n\n); goto exit;
 default:
 rc = 1;
diff --git a/src/udev/collect/collect.c b/src/udev/collect/collect.c
index 16675fb..11a618c 100644
--- a/src/udev/collect/collect.c
+++ b/src/udev/collect/collect.c
@@ -68,15 +68,17 @@ noreturn static void sig_alrm(int signo)
 
 static void usage(void)
 {
-printf(usage: collect [--add|--remove] [--debug] checkpoint
id idlist\n
-   \n
+printf(Usage: collect [options] checkpoint id idlist\n
+ -a,--add add ID id to the list idlist\n
+ -r,--remove  remove ID id from the list
idlist\n
+ -d,--debug   debug to stderr\n
+ -h,--helpprint this help text\n\n
  Adds ID id to the list governed by checkpoint.\n
  id must be part of the list idlist.\n
  If all IDs given by idlist are listed (ie collect
has been\n   invoked for each ID in idlist) collect returns 0,
the\n   number of missing IDs otherwise.\n
- On error a negative number is returned.\n
-   \n);
+ On error a negative number is returned.\n\n);
 }
 
 /*
diff --git a/src/udev/scsi_id/scsi_id.c b/src/udev/scsi_id/scsi_id.c
index 27adb09..5270233 100644
--- a/src/udev/scsi_id/scsi_id.c
+++ b/src/udev/scsi_id/scsi_id.c
@@ -313,7 +313,7 @@ static void help(void) {
  -g,--whitelisted treat device as
whitelisted\n   -u,--replace-whitespace  replace all
whitespace by underscores\n   -v,--verbose
verbose logging\n
---version print version\n
+ -V,--version print version\n
  -x,--export  print values as
environment keys\n   -h,--helpprint this help
text\n\n); 
diff --git a/src/udev/v4l_id/v4l_id.c b/src/udev/v4l_id/v4l_id.c
index d5463b2..08d3efa 100644
--- a/src/udev/v4l_id/v4l_id.c
+++ b/src/udev/v4l_id/v4l_id.c
@@ -45,7 +45,7 @@ int main (int argc, char *argv[])
 
 switch (option) {
 case 'h':
-printf(Usage: v4l_id [--help] device
file\n\n);
+printf(Usage: v4l_id [-h,--help] device
file\n\n); return 0;
 default:
 return 1;
-- 
1.8.4.5
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] Small fixes to accelerometer

2014-12-30 Thread Robert Milasan
As in the subject, check attached patch.

Found 2 problems:

1. -x option not in use, so we should just drop it from the code
2. we support long and short options, but we advertise only long ones.


-- 
Robert Milasan

L3 Support Engineer
SUSE Linux (http://www.suse.com)
email: rmila...@suse.com
GPG fingerprint: B6FE F4A8 0FA3 3040 3402  6FE7 2F64 167C 1909 6D1A
From 7aaa2c1b6b6a6d0ef391610e932d6eff010dea41 Mon Sep 17 00:00:00 2001
From: Robert Milasan rmila...@suse.com
Date: Tue, 30 Dec 2014 09:20:42 +0100
Subject: [PATCH] accelerometer: drop unused -x option, display short options
 too.

---
 src/udev/accelerometer/accelerometer.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/udev/accelerometer/accelerometer.c b/src/udev/accelerometer/accelerometer.c
index dd4b7dc..9c13d97 100644
--- a/src/udev/accelerometer/accelerometer.c
+++ b/src/udev/accelerometer/accelerometer.c
@@ -198,8 +198,8 @@ static void test_orientation(struct udev *udev,
 static void help(void)
 {
 printf(Usage: accelerometer [options] device path\n
- --debug debug to stderr\n
- --help  print this help text\n\n);
+ -d,--debug debug to stderr\n
+ -h,--help  print this help text\n\n);
 }
 
 int main (int argc, char** argv)
@@ -229,7 +229,7 @@ int main (int argc, char** argv)
 while (1) {
 int option;
 
-option = getopt_long(argc, argv, dxh, options, NULL);
+option = getopt_long(argc, argv, dh, options, NULL);
 if (option == -1)
 break;
 
-- 
1.8.4.5

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH 1/2] accelerometer: drop unused -x option

2014-12-30 Thread Robert Milasan
---
 src/udev/accelerometer/accelerometer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/udev/accelerometer/accelerometer.c
b/src/udev/accelerometer/accelerometer.c index dd4b7dc..23d6f78 100644
--- a/src/udev/accelerometer/accelerometer.c
+++ b/src/udev/accelerometer/accelerometer.c
@@ -229,7 +229,7 @@ int main (int argc, char** argv)
 while (1) {
 int option;
 
-option = getopt_long(argc, argv, dxh, options, NULL);
+option = getopt_long(argc, argv, dh, options, NULL);
 if (option == -1)
 break;
 
-- 
1.8.4.5
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH 2/2] accelerometer: display short options too

2014-12-30 Thread Robert Milasan
---
 src/udev/accelerometer/accelerometer.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/udev/accelerometer/accelerometer.c
b/src/udev/accelerometer/accelerometer.c index 23d6f78..9c13d97 100644
--- a/src/udev/accelerometer/accelerometer.c
+++ b/src/udev/accelerometer/accelerometer.c
@@ -198,8 +198,8 @@ static void test_orientation(struct udev *udev,
 static void help(void)
 {
 printf(Usage: accelerometer [options] device path\n
- --debug debug to stderr\n
- --help  print this help text\n\n);
+ -d,--debug debug to stderr\n
+ -h,--help  print this help text\n\n);
 }
 
 int main (int argc, char** argv)
-- 
1.8.4.5
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] udevd: increase maximum number of children

2014-11-28 Thread Robert Milasan
On Fri, 28 Nov 2014 13:51:04 +0100
Tom Gundersen t...@jklm.no wrote:
 
  Also the patch changes the logging level of 'maximum number of
  children reached' to an error, this should be visible as an error
  when the number has been reached.
 
 I don't think an error is appropriate here (as nothing actually
 fails). At most a warning I would say.
 
 Cheers,
 
 Tom
 

This is an error, because the behavior makes the system not work
correctly.

I don't care about a warning that much, but in this case and reference
bug, we see a bug and/or an error which is causes by the small amount of
children, or the impossibility of udev daemon to create new
children/workers, stopping the queue processing until the number of
children is lower the children_max.

Anyway, please do as you wish as long as it gets fixed.

-- 
Robert Milasan

L3 Support Engineer
SUSE Linux (http://www.suse.com)
email: rmila...@suse.com
GPG fingerprint: B6FE F4A8 0FA3 3040 3402  6FE7 2F64 167C 1909 6D1A
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] udevd: increase maximum number of children

2014-11-28 Thread Robert Milasan
On Fri, 28 Nov 2014 14:28:31 +0100
Harald Hoyer harald.ho...@gmail.com wrote:

 
 I think what we are seeing here is, that module loading saturates the
 udev workers here. So there are at least 16 modprobes (kmod) running
 and this hinders further processing of the uevents.
 
 In theory we could increase arg_children_max before builtin_kmod()
 and decrease it again afterwards.
 
 CC'ing Kay
 ___

Ok, I've decreased the arg_children_max number from CPU_COUNT * 256 to
CPU_COUNT * 64. You where right, it was a bit too much.

-- 
Robert Milasan

L3 Support Engineer
SUSE Linux (http://www.suse.com)
email: rmila...@suse.com
GPG fingerprint: B6FE F4A8 0FA3 3040 3402  6FE7 2F64 167C 1909 6D1A
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] udevd: increase maximum number of children

2014-11-27 Thread Robert Milasan
Hello, since a while back, there was a commit (haven't found it) which
limits the number of children/workers to 8 + num_cpu * 2, which in a
normal case like a 4 core/cpu machine is 16 children/workers.

This limit is way too low even for a single core VM, that actually
means 10 children/workers.

I've attached the patch which increased this number to 8 + num_cpu *
256, which is 1032 for a 4 core/cpu machine and 264 for a
single core/cpu machine.

Also the patch changes the logging level of 'maximum number of children
reached' to an error, this should be visible as an error when the
number has been reached.

Reference bug: http://bugzilla.opensuse.org/show_bug.cgi?id=907393

-- 
Robert Milasan

L3 Support Engineer
SUSE Linux (http://www.suse.com)
email: rmila...@suse.com
GPG fingerprint: B6FE F4A8 0FA3 3040 3402  6FE7 2F64 167C 1909 6D1A
From 4fb50b784c7aa6f5ea9cdf2e5a65ba48a2b9ce1b Mon Sep 17 00:00:00 2001
From: Robert Milasan rmila...@suse.com
Date: Fri, 28 Nov 2014 08:49:38 +0100
Subject: [PATCH] udevd: increase maximum number of children

Signed-off-by: Robert Milasan rmila...@suse.com
---
 src/udev/udevd.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/udev/udevd.c b/src/udev/udevd.c
index 3c3de76..c327c38 100644
--- a/src/udev/udevd.c
+++ b/src/udev/udevd.c
@@ -445,7 +445,7 @@ static void event_run(struct event *event) {
 
 if (children = arg_children_max) {
 if (arg_children_max  1)
-log_debug(maximum number (%i) of children reached, children);
+log_error(maximum number (%i) of children reached, children);
 return;
 }
 
@@ -1270,7 +1270,7 @@ int main(int argc, char *argv[]) {
 arg_children_max = 8;
 
 if (sched_getaffinity(0, sizeof (cpu_set), cpu_set) == 0) {
-arg_children_max +=  CPU_COUNT(cpu_set) * 2;
+arg_children_max += CPU_COUNT(cpu_set) * 256;
 }
 }
 log_debug(set children_max to %u, arg_children_max);
-- 
1.8.4.5

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH] udev: always resolve correctly database names on 'change' event

2014-09-15 Thread Robert Milasan
On Sat, 13 Sep 2014 15:29:23 +0200
Robert Milasan rmila...@suse.com wrote:

 Hello, I've found a lingering bug in udev since udev changed it's
 database name from long names to short names 'ex: b9:1'.
 
 The bug is more visible or reproducible on s390(x) has there, we can
 remove and add dasd disk/partitions.
 
 The outcome of the bug is that when removing and re-adding a
 disk/partition, most or some of the links are not removed correctly or
 at all. This leads to multiple UUID links for a single partition or
 stale links in /dev/disk/{by-uuid,by-id}.
 
 How to reproduce:
 
 dasdfmt -b 4096 -v -y -f /dev/dasdb
 fdasd -a /dev/dasdb
 mke2fs /dev/dasdb1
 
 repeat this again and you will notice that /dev/dasdb1 has 2 or more
 UUID links in /dev/disk/by-uuid.
 
 If you do not repeat this, just do 'dasdfmt -b 4096 -v -y
 -f /dev/dasdb' the UUID link to /dev/dasdb1 will be stale, just the
 same as /dev/disk/by-id links.
 
 NOTE: this bug might affect x86 machines too, but it might not be
 visible (not sure).
 
 The issue is due to when there is a change event before the remove
 event for dasdb/dasdb1, we are trying to resolve the database name
 into 'blockmajor:minor', but event-dev_db doesn't get fill-up
 with devnum (major:minor) information, resulting in a database
 name +block:dasdb1, which doesn't exist.
 
 I've attached the patch, please review it and push it if there is no
 complains :)
 

Will anybody be so kind and push the patch to systemd git.

-- 
Robert Milasan

L3 Support Engineer
SUSE Linux (http://www.suse.com)
email: rmila...@suse.com
GPG fingerprint: B6FE F4A8 0FA3 3040 3402  6FE7 2F64 167C 1909 6D1A
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH] udev: always resolve correctly database names on 'change' event

2014-09-13 Thread Robert Milasan
Hello, I've found a lingering bug in udev since udev changed it's
database name from long names to short names 'ex: b9:1'.

The bug is more visible or reproducible on s390(x) has there, we can
remove and add dasd disk/partitions.

The outcome of the bug is that when removing and re-adding a
disk/partition, most or some of the links are not removed correctly or
at all. This leads to multiple UUID links for a single partition or
stale links in /dev/disk/{by-uuid,by-id}.

How to reproduce:

dasdfmt -b 4096 -v -y -f /dev/dasdb
fdasd -a /dev/dasdb
mke2fs /dev/dasdb1

repeat this again and you will notice that /dev/dasdb1 has 2 or more
UUID links in /dev/disk/by-uuid.

If you do not repeat this, just do 'dasdfmt -b 4096 -v -y
-f /dev/dasdb' the UUID link to /dev/dasdb1 will be stale, just the
same as /dev/disk/by-id links.

NOTE: this bug might affect x86 machines too, but it might not be
visible (not sure).

The issue is due to when there is a change event before the remove
event for dasdb/dasdb1, we are trying to resolve the database name into
'blockmajor:minor', but event-dev_db doesn't get fill-up with
devnum (major:minor) information, resulting in a database name
+block:dasdb1, which doesn't exist.

I've attached the patch, please review it and push it if there is no
complains :)

-- 
Robert Milasan

L3 Support Engineer
SUSE Linux (http://www.suse.com)
email: rmila...@suse.com
GPG fingerprint: B6FE F4A8 0FA3 3040 3402  6FE7 2F64 167C 1909 6D1A
From 368082520b25722575783f06879fb5fc2e4c219c Mon Sep 17 00:00:00 2001
From: Robert Milasan rmila...@suse.com
Date: Sat, 13 Sep 2014 15:18:37 +0200
Subject: [PATCH] udev: always resolve correctly database names on 'change'
 event

Signed-off-by: Robert Milasan rmila...@suse.com
---
 src/libudev/libudev-device.c  | 2 +-
 src/libudev/libudev-private.h | 1 +
 src/udev/udev-event.c | 1 +
 3 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/libudev/libudev-device.c b/src/libudev/libudev-device.c
index d61a2ad..2699374 100644
--- a/src/libudev/libudev-device.c
+++ b/src/libudev/libudev-device.c
@@ -161,7 +161,7 @@ _public_ dev_t udev_device_get_devnum(struct udev_device *udev_device)
 return udev_device-devnum;
 }
 
-static int udev_device_set_devnum(struct udev_device *udev_device, dev_t devnum)
+int udev_device_set_devnum(struct udev_device *udev_device, dev_t devnum)
 {
 char num[32];
 
diff --git a/src/libudev/libudev-private.h b/src/libudev/libudev-private.h
index 35ea7ba..05a6410 100644
--- a/src/libudev/libudev-private.h
+++ b/src/libudev/libudev-private.h
@@ -59,6 +59,7 @@ uid_t udev_device_get_devnode_uid(struct udev_device *udev_device);
 gid_t udev_device_get_devnode_gid(struct udev_device *udev_device);
 int udev_device_set_subsystem(struct udev_device *udev_device, const char *subsystem);
 int udev_device_set_syspath(struct udev_device *udev_device, const char *syspath);
+int udev_device_set_devnum(struct udev_device *udev_device, dev_t devnum);
 int udev_device_add_devlink(struct udev_device *udev_device, const char *devlink);
 void udev_device_cleanup_devlinks_list(struct udev_device *udev_device);
 struct udev_list_entry *udev_device_add_property(struct udev_device *udev_device, const char *key, const char *value);
diff --git a/src/udev/udev-event.c b/src/udev/udev-event.c
index e8d6676..2cf0763 100644
--- a/src/udev/udev-event.c
+++ b/src/udev/udev-event.c
@@ -812,6 +812,7 @@ void udev_event_execute_rules(struct udev_event *event,
 if (event-dev_db != NULL) {
 udev_device_set_syspath(event-dev_db, udev_device_get_syspath(dev));
 udev_device_set_subsystem(event-dev_db, udev_device_get_subsystem(dev));
+udev_device_set_devnum(event-dev_db, udev_device_get_devnum(dev));
 udev_device_read_db(event-dev_db, NULL);
 udev_device_set_info_loaded(event-dev_db);
 
-- 
1.8.4.5

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] udev: unable to flock(/dev/sda), skipping event

2014-06-24 Thread Robert Milasan
Hi, we are getting this error on one of our machines. The machine is a
xen host running systemd/udev 210.

Does anybody know why are we getting this errors:

Jun 24 11:15:08 linux systemd-udevd[240]: seq 1232 running
Jun 24 11:15:08 linux systemd-udevd[240]: device 0x7d6930 has devpath
'/devices/
Jun 24 11:15:08 linux systemd-udevd[240]: Unable to flock(/dev/sda),
skipping ev
Jun 24 11:15:08 linux systemd-udevd[240]: seq 1232 processed with -11

Is sda block by some other processes?

-- 
Robert Milasan

L3 Support Engineer
SUSE Linux (http://www.suse.com)
email: rmila...@suse.com
GPG fingerprint: B6FE F4A8 0FA3 3040 3402  6FE7 2F64 167C 1909 6D1A
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] udev: unable to flock(/dev/sda), skipping event

2014-06-24 Thread Robert Milasan
On Tue, 24 Jun 2014 11:38:17 +0200
Robert Milasan rmila...@suse.com wrote:

 Hi, we are getting this error on one of our machines. The machine is a
 xen host running systemd/udev 210.
 
 Does anybody know why are we getting this errors:
 
 Jun 24 11:15:08 linux systemd-udevd[240]: seq 1232 running
 Jun 24 11:15:08 linux systemd-udevd[240]: device 0x7d6930 has devpath
 '/devices/
 Jun 24 11:15:08 linux systemd-udevd[240]: Unable to flock(/dev/sda),
 skipping ev
 Jun 24 11:15:08 linux systemd-udevd[240]: seq 1232 processed with -11
 
 Is sda block by some other processes?
 

The full error is:

Jun 24 11:15:07 linux systemd-udevd[240]: device 0x7c0300 has devpath
'/devices/pci:00/:00:1f.2/ata3/host2/target2:0:0/2:0:0:0/block/sda'
Jun 24 11:15:07 linux systemd-udevd[240]: Unable to flock(/dev/sda),
skipping event handling: Resource temporarily unavailable Jun 24
11:15:07 linux systemd-udevd[240]: seq 1231 processed with -11

Maybe it helps

-- 
Robert Milasan

L3 Support Engineer
SUSE Linux (http://www.suse.com)
email: rmila...@suse.com
GPG fingerprint: B6FE F4A8 0FA3 3040 3402  6FE7 2F64 167C 1909 6D1A
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] udev: unable to flock(/dev/sda), skipping event

2014-06-24 Thread Robert Milasan
On Tue, 24 Jun 2014 12:22:35 +0200
Kay Sievers k...@vrfy.org wrote:

 On Tue, Jun 24, 2014 at 11:58 AM, Robert Milasan rmila...@suse.com
 wrote:
  On Tue, 24 Jun 2014 11:38:17 +0200
  Robert Milasan rmila...@suse.com wrote:
 
  Hi, we are getting this error on one of our machines. The machine
  is a xen host running systemd/udev 210.
 
 First, systemd 210 has no locking logic at all. Please specify what
 exactly you patched into 210.
 
 Kay
 

Commit: 3ebdb81ef088afd3b4c72b516beb5610f8c93a0d

-- 
Robert Milasan

L3 Support Engineer
SUSE Linux (http://www.suse.com)
email: rmila...@suse.com
GPG fingerprint: B6FE F4A8 0FA3 3040 3402  6FE7 2F64 167C 1909 6D1A
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] udevd: skip cd/dvd devices in synthesize_change

2014-06-18 Thread Robert Milasan
If we are running udevd from a LiveCD or ISO image, it can happen that
udevd wont find the cd/dvd in time, causing a failure.

I've attached the patch which seems to fix the issue.

-- 
Robert Milasan

L3 Support Engineer
SUSE Linux (http://www.suse.com)
email: rmila...@suse.com
GPG fingerprint: B6FE F4A8 0FA3 3040 3402  6FE7 2F64 167C 1909 6D1A
From 37ff27dcd84dd835b2e148b86044c3ad5fd8 Mon Sep 17 00:00:00 2001
From: Robert Milasan rmila...@suse.com
Date: Wed, 18 Jun 2014 15:35:27 +0200
Subject: [PATCH] udevd: ignore cd/dvd devices in synthesize_change as it can causes
 issue when udev is running from an ISO image.

Signed-off-by: Robert Milasan rmila...@suse.com
---
 src/udev/udevd.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/udev/udevd.c b/src/udev/udevd.c
index aed1149..56cf7ea 100644
--- a/src/udev/udevd.c
+++ b/src/udev/udevd.c
@@ -741,7 +741,8 @@ static int synthesize_change(struct udev_device *dev) {
 
 if (streq_ptr(block, udev_device_get_subsystem(dev)) 
 streq_ptr(disk, udev_device_get_devtype(dev)) 
-!startswith(udev_device_get_sysname(dev), dm-)) {
+!startswith(udev_device_get_sysname(dev), dm-) 
+!startswith(udev_device_get_sysname(dev), sr)) {
 bool part_table_read = false;
 bool has_partitions = false;
 int fd;
-- 
1.8.4.5

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] udevd: skip cd/dvd devices in synthesize_change

2014-06-18 Thread Robert Milasan
On Wed, 18 Jun 2014 20:57:35 +0200
Kay Sievers k...@vrfy.org wrote:

 On Wed, Jun 18, 2014 at 8:17 PM, Robert Milasan rmila...@suse.com
 wrote:
  If we are running udevd from a LiveCD or ISO image, it can happen
  that udevd wont find the cd/dvd in time, causing a failure.
 
  I've attached the patch which seems to fix the issue.
 
 Change events are triggered when some tool has opened the device for
 writing and closes the file descriptor. That sounds pretty strange
 with a Live CD on /dev/sr0.
 
 All we do in the code you patch here is to look for possible
 partitions.
 
 Are you sure that this is really the problem?
 
 Kay
 

From our tests yes, but you can wait with pushing the patch for a while
until I get a better confirmation.


-- 
Robert Milasan

L3 Support Engineer
SUSE Linux (http://www.suse.com)
email: rmila...@suse.com
GPG fingerprint: B6FE F4A8 0FA3 3040 3402  6FE7 2F64 167C 1909 6D1A
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] Reorder usage of streq_ptr, don't think it was correct in the first place

2014-06-13 Thread Robert Milasan
It seems that in udevd.c synthesize_change that order of arguments in
streq_ptr is wrong, or at least it looks wrong to me.

I've attached the patch which should fix the issue.


-- 
Robert Milasan

L3 Support Engineer
SUSE Linux (http://www.suse.com)
email: rmila...@suse.com
GPG fingerprint: B6FE F4A8 0FA3 3040 3402  6FE7 2F64 167C 1909 6D1A
From 67f470fbc1711e8199e71c30a51de5033db7b596 Mon Sep 17 00:00:00 2001
From: Robert Milasan rmila...@suse.com
Date: Fri, 13 Jun 2014 10:46:37 +0200
Subject: [PATCH] udevd: really check for partitions in synthesize_change

Signed-off-by: Robert Milasan rmila...@suse.com
---
 src/udev/udevd.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/udev/udevd.c b/src/udev/udevd.c
index a45d324..aed1149 100644
--- a/src/udev/udevd.c
+++ b/src/udev/udevd.c
@@ -790,7 +790,7 @@ static int synthesize_change(struct udev_device *dev) {
 if (!d)
 continue;
 
-if (!streq_ptr(partition, udev_device_get_devtype(d)))
+if (!streq_ptr(udev_device_get_devtype(d), partition))
 continue;
 
 has_partitions = true;
@@ -820,7 +820,7 @@ static int synthesize_change(struct udev_device *dev) {
 if (!d)
 continue;
 
-if (!streq_ptr(partition, udev_device_get_devtype(d)))
+if (!streq_ptr(udev_device_get_devtype(d), partition))
 continue;
 
 log_debug(device %s closed, synthesising partition '%s' 'change',
-- 
1.8.4.5

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] Inconsistent device naming for dual-port or multi-port network devices

2014-05-05 Thread Robert Milasan
Hello, seems that on some systems (in our cases s390x) a dual
port network device, is named ens11 and ens11d1 which doesn't exactly
looks normal (not sure if this in on purpose or not)

udevadm info -a -p /sys/class/net/ens11 | grep dev_id
ATTR{dev_id}==0x0
udevadm info -a -p /sys/class/net/ens11d1 | grep dev_id
ATTR{dev_id}==0x1

Seems that in src/udev/udev-builtin-net_id.c:201 we don't use dev_id,
if dev_id = 0.

Again, checking the idea in the header of udev-builtin-net_id.c, the
logic should be:

en (ethernet), s slot, f function, d dev_id, but is not specified
that dev_id is not use if dev_id = 0.

The logic should be ens11d0 and ens11d1, at least according to how it
is explained.

I've attached the patch which fixes this issue, if this is not really a
bug, then ignore the mail :)


-- 
Robert Milasan

L3 Support Engineer
SUSE Linux (http://www.suse.com)
email: rmila...@suse.com
GPG fingerprint: B6FE F4A8 0FA3 3040 3402  6FE7 2F64 167C 1909 6D1A
From bc159a64961fc222f36139c8990f581d139f420d Mon Sep 17 00:00:00 2001
From: Robert Milasan rmila...@suse.com
Date: Mon, 5 May 2014 14:25:49 +0200
Subject: [PATCH] Use dev_id for network devices even if dev_id equals zero

Signed-off-by: Robert Milasan rmila...@suse.com
---
 src/udev/udev-builtin-net_id.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/udev/udev-builtin-net_id.c b/src/udev/udev-builtin-net_id.c
index c80c30a..e141774 100644
--- a/src/udev/udev-builtin-net_id.c
+++ b/src/udev/udev-builtin-net_id.c
@@ -198,7 +198,7 @@ static int dev_pci_slot(struct udev_device *dev, struct netnames *names) {
 l = strpcpyf(s, l, p%ds%d, bus, slot);
 if (func  0 || is_pci_multifunction(names-pcidev))
 l = strpcpyf(s, l, f%d, func);
-if (dev_id  0)
+if (dev_id = 0)
 l = strpcpyf(s, l, d%d, dev_id);
 if (l == 0)
 names-pci_path[0] = '\0';
-- 
1.8.4.5

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] Possible net_id incorrect bus and/or slot

2014-01-09 Thread Robert Milasan
Hello, just notice that my network card is named enp0s25, but when I do:

# readlink -f /sys/class/net/enp0s25
/sys/devices/pci:00/:00:19.0/net/enp0s25

and

# lspci |grep Network
00:19.0 Ethernet controller: Intel Corporation 82579LM Gigabit Network
Connection (rev 04)

# udevadm test-builtin net_id /sys/class/net/enp0s25
calling: test-builtin
=== trie on-disk ===
tool version:  208
file size: 5968358 bytes
header size 80 bytes
strings1302262 bytes
nodes  4666016 bytes
load module index
ID_NET_NAME_MAC=enx180373dbc331
ID_OUI_FROM_DATABASE=Dell Inc
ID_NET_NAME_PATH=enp0s25
unload module index

enp0s25 seems wrong to me, or the slot is based on what?

Please clarify how to get this.

-- 
Robert Milasan

L3 Support Engineer
SUSE Linux (http://www.suse.com)
email: rmila...@suse.com
GPG fingerprint: B6FE F4A8 0FA3 3040 3402  6FE7 2F64 167C 1909 6D1A
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Possible net_id incorrect bus and/or slot

2014-01-09 Thread Robert Milasan
On Thu, 9 Jan 2014 11:07:40 +0100
Tomasz Torcz to...@pipebreaker.pl wrote:

 On Thu, Jan 09, 2014 at 10:59:34AM +0100, Robert Milasan wrote:
  Hello, just notice that my network card is named enp0s25, but when
  I do:
  
  # readlink -f /sys/class/net/enp0s25
  /sys/devices/pci:00/:00:19.0/net/enp0s25
  
  # lspci |grep Network
  00:19.0 Ethernet controller: Intel Corporation 82579LM Gigabit
  Network Connection (rev 04)
  
  enp0s25 seems wrong to me, or the slot is based on what?
  
  Please clarify how to get this.
 
   0x19 = 25.  It's hexadecimal vs decimal.
 

Ohh, that explains it :) I didn't think of it

-- 
Robert Milasan

L3 Support Engineer
SUSE Linux (http://www.suse.com)
email: rmila...@suse.com
GPG fingerprint: B6FE F4A8 0FA3 3040 3402  6FE7 2F64 167C 1909 6D1A
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Possible net_id incorrect bus and/or slot

2014-01-09 Thread Robert Milasan
On Thu, 9 Jan 2014 11:07:40 +0100
Tomasz Torcz to...@pipebreaker.pl wrote:

 On Thu, Jan 09, 2014 at 10:59:34AM +0100, Robert Milasan wrote:
  Hello, just notice that my network card is named enp0s25, but when
  I do:
  
  # readlink -f /sys/class/net/enp0s25
  /sys/devices/pci:00/:00:19.0/net/enp0s25
  
  # lspci |grep Network
  00:19.0 Ethernet controller: Intel Corporation 82579LM Gigabit
  Network Connection (rev 04)
  
  enp0s25 seems wrong to me, or the slot is based on what?
  
  Please clarify how to get this.
 
   0x19 = 25.  It's hexadecimal vs decimal.
 

OK, now because that is clear, there is another issue:

Example:

user has an on board network adapter named enp3s0.
user adds 2 additinal network adapters on pcie and they will be named
enp6s0 and enp5s0, but enp3s0 also got renamed to enp4s0.

Now I'm not sure if this is normal, but in my own limited logic, it
doesn't sounds or look normal at all. The setup or the naming is not
very stable.

The on board nic didn't change or wasn't placed someplace else, well
it's on board, so it's a bit difficult to place on some other slot.
Also the users hasn't touch the system's BIOS.

My question is: is this expected or normal?

The network adapters are r8169

[5.654437] r8169 Gigabit Ethernet driver 2.3LK-NAPI loaded
[5.655012] r8169 :04:00.0 eth0: RTL8168evl/8111evl at
0xc90001948000, 00:0a:cd:21:e3:e5, XID 0c900800 IRQ 57
[5.655014] r8169 :04:00.0 eth0: jumbo features [frames: 9200 bytes, tx
checksumming: ko]
[5.655035] r8169 Gigabit Ethernet driver 2.3LK-NAPI loaded
[5.655360] r8169 :05:00.0 eth1: RTL8168evl/8111evl at
0xc9000194a000, 00:0a:cd:21:e3:e6, XID 0c900800 IRQ 58
[5.655361] r8169 :05:00.0 eth1: jumbo features [frames: 9200 bytes, tx
checksumming: ko]
[5.655368] r8169 Gigabit Ethernet driver 2.3LK-NAPI loaded
[5.657199] r8169 :06:00.0 eth2: RTL8168g/8111g at 0xc90001974000,
d8:50:e6:4c:08:d4, XID 0c000800 IRQ 59
[5.657202] r8169 :06:00.0 eth2: jumbo features [frames: 9200 bytes, tx
checksumming: ko]
[5.706037] systemd-udevd[309]: renamed network interface eth2 to enp6s0
[6.409314] systemd-udevd[306]: renamed network interface eth0 to enp4s0
[6.415252] systemd-udevd[307]: renamed network interface eth1 to enp5s0

-- 
Robert Milasan

L3 Support Engineer
SUSE Linux (http://www.suse.com)
email: rmila...@suse.com
GPG fingerprint: B6FE F4A8 0FA3 3040 3402  6FE7 2F64 167C 1909 6D1A
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] udev rules environment variable

2013-12-18 Thread Robert Milasan
On Tue, 17 Dec 2013 23:14:12 +0400
Andrey Borzenkov arvidj...@gmail.com wrote:

 В Tue, 17 Dec 2013 19:59:47 +0100
 Kay Sievers k...@vrfy.org пишет:
 
  
  Works just fine here as expected, it's probably something in your
  setup.
  
 
 No, it *your* default interface renaming :)
 
  Kay
  
  # head -2 /etc/udev/rules.d/10-local.rules
  ACTION==add, SUBSYSTEM==net, ENV{test_device}=1
  ACTION==remove, SUBSYSTEM==net, ENV{test_device}==1,
  RUN+=/bin/logger $env{test_device}
  
  # udevadm monitor -p -u 
  
  # modprobe dummy
 
 dummy is not renamed.
 
 KERNEL[80247.266050]
 add  /devices/pci:00/:00:03.0/net/eth0 (net) ACTION=add
 DEVPATH=/devices/pci:00/:00:03.0/net/eth0
 IFINDEX=8
 INTERFACE=eth0
 SEQNUM=1448
 SUBSYSTEM=net
 
 KERNEL[80247.295702]
 move /devices/pci:00/:00:03.0/net/ens3 (net) ACTION=move
 DEVPATH=/devices/pci:00/:00:03.0/net/ens3
 DEVPATH_OLD=/devices/pci:00/:00:03.0/net/eth0
 IFINDEX=8
 INTERFACE=ens3
 SEQNUM=1452
 SUBSYSTEM=net
 
 UDEV  [80256.247824]
 add  /devices/pci:00/:00:03.0/net/ens3 (net) ACTION=add
 DEVPATH=/devices/pci:00/:00:03.0/net/ens3
 ID_BUS=pci
 ...
 INTERFACE=ens3
 INTERFACE_OLD=eth0
 SEQNUM=1448
 ...
 test_device=1
 
 UDEV  [80256.274447]
 move /devices/pci:00/:00:03.0/net/ens3 (net) ACTION=move
 ...
 INTERFACE=ens3
 SEQNUM=1452
 ...
 TAGS=:systemd:
 UDEV_LOG=7
 
 Oops. test_device is lost. 
 

So basically it doesn't really work ?!

-- 
Robert Milasan

L3 Support Engineer
SUSE Linux (http://www.suse.com)
email: rmila...@suse.com
GPG fingerprint: B6FE F4A8 0FA3 3040 3402  6FE7 2F64 167C 1909 6D1A
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] udev rules environment variable

2013-12-18 Thread Robert Milasan
On Wed, 18 Dec 2013 02:52:01 +0100
Kay Sievers k...@vrfy.org wrote:

 On Tue, Dec 17, 2013 at 8:14 PM, Andrey Borzenkov
 arvidj...@gmail.com wrote:
  В Tue, 17 Dec 2013 19:59:47 +0100 Kay Sievers k...@vrfy.org пишет:
 
  # modprobe dummy
 
  dummy is not renamed.
 
  UDEV  [80256.274447]
  move /devices/pci:00/:00:03.0/net/ens3 (net) ACTION=move
  ...
  INTERFACE=ens3
  SEQNUM=1452
  ...
  TAGS=:systemd:
  UDEV_LOG=7
 
  Oops. test_device is lost.
 
 Adding something like:
   ACTION!=add|remove, IMPORT{db}=test_device
 
 might make it work.
 
 Kay
 

One more question: Where exactly is 'test_device' variable saved, I
mean physically? I suppose it should be in /run/udev/data or something
similar no?

-- 
Robert Milasan

L3 Support Engineer
SUSE Linux (http://www.suse.com)
email: rmila...@suse.com
GPG fingerprint: B6FE F4A8 0FA3 3040 3402  6FE7 2F64 167C 1909 6D1A
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] udev rules environment variable

2013-12-18 Thread Robert Milasan
On Wed, 18 Dec 2013 14:39:57 +0100
Kay Sievers k...@vrfy.org wrote:

 On Wed, Dec 18, 2013 at 2:07 PM, Robert Milasan rmila...@suse.com
 wrote:
 
  One more question: Where exactly is 'test_device' variable saved, I
  mean physically? I suppose it should be in /run/udev/data or
  something similar no?
 
 Yes, in the udev database at /run/udev/data/device ID.
 
 It's plain text, just look into it. The file names start with b ==
 block, c == char, n == network devices, ...
 
 Kay
 

Good to know coz that means it doesn't work :)

-- 
Robert Milasan

L3 Support Engineer
SUSE Linux (http://www.suse.com)
email: rmila...@suse.com
GPG fingerprint: B6FE F4A8 0FA3 3040 3402  6FE7 2F64 167C 1909 6D1A
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] udev rules environment variable

2013-12-17 Thread Robert Milasan
On Tue, 17 Dec 2013 11:52:15 +0100
Kay Sievers k...@vrfy.org wrote:

 On Tue, Dec 17, 2013 at 8:56 AM, Hannes Reinecke h...@suse.de wrote:
  On 12/17/2013 08:52 AM, Robert Milasan wrote:
  Hello,
got a small question about creating a rule, like this:
 
  ACTION==add, , ENV{test_device}=1
 
  ACTION==remove, , ENV{test_device}==1,
  RUN+=/path/to/some/script
 
  Does udev save test_device variable someplace and then it can be
  used later on, when have ACTION==remove ?
 
  Typically not.
 
 There is a standard REMOVE_CMD in 95-udev-late.rules to use for this
 
 All variables are stored in the database and are contained in the
 remove event, without the need to be added or queried. Sysfs though
 is not available, all of it is gone at remove.
 
  I would be using external tools for that, like 'collect'
 
 That is needed to sync stuff across multiple devices, not for a single
 one, right?
 
  Might be biased, though, what with me having written it ...
 
  And the alternative of querying the udev database from within an
  udev event is just plain ugly and prone to races.
 
 That happens automatically, it's just part of the remove
 environment.
 
 Kay
 ___
 systemd-devel mailing list
 systemd-devel@lists.freedesktop.org
 http://lists.freedesktop.org/mailman/listinfo/systemd-devel
 

I have this rule as a test, but doesn't do squat (meaning it doesnt
work) :)

ACTION==add, SUBSYSTEM==net, KERNEL==?*, ENV{test_device}=1

ACTION==remove, SUBSYSTEM==net, KERNEL==?*, ENV{test_device}==1, 
RUN+=/bin/sh -c 'echo test_device  /tmp/test_device.log'


-- 
Robert Milasan

L3 Support Engineer
SUSE Linux (http://www.suse.com)
email: rmila...@suse.com
GPG fingerprint: B6FE F4A8 0FA3 3040 3402  6FE7 2F64 167C 1909 6D1A
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] udev rules environment variable

2013-12-17 Thread Robert Milasan
On Tue, 17 Dec 2013 13:54:34 +0100
Martin Pitt martin.p...@ubuntu.com wrote:

 Robert Milasan [2013-12-17 12:44 +0100]:
  I have this rule as a test, but doesn't do squat (meaning it doesnt
  work) :)
  
  ACTION==add, SUBSYSTEM==net, KERNEL==?*, ENV{test_device}=1
  
  ACTION==remove, SUBSYSTEM==net, KERNEL==?*,
  ENV{test_device}==1, RUN+=/bin/sh -c 'echo test_device
   /tmp/test_device.log'
 
 Drop the KERNEL== bits. Network devices don't have a /dev/... device
 node in Linux, so KERNEL will never be set for those.
 
 Martin

Even without the KERNEL== doesn't seem to work:

I'm testing this by first removing the network device (ex. rmmod
e1000), so I can have first an ADD event and then a REMOVE event, by
removing again the module, so:

rmmod e1000 (remove first)
modprobe e1000 (ADD event, set the test_device var to 1)
rmmod e1000 (REMOVE event, get the test_device value)

This doesn't seem to work, or at least it looks like that.

-- 
Robert Milasan

L3 Support Engineer
SUSE Linux (http://www.suse.com)
email: rmila...@suse.com
GPG fingerprint: B6FE F4A8 0FA3 3040 3402  6FE7 2F64 167C 1909 6D1A
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] udev rules environment variable

2013-12-17 Thread Robert Milasan
On Tue, 17 Dec 2013 17:36:21 +0100
Kay Sievers k...@vrfy.org wrote:

 On Tue, Dec 17, 2013 at 2:05 PM, Robert Milasan rmila...@suse.com
 wrote:
  On Tue, 17 Dec 2013 13:54:34 +0100
  Martin Pitt martin.p...@ubuntu.com wrote:
 
  Robert Milasan [2013-12-17 12:44 +0100]:
   I have this rule as a test, but doesn't do squat (meaning it
   doesnt work) :)
  
   ACTION==add, SUBSYSTEM==net, KERNEL==?*,
   ENV{test_device}=1
  
   ACTION==remove, SUBSYSTEM==net, KERNEL==?*,
   ENV{test_device}==1, RUN+=/bin/sh -c 'echo test_device
/tmp/test_device.log'
 
  Drop the KERNEL== bits. Network devices don't have a /dev/...
  device node in Linux, so KERNEL will never be set for those.
 
 KERNEL is the device name in /sys, without the leading path. It is in
 almost all cases also the name in /dev, but there are some
 differences. And right, it is always set, there is never a point to do
 such a match.
 
  Even without the KERNEL== doesn't seem to work:
 
 It's pointless to match that, so it should not make a difference.
 
  I'm testing this by first removing the network device (ex. rmmod
  e1000), so I can have first an ADD event and then a REMOVE event, by
  removing again the module, so:
 
  rmmod e1000 (remove first)
  modprobe e1000 (ADD event, set the test_device var to 1)
  rmmod e1000 (REMOVE event, get the test_device value)
 
  This doesn't seem to work, or at least it looks like that.
 
 How old is your udev? You are not possibly talking about years old
 versions, right?
 
 Kay
 

The tests are run using udev 208 (systemd 208).

-- 
Robert Milasan

L3 Support Engineer
SUSE Linux (http://www.suse.com)
email: rmila...@suse.com
GPG fingerprint: B6FE F4A8 0FA3 3040 3402  6FE7 2F64 167C 1909 6D1A
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] udev rules environment variable

2013-12-16 Thread Robert Milasan
Hello,
  got a small question about creating a rule, like this:

ACTION==add, , ENV{test_device}=1

ACTION==remove, , ENV{test_device}==1,
RUN+=/path/to/some/script

Does udev save test_device variable someplace and then it can be used
later on, when have ACTION==remove ?


-- 
Robert Milasan

L3 Support Engineer
SUSE Linux (http://www.suse.com)
email: rmila...@suse.com
GPG fingerprint: B6FE F4A8 0FA3 3040 3402  6FE7 2F64 167C 1909 6D1A
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] udevadm settle takes too long to finish

2013-12-09 Thread Robert Milasan
On Mon, 09 Dec 2013 11:33:03 +0100
Thomas Bächler tho...@archlinux.org wrote:

 Am 07.12.2013 22:29, schrieb Robert Milasan:
  From systemd-analyze dump:
  
  Wants: systemd-udevd.service
  WantedBy: lvm2-activation-early.service
  WantedBy: lvm2-activation.service
  Before: lvm2-activation-early.service
  Before: sysinit.target
  After: systemd-udev-trigger.service
  After: systemd-journald.socket
  References: systemd-udevd.service
  References: systemd-udev-trigger.service
  References: sysinit.target
  References: systemd-journald.socket
  ReferencedBy: lvm2-activation-early.service
  ReferencedBy: lvm2-activation.service
 
 What's the distribution you are using? Using udevadm settle for lvm
 is a waste of boot time and isn't even guaranteed to work (ask
 Lennart, Kay or Greg K-H for the full speech). It's a hackish
 workaround for LVM's inability to activate volumes automatically.
 
 Instead, a socket-activated lvmetad service should be used in
 combination with the correct udev rules. The service files are
 provided by LVM, but they reference weird redhat-specific units and
 from what I saw have too many orderings, which results in slowing
 everything down needlessly.
 
 Currently, I use 69-dm-lvm-metad.rules provided by LVM in combination
 with the unit files [1] and [2] (derived from the redhat units
 included in LVM). This is fast and works great for me, although
 lvmetad has some annoying bugs which have been reported to me, but
 which I could never reproduce.
 
 There is no way to make udevadm settle faster and the only solution
 is (as Kay said already) is not using it.
 
 [1]
 https://projects.archlinux.org/svntogit/packages.git/tree/trunk/lvmetad.service?h=packages/lvm2
 [2]
 https://projects.archlinux.org/svntogit/packages.git/tree/trunk/lvmetad.socket?h=packages/lvm2
 

The distro is openSUSE and we are using lvm2-activation-generator which
comes with lvm2 package:

https://git.fedorahosted.org/cgit/lvm2.git/tree/scripts/lvm2_activation_generator_systemd_red_hat.c

-- 
Robert Milasan

L3 Support Engineer
SUSE Linux (http://www.suse.com)
email: rmila...@suse.com
GPG fingerprint: B6FE F4A8 0FA3 3040 3402  6FE7 2F64 167C 1909 6D1A


signature.asc
Description: PGP signature
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] Question about a udev rule

2013-12-08 Thread Robert Milasan
I've got this small rule which seems to not work at all:

ACTION!=add|change, GOTO=end_root_symlink
SUBSYSTEM!=block, GOTO=end_root_symlink
ENV{DEVTYPE}!=partition, GOTO=end_root_symlink

IMPORT{program}=/usr/bin/udevadm info --export --export-prefix=ROOT_
--device-id-of-file=/ ENV{MAJOR}!=0, ENV{MAJOR}==$env{ROOT_MAJOR},
ENV{MINOR}==$env{ROOT_MINOR}, SYMLINK+=root

LABEL=end_root_symlink

Can anyone tell me what I'm doing wrong?

-- 
Robert Milasan

L3 Support Engineer
SUSE Linux (http://www.suse.com)
email: rmila...@suse.com
GPG fingerprint: B6FE F4A8 0FA3 3040 3402  6FE7 2F64 167C 1909 6D1A
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Question about a udev rule

2013-12-08 Thread Robert Milasan
On Sun, 8 Dec 2013 19:30:45 +0100
Martin Pitt martin.p...@ubuntu.com wrote:

 Robert Milasan [2013-12-08 19:14 +0100]:
  IMPORT{program}=/usr/bin/udevadm info --export
  --export-prefix=ROOT_ --device-id-of-file=/ ENV{MAJOR}!=0,
  ENV{MAJOR}==$env{ROOT_MAJOR},
 ^
 
 For starters you seem to be missing a comma there.
 

Not really, it's a new line, just the mail client didn't do a good
job :)

Suppose to be:

IMPORT{program}=/usr/bin/udevadm info --export --export-prefix=ROOT_
--device-id-of-file=/
ENV{MAJOR}!=0, ENV{MAJOR}==$env{ROOT_MAJOR},
ENV{MINOR}==$env{ROOT_MINOR}, SYMLINK+=root

-- 
Robert Milasan

L3 Support Engineer
SUSE Linux (http://www.suse.com)
email: rmila...@suse.com
GPG fingerprint: B6FE F4A8 0FA3 3040 3402  6FE7 2F64 167C 1909 6D1A
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Question about a udev rule

2013-12-08 Thread Robert Milasan
On Sun, 8 Dec 2013 19:30:45 +0100
Martin Pitt martin.p...@ubuntu.com wrote:

 Robert Milasan [2013-12-08 19:14 +0100]:
  IMPORT{program}=/usr/bin/udevadm info --export
  --export-prefix=ROOT_ --device-id-of-file=/ ENV{MAJOR}!=0,
  ENV{MAJOR}==$env{ROOT_MAJOR},
 ^
 
 For starters you seem to be missing a comma there.
 

I've attached the rule, might be easier to see it.

-- 
Robert Milasan

L3 Support Engineer
SUSE Linux (http://www.suse.com)
email: rmila...@suse.com
GPG fingerprint: B6FE F4A8 0FA3 3040 3402  6FE7 2F64 167C 1909 6D1A


10-root-symlink.rules
Description: Binary data
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] udevadm settle takes too long to finish

2013-12-07 Thread Robert Milasan
I'm running systemd 208 and I've noticed that the service that
takes the most time to finish is 'systemd-udev-settle.service':

rmilasan@coolcat:~ systemd-analyze blame|head
  1.890s systemd-udev-settle.service
  1.804s NetworkManager.service
  1.447s ModemManager.service
  1.410s kmod-static-nodes.service
  1.408s systemd-udev-root-symlink.service
  1.042s dev-mqueue.mount
  1.041s sys-kernel-debug.mount
  1.041s dev-hugepages.mount

Note: I'm not using raid nor lvm and biosdevname package is not
installed.

Can anyone clarify why does udevadm settle takes so long to finish?

-- 
Robert Milasan

L3 Support Engineer
SUSE Linux (http://www.suse.com)
email: rmila...@suse.com
GPG fingerprint: B6FE F4A8 0FA3 3040 3402  6FE7 2F64 167C 1909 6D1A
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] udevadm settle takes too long to finish

2013-12-07 Thread Robert Milasan
On Sat, 7 Dec 2013 21:09:39 +0100
Kay Sievers k...@vrfy.org wrote:

 
 It is not used by default, not enabled.
 
 You probably have legacy tools running/installed pulling it in, like
 dmraid installed? If it's something else, grep through the service
 files. You might be able to just get rid of some old stuff, if you
 don't use it.
 
 Kay
 

dmraid is installed, but has nothing to do with systemd nor udev and I
can't remove it. I have no seen any service files or udev rules coming
from dmraid package.

-- 
Robert Milasan

L3 Support Engineer
SUSE Linux (http://www.suse.com)
email: rmila...@suse.com
GPG fingerprint: B6FE F4A8 0FA3 3040 3402  6FE7 2F64 167C 1909 6D1A
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] udevadm settle takes too long to finish

2013-12-07 Thread Robert Milasan
On Sat, 07 Dec 2013 18:35:38 -0300
Cristian Rodríguez crrodrig...@opensuse.org wrote:

 
 I have the same issue ..(not much of a problem actually) it is
 caused by the LVM activator that (in openSUSE at least) runs even
 when you are not using lvm.. the units are autogenerated ones..
 
 systemctl mask lvm2-activation.service
 
 made the issue go away.
 

Well that didn't help, but this did:

systemctl mask lvm2-activation.service
systemctl mask lvm2-activation-early.service

If I only mask lvm2-activation.service, then it doesn't make much
difference, but masking both it works better.

My question is: why does this happen, if lvm is not in use at all?

-- 
Robert Milasan

L3 Support Engineer
SUSE Linux (http://www.suse.com)
email: rmila...@suse.com
GPG fingerprint: B6FE F4A8 0FA3 3040 3402  6FE7 2F64 167C 1909 6D1A
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] 'udevadm test' removes/adds by-id/by-path links

2013-11-28 Thread Robert Milasan
Hello,
  when running 'udevadm test /sys/block/sdb --action=remove' then links
  to the device node in /dev/disk/{by-id,by-path} are being removed and
  running udevadm test with action=add, the links are re-added.

robert@viper:~ ls -l /dev/disk/by-id/|grep sdb
lrwxrwxrwx 1 root root  9 Nov 28 11:13
usb-Corsair_Flash_Voyager_002557-0:0 - ../../sdb
lrwxrwxrwx 1 root root 10 Nov 28 10:50
usb-Corsair_Flash_Voyager_002557-0:0-part1 - ../../sdb1

robert@viper:~ sudo udevadm test /sys/block/sdb --action=remove
/dev/null 21
robert@viper:~ ls -l /dev/disk/by-id/|grep sdb
lrwxrwxrwx 1 root root 10 Nov 28 10:50
usb-Corsair_Flash_Voyager_002557-0:0-part1 - ../../sdb1

robert@viper:~ sudo udevadm test /sys/block/sdb --action=add
/dev/null 21
robert@viper:~ ls -l /dev/disk/by-id/|grep sdb
lrwxrwxrwx 1 root root  9 Nov 28 11:34
usb-Corsair_Flash_Voyager_002557-0:0 - ../../sdb
lrwxrwxrwx 1 root root 10 Nov 28 10:50
usb-Corsair_Flash_Voyager_002557-0:0-part1 - ../../sdb1

 As you can see on action=remove, the link to sdb device node has been
 removed and on action=add, the link as been re-added.

 As I am running 'udevadm test', I would think, that this is only a test
 and the links or anything related to this test suppose to be fake,
 meaning nothing really should be removed/added.

 Is this a known functionality of 'udevadm test' or it's a bug?

-- 
Robert Milasan

L3 Support Engineer
SUSE Linux (http://www.suse.com)
email: rmila...@suse.com
GPG fingerprint: B6FE F4A8 0FA3 3040 3402  6FE7 2F64 167C 1909 6D1A
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH] udev: don't create symlink or rename if it already exists

2013-02-12 Thread Robert Milasan
Under some circumstances udev mixed with multipath fails:

udevd-work[1376]:
symlink(../../sdk, 
/dev/disk/by-id/scsi-36005076305ffc0672842.udev-tmp)
failed: File exists udevd-work[1432]:
rename(/dev/disk/by-id/scsi-36005076305ffc0850a88.udev-tmp, 
/dev/disk/by-id/scsi-36005076305ffc0850a88)
failed: No such file or directory

This is non-fatal, but there is no point of created the symlink or
renaming the symlink if it already exists.

Reference: https://bugzilla.novell.com/show_bug.cgi?id=791503

---
 src/udev/udev-node.c |   14 ++
 1 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/src/udev/udev-node.c b/src/udev/udev-node.c
index bce4cfe..a92d727 100644
--- a/src/udev/udev-node.c
+++ b/src/udev/udev-node.c
@@ -107,6 +107,10 @@ static int node_symlink(struct udev *udev, const
char *node, const char *slink) err = mkdir_parents_label(slink_tmp,
0755); if (err != 0  err != -ENOENT)
 break;
+if (lstat(slink_tmp, stats) == 0) {
+err = 0;
+break;
+}
 label_context_set(slink_tmp, S_IFLNK);
 err = symlink(target, slink_tmp);
 if (err != 0)
@@ -117,10 +121,12 @@ static int node_symlink(struct udev *udev, const
char *node, const char *slink) log_error(symlink '%s' '%s' failed:
%m\n, target, slink_tmp); goto exit;
 }
-err = rename(slink_tmp, slink);
-if (err != 0) {
-log_error(rename '%s' '%s' failed: %m\n, slink_tmp,
slink);
-unlink(slink_tmp);
+if (lstat(slink_tmp, stats) == 0) {
+err = rename(slink_tmp, slink);
+if (err != 0) {
+log_error(rename '%s' '%s' failed: %m\n,
slink_tmp, slink);
+unlink(slink_tmp);
+}
 }
 exit:
 return err;
-- 
1.7.7

-- 
Robert Milasan

L3 Support Engineer
SUSE Linux (http://www.suse.com)
email: rmila...@suse.com
GPG fingerprint: B6FE F4A8 0FA3 3040 3402  6FE7 2F64 167C 1909 6D1A
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH] udev: don't create symlink or rename if it already exists

2013-02-12 Thread Robert Milasan
On Tue, 12 Feb 2013 14:57:28 +0100
Kay Sievers k...@vrfy.org wrote:

 
 Btw, you should use a different mailer for sending patches, or attach
 them; this seems all mangled and would not apply.
 
 Kay
 

OK, as you wish and yes I noticed only after I sent the patch :)

-- 
Robert Milasan

L3 Support Engineer
SUSE Linux (http://www.suse.com)
email: rmila...@suse.com
GPG fingerprint: B6FE F4A8 0FA3 3040 3402  6FE7 2F64 167C 1909 6D1A
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH] udev: don't create symlink or rename if it already exists

2013-02-12 Thread Robert Milasan
On Tue, 12 Feb 2013 15:09:18 +0100
Kay Sievers k...@vrfy.org wrote:

 On Tue, Feb 12, 2013 at 3:07 PM, Robert Milasan rmila...@suse.com
 wrote:
  On Tue, 12 Feb 2013 14:57:28 +0100
  Kay Sievers k...@vrfy.org wrote:
 
  Btw, you should use a different mailer for sending patches, or
  attach them; this seems all mangled and would not apply.
 
  OK, as you wish and yes I noticed only after I sent the patch :)
 
 My wish? Will you update the patch, or should I do it? :)
 
 Kay
 

Sorry, was referring to patch, it looks good to me, but I'm not really
a developer, so it's up to you to change it.

-- 
Robert Milasan

L3 Support Engineer
SUSE Linux (http://www.suse.com)
email: rmila...@suse.com
GPG fingerprint: B6FE F4A8 0FA3 3040 3402  6FE7 2F64 167C 1909 6D1A
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] usb_id gets bogus serial and makes a mess

2013-02-10 Thread Robert Milasan
On Thu, 7 Feb 2013 15:52:20 +0100
Robert Milasan rmila...@suse.com wrote:

 Hi, seems that using some strange usb devices with really bogus serial
 numbers usb_id creates links with junk strings in it:
 
 /dev/disk/by-id/usb-TSSTcorp_BDDVDW_SE-506AB_㡒䍌䜶䉗ぁㄴ㌴†ँ-0:0
 
 Initially was believed that usb_id is to blame, then the kernel, but
 it turns out that really the usb cd/dvd drive has this bogus serial
 number:
 
 output from dmesg:
 [  538.200160] usb 1-2: new high-speed USB device number 5 using
 ehci_hcd [  538.335067] usb 1-2: New USB device found, idVendor=0e8d,
 idProduct=1956 [  538.335080] usb 1-2: New USB device strings: Mfr=1,
 Product=2, SerialNumber=3 [  538.335089] usb 1-2: Product: MT1956 
 [  538.335097] usb 1-2: Manufacturer: MediaTek Inc
 [  538.335105] usb 1-2: SerialNumber:
 \xffe3\xffa1\xff92\xffe4\xff8d\xff8c\xffe4\xff9c\xffb6\xffe4\xff89\xff97\xffe3\xff81\xff81\xffe3\xff84\xffb4\xffe3\xff8c\xffb4\xffe2\xff80\xffa0\xffe0\xffa4\xff81
 [  538.337540] scsi6 : usb-storage 1-2:1.0 [  539.341385] scsi
 6:0:0:0: CD-ROMTSSTcorp BDDVDW SE-506AB  TS00 PQ: 0 ANSI:
 0 [  539.354240] sr0: scsi3-mmc drive: 0x/24x writer dvd-ram cd/rw
 xa/form2 cdda tray [  539.354777] sr 6:0:0:0: Attached scsi CD-ROM sr0
 [  539.355122] sr 6:0:0:0: Attached scsi generic sg2 type 5
 
 output of command:  udevadm test-builtin usb_id /block/sr0
 udev_device_new_from_syspath: device 0x9c84d58 has devpath
 '/devices/pci:00/:00:1d.7/usb1/1-2' udev_builtin_add_property:
 ID_VENDOR=TSSTcorp udev_builtin_add_property: ID_VENDOR_ENC=TSSTcorp
 udev_builtin_add_property: ID_VENDOR_ID=0e8d
 udev_builtin_add_property: ID_MODEL=BDDVDW_SE-506AB
 udev_builtin_add_property: ID_MODEL_ENC=BDDVDW\x20SE-506AB\x20
 udev_builtin_add_property: ID_MODEL_ID=1956
 udev_builtin_add_property: ID_REVISION=TS00
 udev_builtin_add_property:
 ID_SERIAL=TSSTcorp_BDDVDW_SE-506AB_㡒䍌䜶䉗ぁㄴ㌴†ँ-0:0
 udev_builtin_add_property: ID_SERIAL_SHORT=㡒䍌䜶䉗ぁㄴ㌴†ँ
 udev_builtin_add_property: ID_TYPE=cd udev_builtin_add_property:
 ID_INSTANCE=0:0 udev_builtin_add_property: ID_BUS=usb
 udev_builtin_add_property: ID_USB_INTERFACES=:080250:
 udev_builtin_add_property: ID_USB_INTERFACE_NUM=00
 udev_builtin_add_property: ID_USB_DRIVER=usb-storage
 
 Wouldn't be a good idea to add a string validator for the serial
 number and if it doesn't fall into the valid options, then just set
 the serial to 0 or something like this?
 
 I'm not sure, but don't think from the usb_id point the serial matters
 too much.
 
 Was thinking that this function:
 
 static bool valid_string(const char *serial)
 {
  const char *s;
 
  if (!serial)
 return false;
  for (s = serial; *s != '\0'; s++) {
 if ((*s = 'a'  *s = 'z') || 
 (*s = 'A'  *s = 'Z') ||
 (*s = '0'  *s = '9') || 
  *s == '-' || *s == '_')
   continue;
 else
   return false;
  }
  return true;
 }
 
 Could be added to usb_id and then use it to validated serial_str and
 serial.
 

Here is a simple patch, just don't use the serial if it's bogus.

-- 
Robert Milasan

L3 Support Engineer
SUSE Linux (http://www.suse.com)
email: rmila...@suse.com
GPG fingerprint: B6FE F4A8 0FA3 3040 3402  6FE7 2F64 167C 1909 6D1A
From 2ffcfb9b45262271019d1751cafc895c3dae8f0e Mon Sep 17 00:00:00 2001
From: Robert Milasan rmila...@suse.com
Date: Sun, 10 Feb 2013 11:00:20 +0100
Subject: [PATCH] usb_id: some strange devices have a very bogus or strange serial
 numer, making a mess in /dev/disk/by-id. Let's check if the
 serial number is a valid, otherwise don't use it.

---
 src/udev/udev-builtin-usb_id.c |   23 +++
 1 file changed, 23 insertions(+)

diff --git a/src/udev/udev-builtin-usb_id.c b/src/udev/udev-builtin-usb_id.c
index 7ce401d..9e407c5 100644
--- a/src/udev/udev-builtin-usb_id.c
+++ b/src/udev/udev-builtin-usb_id.c
@@ -23,6 +23,7 @@
 #include stdio.h
 #include stdlib.h
 #include stdarg.h
+#include stdbool.h
 #include unistd.h
 #include string.h
 #include ctype.h
@@ -31,6 +32,26 @@
 
 #include udev.h
 
+static bool validate_string(const char *str)
+{
+const char *s;
+
+if (!str)
+return false;
+
+for (s = str; *s != '\0'; s++) {
+ if ((*s = 'a'  *s = 'z') ||
+ (*s = 'A'  *s = 'Z') ||
+ (*s = '0'  *s = '9') ||
+  *s == '-' || *s == '_')
+continue;
+  else
+return false;
+}
+
+return true;
+}
+
 static void set_usb_iftype(char *to, int if_class_num, size_t len)
 {
 const char *type = generic;
@@ -431,6 +452,8 @@ fallback:
 const char *usb_serial;
 
 usb_serial = udev_device_get_sysattr_value(dev_usb, serial);
+if (!validate_string(usb_serial))
+usb_serial = NULL

[systemd-devel] Typos in CODING_STYLE

2013-01-29 Thread Robert Milasan
I found this in CODING_STYLE which is hard to read:

- Do not issue NSS requests (that includes user name and host name
  lookups) from the main daemon as this might trigger deadlocks when
  we those lookups involve synchronously talking to services that we
  would need to start up

deadlocks when we those lookups is it me, or its just wrong?

-- 
Robert Milasan

L3 Support Engineer
SUSE Linux (http://www.suse.com)
email: rmila...@suse.com
GPG fingerprint: B6FE F4A8 0FA3 3040 3402  6FE7 2F64 167C 1909 6D1A
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] Counting mechanism in udev rules

2012-12-14 Thread Robert Milasan
Is there some kind of a counting mechanism which can be used in a udev
rule?

I got this rule:

ACTION==add, SUBSYSTEM==3270, KERNEL==tty0.0.[0-9]*,
SYMLINK+=3270/ttycons-%n

and the result of this rule looks like this:

lrwxrwxrwx 1 root root 14 Dec 13 15:28 ttycons-0500 - ../tty0.0.0500
lrwxrwxrwx 1 root root 14 Dec 13 15:28 ttycons-0501 - ../tty0.0.0501
lrwxrwxrwx 1 root root 14 Dec 13 15:28 ttycons-0502 - ../tty0.0.0502
lrwxrwxrwx 1 root root 14 Dec 13 15:28 ttycons-0503 - ../tty0.0.0503

But I would like instead of '%n' to use a counting variable that would
make the result look something like this:

lrwxrwxrwx 1 root root 14 Dec 13 15:28 ttycons0 - ../tty0.0.0500
lrwxrwxrwx 1 root root 14 Dec 13 15:28 ttycons1 - ../tty0.0.0501
lrwxrwxrwx 1 root root 14 Dec 13 15:28 ttycons2 - ../tty0.0.0502
lrwxrwxrwx 1 root root 14 Dec 13 15:28 ttycons3 - ../tty0.0.0503

Would this be possible in udev, if so what '%' option can I use?

-- 
Robert Milasan

L3 Support Engineer
SUSE Linux (http://www.suse.com)
email: rmila...@suse.com
GPG fingerprint: B6FE F4A8 0FA3 3040 3402  6FE7 2F64 167C 1909 6D1A
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Counting mechanism in udev rules

2012-12-14 Thread Robert Milasan
On Fri, 14 Dec 2012 11:30:05 +0100
Kay Sievers k...@vrfy.org wrote:

 On Fri, Dec 14, 2012 at 9:11 AM, Robert Milasan rmila...@suse.com
 wrote:
  Is there some kind of a counting mechanism which can be used in a
  udev rule?
 
  I got this rule:
 
  ACTION==add, SUBSYSTEM==3270, KERNEL==tty0.0.[0-9]*,
  SYMLINK+=3270/ttycons-%n
 
  and the result of this rule looks like this:
 
  lrwxrwxrwx 1 root root 14 Dec 13 15:28 ttycons-0500
  - ../tty0.0.0500 lrwxrwxrwx 1 root root 14 Dec 13 15:28
  ttycons-0501 - ../tty0.0.0501 lrwxrwxrwx 1 root root 14 Dec 13
  15:28 ttycons-0502 - ../tty0.0.0502 lrwxrwxrwx 1 root root 14 Dec
  13 15:28 ttycons-0503 - ../tty0.0.0503
 
  But I would like instead of '%n' to use a counting variable that
  would make the result look something like this:
 
  lrwxrwxrwx 1 root root 14 Dec 13 15:28 ttycons0 - ../tty0.0.0500
  lrwxrwxrwx 1 root root 14 Dec 13 15:28 ttycons1 - ../tty0.0.0501
  lrwxrwxrwx 1 root root 14 Dec 13 15:28 ttycons2 - ../tty0.0.0502
  lrwxrwxrwx 1 root root 14 Dec 13 15:28 ttycons3 - ../tty0.0.0503
 
  Would this be possible in udev, if so what '%' option can I use?
 
 There is intentionally no enumeration facility in udev. Udev-provided
 enumeration would not be much better than the kernel-provided
 enumeration.
 
 In general, all sorts of device inter-dependencies in device names
 should be avoided, and names should be provided by properties derived
 from the device itself, the bus location it is connected to, or be
 supported by the firmware, and not by unreliable enumeration.
 
 Inventing new numbers in a device hotplug path cannot really work,
 and udev does not want to give the impression it could.
 
 Kay
 

OK, I understand, but if I would like to achieve what I wrote, how would
I go and do that?

-- 
Robert Milasan

L3 Support Engineer
SUSE Linux (http://www.suse.com)
email: rmila...@suse.com
GPG fingerprint: B6FE F4A8 0FA3 3040 3402  6FE7 2F64 167C 1909 6D1A
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] Supermicro X8ST3 KVM-over-IP keyboard doesn't work with the existing rule in 42-usb-hid-pm.rules

2012-12-06 Thread Robert Milasan
It seems that the added rules: 

ACTION==add, SUBSYSTEM==usb, ATTR{idVendor}==046b,
ATTR{idProduct}==ff10, TEST==power/control,
ATTR{power/control}=auto

creates problems for people with Supermicro X8ST3 mb (and maybe
other Supermicro mb's) and renders the KVM-over-IP unusable, at BIOS
and GRUB the KVM works perfectly, but after that the device is unusable.

Dropping the rule fixes the issue:

diff --git a/rules/42-usb-hid-pm.rules b/rules/42-usb-hid-pm.rules
index c9f67c7..498c6a5 100644
--- a/rules/42-usb-hid-pm.rules
+++ b/rules/42-usb-hid-pm.rules
@@ -12,9 +12,6 @@ ACTION==add, SUBSYSTEM==usb, ATTR{product}==QEMU
USB Mouse, ATTR{serial}== ACTION==add, SUBSYSTEM==usb,
ATTR{product}==QEMU USB Tablet, ATTR{serial}==42,
TEST==power/control, ATTR{power/control}=auto ACTION==add,
SUBSYSTEM==usb, ATTR{product}==QEMU USB Keyboard,
ATTR{serial}==42, TEST==power/control, ATTR{power/control}=auto
-# AMI 046b:ff10 -ACTION==add, SUBSYSTEM==usb,
ATTR{idVendor}==046b, ATTR{idProduct}==ff10, TEST==power/control,
ATTR{power/control}=auto - # # Catch-all for Avocent HID devices.
Keyed off interface in order to only # trigger on HID class devices.


Reference bug: https://bugzilla.novell.com/show_bug.cgi?id=792576

-- 
Robert Milasan

L3 Support Engineer
SUSE Linux (http://www.suse.com)
email: rmila...@suse.com
GPG fingerprint: B6FE F4A8 0FA3 3040 3402  6FE7 2F64 167C 1909 6D1A
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH] allow udev to correctly handle 'change' after device has disappeared

2012-11-08 Thread Robert Milasan
From: Neil Brown nfbr...@suse.com
Date: Thu, 8 Nov 2012 10:39:06 +0100
Subject: [PATCH] If a 'change' event does not get handled by udev until
after the device has subsequently disappeared, udev mis-handles
 it. This can happen with 'md' devices which emit a change
 event and then a remove event when they are stopped. It is
 normally only noticed if udev is very busy (lots of arrays
 being stopped at once) or the machine is otherwise loaded
 and reponding slowly.

There are two problems.

1/ udev_device_new_from_syspath() will refuse to create the device
  structure if the device does not exist in /sys, and particularly if
the uevent file does not exist.
  If a 'db' file does exist, that is sufficient evidence that the device
  is genuine and should be created.  Equally if we have just received an
  event from the kernel about the device, it must be real.

  This patch just disabled the test for the 'uevent' file, it doesn't
  try imposing any other tests - it isn't clear that they are really
  needed.

2/ udev_event_execute_rules() calls udev_device_read_db() on a 'device'
   structure that is largely uninitialised and in particular does not
   have the 'subsystem' set.  udev_device_read_db() needs the subsystem
   so it tries to read the 'subsystem' symlink out of sysfs.  If the
device is already deleted, this naturally fails.
   udev_event_execute_rules() knows the subsystem (as it was in the
event message) so this patch simply sets the subsystem for the device
structure to be loaded to match the subsystem of the device structure
that is handling the event.

With these two changes, deleted handling of change events will still
correctly remove any symlinks that are not needed any more.

---
 src/libudev/libudev-device.c |2 --
 src/udev/udev-event.c|2 ++
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/libudev/libudev-device.c b/src/libudev/libudev-device.c
index 08476e6..0ea5afe 100644
--- a/src/libudev/libudev-device.c
+++ b/src/libudev/libudev-device.c
@@ -662,8 +662,6 @@ _public_ struct udev_device
*udev_device_new_from_syspath(struct udev *udev, con 
 /* all devices require a uevent file */
 util_strscpyl(file, sizeof(file), path, /uevent,
NULL);
-if (stat(file, statbuf) != 0)
-return NULL;
 } else {
 /* everything else just needs to be a directory */
 if (stat(path, statbuf) != 0
|| !S_ISDIR(statbuf.st_mode)) diff --git a/src/udev/udev-event.c
b/src/udev/udev-event.c index 2b9fdf6..bc936f4 100644
--- a/src/udev/udev-event.c
+++ b/src/udev/udev-event.c
@@ -799,6 +799,8 @@ int udev_event_execute_rules(struct udev_event
*event, struct udev_rules *rules, } else {
 event-dev_db =
udev_device_new_from_syspath(event-udev,
udev_device_get_syspath(dev)); if (event-dev_db != NULL) {
+   udev_device_set_subsystem(event-dev_db,
+
udev_device_get_subsystem(dev)); udev_device_read_db(event-dev_db,
NULL); udev_device_set_info_loaded(event-dev_db);
 
-- 
1.7.7

-- 
Robert Milasan

L3 Support Engineer
SUSE Linux (http://www.suse.com)
email: rmila...@suse.com
GPG fingerprint: B6FE F4A8 0FA3 3040 3402  6FE7 2F64 167C 1909 6D1A
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel