Usenet comp.unix.osf.osf1 (1992-2004)
 help / color / mirror / Atom feed
From: talbot@fire.syd.dms.CSIRO.AU (Hugues Talbot)
Subject: Re: cdrom mount for users
Date: 1996/02/05	[thread overview]
Message-ID: <yea68dmgutk.fsf@fire.syd.dms.CSIRO.AU> (raw)
In-Reply-To: 4eo0o6$q9v@unix13.u-3mrs.fr



Hi everyone,

	Here's a little utility that will mount a cd-rom on a Digital
200-4/233 under Dunix 3.2c. I'm not sure about other versions.
	It mounts the cd-rom on /cdrom, assuming your
cd-rom drive in on the SCSI chain at address 4 (device /dev/rz4c).
If your configuration does not match this, then you'll have a bit
of editing to do. Should be straightforward.

	Compile that thing with cc -o cd-mount cd-mount.c, then chmod
s+u root cd-mount, finally place it in a public place (maybe
/usr/local/bin). This will then execute as root. Since the only thing
it does is take that device and mount it in the expected place,
it should be safe enough. I suppose you could do the same thing with a
simple shell script. However, you have to be a bit more cautious with
shell scripts suid to root since they can more easily become security
problems.

	You'll want the cd-umount utility as well. It's listed
after that. suid u+s root cd-umount as well.

	If unhappy about something let me know.

-------------------------------------------------------
cd-mount.c


/*
 * this mounts a ISO-9660 CD-ROM on a DEC UNIX 200 E
 * workstation
 *
 * by Hugues Talbot     10 Jan 1996
 *
 */
#include <errno.h>
#include <sys/mount.h>
#include <cdfs/cdfsmount.h>
#include <stdio.h>


main()
{
    int res;
    struct cdfs_args cd_struct;

    /* fill the structure */
    cd_struct.fspec = "/dev/rz4c";
    cd_struct.exflags = 0;
    cd_struct.exroot = 0;
    cd_struct.flags = M_NOVERSION | M_RRIP;
    cd_struct.version = 0;
    cd_struct.default_uid = 0;
    cd_struct.default_gid = 0;  /* root all the time by default... */
    cd_struct.default_fmode = 0664;
    cd_struct.default_dmode = 0755;
    cd_struct.map_uid_ct = 0;
    cd_struct.map_uid = NULL;
    cd_struct.map_gid_ct = 0;
    cd_struct.map_gid = NULL;

    /* mount read-only and no suid of any kind */
    res = mount(MOUNT_CDFS, "/cdrom",
                M_RDONLY | M_NOSUID,
                &cd_struct);

    if (res != 0) {
        switch (errno) {
          case EPERM:
            fprintf(stderr, "Insufficient permissions\n");
            break;
          case ENAMETOOLONG:
            fprintf(stderr, "Path name too long\n");
            break;
          case ELOOP:
            fprintf(stderr, "Recursive path\n");
            break;
          case EMFILE:
            fprintf(stderr, "Mount table is full\n");
            break;
          case ENOENT:
            fprintf(stderr, "Mount point invalid\n");
            break;
          case ENOTDIR:
            fprintf(stderr, "Mount point not a directory\n");
            break;
          case EINVAL:
            fprintf(stderr, "File system name invalid\n");
            break;
          case EBUSY:
            fprintf(stderr, "Mount point is busy\n");
            break;
          case EDIRTY:
            fprintf(stderr, "Filesystem is dirty\n");
            break;
          case EFAULT:
            fprintf(stderr, "Mount point pointer invalid\n");
            break;
          case ENODEV:
            fprintf(stderr, "A component of fspec does not exist\n");
            break;
          case ENOTBLK:
            fprintf(stderr, "Not a block device\n");
            break;
          case ENXIO:
            fprintf(stderr, "Block number out of range. No driver"
                    "exists for hardware\n");
            break;
          case ENOMEM:
            fprintf(stderr, "Not enough memory\n");
            break;
          case EIO:
            fprintf(stderr, "I/O error. Ouch, not very informative...\n");
            break;
          default:
            fprintf(stderr, "Unknown error #%d\n", errno);
            break;          
        }
    }
    
    return res;
}


-----------------------------------------------------
cd-umount.c

/*
 *
 * This unmount a CD-ROM from a DEC UNIX 200 workstation
 *
 * by Hugues Talbot     10 Jan 1996
 *
 */

#include <errno.h>
#include <sys/mount.h>
#include <stdio.h>


main()
{
    int res;

    res = umount("/mnt", 0);

    if (res != 0) {
        switch (errno) {
          case EPERM:
            fprintf(stderr, "Insufficient privilege\n");
            break;
          case ENOTDIR:
            fprintf(stderr, "Given path is not a directory\n");
            break;
          case ENAMETOOLONG:
            fprintf(stderr, "Given path is too long\n");
            break;
          case ELOOP:
            fprintf(stderr, "Infinite recursion in path\n");
            break;
          case EINVAL:
            fprintf(stderr, "CD-ROM was not mounted\n");
            break;
          case EBUSY:
            fprintf(stderr, "Device is busy\n");
            break;
          case EIO:
            fprintf(stderr, "I/O error. Bad...\n");
            break;
          case EFAULT:
            fprintf(stderr, "Path pointer out of address space\n");
            break;
          default:
            fprintf(stderr, "Unknown error #%d\n", errno);
            break;
        }
    }   
    
    return res;
}

---------------------------------------------------------






  reply	other threads:[~1996-02-05  5:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-01-31  5:00 cdrom mount for users Christophe MATHIEU
1996-02-05  5:00 ` Hugues Talbot [this message]
1996-02-05  5:00   ` Alain Cedelle
1996-02-05  5:00 ` Hugues Talbot
1996-02-07  5:00 ` Simon Wright
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox