0

I am trying to update the CUPS daemon on my QNAP NAS, which runs a flavor of *nix. The entire OS system is loaded on a RAMDISK when the NAS boots so I've come up with a script that runs at start-up and injects my own coding. Now my problem is that I need to trigger the kernel action so that the usb printer driver calls the cupsd.sh script.

According to the manufacturer:

We modified the "USB Printer Device Class driver" of Linux kernel to issue a signal/message when plug-in/out a USB printer. After the daemon, picd get signal/message, it will call cupsd.sh to add_printer/del_printer .

Any ideas how I can accomplish this?

user9517
  • 115,471
  • 20
  • 215
  • 297
Chris19
  • 61
  • 1
  • 1
  • 4

1 Answers1

0

Normally, it is done by udev in Linux, however I'm not sure if QNAP is using it. Another alternative is mdev from busybox. Check your system to see which approach it uses and then read corresponding documentation.

Generally the way it works is as follows:

  • kernel generates even when you plug new device,
  • a user space daemon (udev or mdev) listens for these events,
  • the event goes through a chain of rules and if match is found then corresponding action is taken,
  • the action can be to execute your custom script.
dtoubelis
  • 4,677
  • 1
  • 29
  • 32
  • And how would I be able to check if udev or mdev is used? ... I can't find any of the binaries on the PATH. On a side note, I tried to unload the usbcore module and reinitialize it but with little success because it complains about missing module.dep ... Am I right to think that if I manage to reinitialize the usbcore module the system will think that a new device has been added and do it's normal routine? – Chris19 Nov 22 '11 at 07:25
  • Try `grep [um]dev /etc/init.d/*`. I'm not very familiar with usbcore module, but in a grand scheme - this should be the module that provides events to udev/mdev. BTW, do you see any messages with `dmesg` when you add your device? If so, that means usbcore module is working and you only meed to figure out udev/mdev stuff. – dtoubelis Nov 22 '11 at 15:36
  • I just got access to a qnap box and it seems that they do hot plugging it in a very custom way without using mdev. So, all I said before does not apply here. Sorry. – dtoubelis Nov 22 '11 at 15:55