[06:14:04]  ***  hadess (n=hadess@cpc1-glfd5-2-0-cust794.6-2.cable.virginmedia.com) has joined chat #udev. [06:14:27]  kay_: got a sec? [06:16:33]  i'm trying to delay an event helper getting run: http://pastebin.com/m54319fa2 [06:20:22]  kay_: or find another way to find whether bluetooth devices are available [07:31:19]  kay: hey! [08:46:09]  udev will emit an event when starting up, when root fs is still read only [08:48:02]  me, no [08:49:25]  but people might [08:49:41]  yeah, they are on their own then :) [08:49:57]  all stuff will break in interesting ways :) [08:50:37]  but with all tools on the rootfs, the coldplug thing should be fine, i think [08:50:39]  is there a good way for me to check whether / would be ro, and defer? [08:51:21]  you currently see the ro /, when called? [08:51:40]  and you are not called again later? [08:51:44]  as i mentioned, didn't test, just notting's word for it [08:51:57]  maybe i should just try that... [08:52:01]  ah, i see. i guess you need to try :) [08:52:24]  coldplug should happen after the rootfs is writable [08:52:39]  ***  kzak has left chat #udev (Read error: 113 (No route to host)). [08:52:53]  the only problem is if you have parts of the filesystem on different disks which are not available that time [08:53:14]  yeah, things will break [08:53:16]  then you could, if you detect this, return non-zero from the RUN+="..." rule [08:53:36]  and you will be called again after all local fss are mounted [08:53:36]  what happens if i return non-0? [08:53:45]  oh, excellent [08:53:54]  then the device is marked as failed [08:54:05]  and a later boot script calls all failed events again [08:54:14]  than *might* work [08:54:52]  not sure if anybody ever relied on that, it's there, but it might just have problems nobody ever cared about [08:55:05]  ***  kzak (n=kzak@176.21.broadband11.iol.cz) has joined chat #udev. [09:17:29]  kay: stupid question, what what can i use to check whether a path is on a read-only partition/device? [09:18:29]  huh [09:18:49]  i think i'll just grep the output of mount for now :) [09:19:21]  and upstart wouldn't be able to start bluetoothd [09:20:00]  you are not adding stuff like this to an event handler, right? [09:20:27]  i am, shouldn't i be? [09:20:33]  i mean you are not calling the mount binary here? [09:20:52]  no, you shouldn't, definitely not [09:22:09]  # Run "initctl log-priority info" to get debug from [09:22:09]  # upstart about events being processed, or pass [09:22:09]  # --debug to your kernel arguments [09:22:09]  emit_event() [09:22:10]  { [09:22:11]  Keybuk: isn't that to be solved in upstart? [09:22:12]          /sbin/initctl emit --no-wait $1 [09:22:16]  } [09:22:18]  # If any of those paths are read-only, bail [09:22:20]  if `mount | grep "on / type" | grep -q ro` ; then [09:22:22]          return 1; [09:22:24]  fi [09:22:26]  # If the action is add, we always have an adapter [09:22:28]  if test "x$ACTION" = "xadd" ; then [09:22:30]          emit_event fedora.bluetooth-adapter-available [09:22:32]          exit 0 [09:22:34]  fi [09:22:36]  # Check whether any devices are available [09:22:38]  if `udevadm info --export-db | grep -q -e '/devices/.*/bluetooth/.*'` ; then [09:22:40]          emit_event fedora.bluetooth-adapter-available [09:22:42]  else [09:22:46]          emit_event fedora.bluetooth-adapter-not-available [09:22:48]  fi [09:22:49]  oh, stop it please :) [09:22:50]  exit 0 [09:22:52]  crap [09:22:54]  sorry! [09:22:55]  i'm puking :) [09:22:56]  http://pastebin.com/m58bce486 [09:23:28]  no, it's fine to paste here, but what is crap like: udevadm info --export-db [09:23:40]  it's insane [09:24:24]  i guess someone needs to find a sane way to do that, that looks like an awful piece of total crap :) [09:25:02]  why thank you [09:25:17]  calling mount and dumping the udev database from an event, that's really wrong on so many levels :) [09:25:19]  i work with what i have [09:25:33]  yeah, sorry, it; not personal [09:25:39]  it's not, i mean [09:25:52]  get me better tools, and i won't be doing crazy shit [09:26:18]  so back to square one: what are you trying to accomplish? [09:26:47]  start bluetoothd when a bluetooth adapter shows up, stop it when the last bluetooth adapter is removed [09:27:21]  bluetoothd watches its devices, right? [09:27:27]  yes [09:27:39]  so you don't do refcounting in udev events [09:27:45]  and never stop anything [09:27:55]  let blutoothd exit if it has nothing to do [09:27:57]  but we're trying not to run bluetoothd when there's no adapters [09:28:10]  yeah, but make it exit if it has no devices left [09:28:33]  hmm [09:28:38]  so you get rid of the "refcounting" hack by dumping the db [09:29:18]  i guess i could do that as a bluetoothd plugin [09:29:20]  and you make it exit immediately when its already running [09:30:00]  you start it with  every device event, and it will just exit,when its not needed because it runs already [09:30:16]  it runs on dbus, so it would already do that [09:30:24]  sounds good [09:30:52]  same thing, if it can not run because / is ro, let it exit [09:31:03]  i think it already does that [09:31:11]  and the next event will try to start it again [09:31:30]  you mean that i could do that using only udev and no upstart? [09:31:55]  i don't think there needs to be anything of this in udev rules [09:32:02]  maybe, i can't say [09:32:18]  what does bluetoothd do with the adapter? [09:32:19]  any of "this" what? [09:32:29]  just trigger the start of the daemon from the event, and noting else [09:32:34]  Keybuk: brings it up, and makes it available to user-space [09:32:42]  does it need to even be running if an adapter is present but no application requires it? [09:32:47]  if not, consider d-bus activation instead [09:32:50]  and no, dbus activation was already tried, and it wouldn't work for us [09:35:24]  should i run bluetoothd as a daemon from the RUN+=, or with --nodaemon? [09:35:49]  it needs ... [09:35:56]  you never have a client that wants to start it up, right? [09:37:06]  applications should already handle the dbus service not being available [09:38:15]  and there's not really any difference between no devices and no dbus service [09:38:36]  i see, so calling the binary again for the next adapter will just make it exit(0), right? [09:39:45]  probably exit 1 as it's already running [09:40:24]  yeah, you just want to prevent the event to return a failure [09:41:11]  i could do that in a helper [09:41:21]  check whether it's already on the bus using dbus-send [09:41:38]  you want it to return 1 if it wasn't running, but / is ro, or something esle [09:42:23]  you could do, i guess, i would just add that to the binary itself [09:43:37]  so udev "add" events would just always call the helper or the daemon, regardless of the state, and the daemon would take care of exiting itself [09:43:45]  yeah [09:43:58]  then noting of the magic will be needed, right? [09:45:37]  hey, and sorry for calling it piece of crap, i'm just buried in stuff like this, and can't manage it :) [09:46:15]  i think some bits would have to live in the daemon, some others in the helper script [09:46:34]  i think it should maybe go into the daemon itself, otherwise it could be racy and you need to cover the races in the daemon anyway [09:50:36]  what else than: ACTION="add",  RUN+="bluetoothd --exit-if-already-running" would be needed? [09:51:27]  it would return 0 if started successfully, or it was already running [09:52:01]  return 1 if it wasn't already running, and it was unable to start because of ro /, or any other failure [09:53:33]  and it exits if no adapter is left, by dropping the service, while still listening to events, and if no "new device" event comes in, it will exit [09:54:56]  if after dropping the service, a "new device" comes in it will try to reclaim the service, and exit if the new daemon has taken it over, otherwise it will keep running for the new device