cd_setdevmap(3X)


cd_setdevmap -- set or unset major and minor numbers assignments for a CD-ROM device

Synopsis

   cc [flag . . . ] file . . . -lcdfs -lgen [library] . . .
   

#include <sys/cdrom.h>

int cd_setdevmap(const char *path, int cmd, int *new_major, int *new_minor);

Description

cd_setdevmap sets (reassigns) or unsets, depending on the value of cmd, the major and minor numbers of a device file to new values so the appropriate device on the host system is accessed.

The major and minor number of any device files on a CD-ROM are assigned by the CD-ROM publisher during manufacturing. These values may not match the major and minor numbers assigned to the physical devices on the host system.

When a device file is referenced, the major and minor number assigned using the cd_setdevmap function or the values recorded on the media are used. When the CD-ROM is unmounted, any new major and minor number assignments are invalidated.

The cd_setdevmap function should be used before the device file is used, otherwise the change will not take effect until the device file is closed and reopened. Only a privileged user can use the cd_setdevmap function.

The maximum number of device files per CD-ROM that can be reset is defined in sys/cdrom.h.

The cd_setdevmap function must be specified as follows:


path
Points to a device file within the CD-ROM file hierarchy.

cmd
Specifies the command to execute (set or unset). cmd is one of the following:

CD_SETDMAP
Specifies that the original major and minor number pair of a device file (specified by path) be replaced with the value specified by new_major and new_minor. Any previous reassignments are overridden.

CD_UNSETDMAP
Specifies that the major and minor numbers of the device file pointed to by path should be unset (the values on the mounted CD-ROM will be used from then on).

new_major
Identifies the memory location where the major number is stored.

new_minor
Identifies the memory location where the minor number is stored.

Return values

For CD_SETDMAP, exit status is 1 if the major and minor number of the device file is successfully reassigned, and the exit status is 0 if no more assignments are allowed.

For CD_UNSETDMAP, the exit status is 1 if the major and minor number assignments of the device file is successfully unset, and the exit status is 0 if the major and minor number assignments of the device files are not found.

Exit status is -1 if an error occurs, and errno is set to indicate the error as follows:


EACCES
Search permission is denied for a component of the path prefix.

EACCES
Write permission on the device file pointed to by path is denied.

EFAULT
The address of path, new_major, or new_minor is invalid.

EINTR
A signal was caught during the cd_setdevmap function.

EINVAL
The value of cmd is invalid.

EINVAL
The path argument points to a device file that is not within the CD-ROM file hierarchy.

EINVAL
The file pointed to by path is not a device file.

EMFILE
Too many file descriptors are currently open in the calling process.

ENAMETOOLONG
The length of the path string exceeds MAXPATHLEN.

ENAMETOOLONG
A pathname component is longer than MAXNAMELEN while _POSIX_NO_TRUNC is in effect.

ENFILE
The system file table is full.

ENOENT
A component of path does not exist.

ENOENT
The path argument points to an empty string.

ENOTDIR
A component of the path prefix is not a directory.

ENXIO
The CD-ROM is not in the drive.

ENXIO
A read error occurred.

EPERM
User does not have read/write permission for the specified device file.

References

cd_getdevmap(3X), cddevsuppl(1M), cdsuf(1M)

Rock Ridge Interchange Protocol from the Rock Ridge Technical Working Group


© 2004 The SCO Group, Inc. All rights reserved.
UnixWare 7 Release 7.1.4 - 25 April 2004