Sample Header Ad - 728x90

udev rule odd behavior with bluray disc drive

3 votes
0 answers
55 views
I have a udev rule that runs a script when a bluray disc is loaded. I am aware of the time limit on udev scripts and so have the script run a child script with the "at now" command. The child script then does a bunch of ripping and post processing. The strange behavior is that any attempt to read the disc label returns an empty string when run from udev. But, if I run the same script from the command line, it has no problem spinning up the disc and reading the label. in fact, I even have a test script that I tried that only loops and tries to read the label and echo to a text file. It sits and loops outputting an empty string. Whats also weird is that any media check in the udev script says the disc is loaded and ready to go. udev rule:
UBSYSTEM=="block", ENV{ID_CDROM}=="1", ENV{ID_TYPE}=="cd", ACTION=="change", RUN+="/usr/local/bin/autodisk '%E(DEVNAME)'"
udev script autodisk:
#!/bin/bash

{
  if [ "$ID_CDROM_MEDIA_BD" -eq "1" ]; then
    echo /home/nathan/rom_ready $DEVNAME | at now
    exit 1
  fi
}
rom_ready script
#!/bin/bash
counter=0

device=$1

echo $device >  /home/nathan/.var/log/diskrip/.diskripper.log
while true; do

  file -s $device >> /home/nathan/.var/log/diskrip/.diskripper.log
  sleep 1
  echo "loop" >>  /home/nathan/.var/log/diskrip/.diskripper.log
  discname=$(blkid -o value -s LABEL $device)
  echo $discname >>  /home/nathan/.var/log/diskrip/.diskripper.log

  counter=$((counter + 1))
  if [ $counter -ge 20 ]; then break; fi
  
done
the line **file -s $device >> ~/log.text** writes "/dev/sr0: data" to the log file, but that shouldn't happen if the disc isn't ready to read. While rom_ready is looping and failing to output the disc label, if I open a terminal and read the label, i can get the label from the command line, but the rom_ready keeps getting blank data. Also if I run the rom_ready from the terminal instead of from udev, it executes as expected. It's like when I put the disc in and udev is the only thing that initiates an action, the system thinks the disc has been read from, but nothing has actually been read, so all the fields are empty. Whats also weird is that if I include a call to makemkvcon in the udev script, it has no problem loading and ripping the disc as well as naming the file. It just sucks, because I can't automate naming of the directories ahead of time. This doesn't seem to be a problem with regular dvd discs. It reads the label, creates a directory with the name of the movie title, and then rips the disk into that directory.
Asked by Nathan Shaffer (31 rep)
Jul 22, 2024, 03:13 AM
Last activity: Jul 22, 2024, 05:55 PM