[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: automounting cdrom?



Just a small example for automounting cdrom, using amd.

I created :  /amd/a   (real cdrom mount point)
             /amd/nfs (amd-nfs mount point)
             /cdrom -> /amd/nfs/cd  (to acces cdrom directly)


 the amd config file /etc/amd/amd.cd :
-----
cd      type:=program;fs:=/amd/a;mount:="/etc/amd/cd_mount.sh cd_mount.sh /amd/a";unmount:="/etc/amd/cd_umount.sh cd_umount.sh /amd/a"
-----

 It uses 2 shell scripts, to mount & umount cdrom


 /etc/amd/cd_mount.sh
-----
#!/bin/sh

/sbin/mount /dev/cd0a $1
/etc/amd/cd_lock /dev/rcd0c lock
------


 /etc/amd/cd_umount.sh
------
#!/bin/sh

/etc/amd/cd_lock /dev/rcd0c unlock
/sbin/umount $1
------


 To run amd (check if portmap is running first..) :

# /usr/sbin/amd -p -c 30 -a /amd/a /amd/nfs /etc/amd/amd.cd > /etc/amd/.amd.pid



 cd_lock is used to lock/unlock cd door :
-----
#include        <sys/cdio.h>
#include        <sys/ioctl.h>
#include        <fcntl.h>


int main(int ac, char **av)
{
  int   fd;

  if (ac>2)
    if ((fd = open(av[1],O_RDWR))==-1)
      exit(-1);
  if (ac>2 && !strcmp(av[2],"lock"))
    exit(ioctl(fd,CDIOCPREVENT));
  if (ac>2 && !strcmp(av[2],"unlock"))
    exit(ioctl(fd,CDIOCALLOW));
  printf("Usage: %s <device> (lock|unlock)\n",av[0]);
  exit(-1);
}
--------


  More checks should be done to handle all cases
  (cd_lock & mount exit status ...)


Olivier


Msg from Peter H. Coffin :
> On Tue, Feb 25, 2003 at 08:55:06PM -0800, Patrick Gibson wrote:
> > I'm trying to configure amd to automount my CDROM drive. I'm having a hell
> > of a time finding an example of how to do this in OpenBSD. I've searched
> > "info amd", Google, and the mailing list archive, but so far I haven't found
> > anything that works.
> > 
> > Is there anyone who has an /etc/amd/master file with an entry for
> > automounting the CDROM?
> 
> I take it you want to be able to just drop a cd in and use it, rather
> than simply making the drive mount at boot with fstab?
> 
> -- 
> 62. I will design fortress hallways with no alcoves or protruding structural 
>     supports which intruders could use for cover in a firefight.
>                 --Peter Anspach's list of things to do as an Evil Overlord
> 

-- 
--------------------------------------------------------
     Olivier Crouzet                --{Epitech.}--
       ol_(_at_)_epita_(_dot_)_fr                14-16 rue Voltaire
     01 44 08 01 01            94276 le Kremlin Bicetre
--------------------------------------------------------



Visit your host, monkey.org