eject(1)
NAME
eject − eject media such as CD-ROM and floppy from drive
SYNOPSIS
eject [ −dfnq ] [ device|nickname ]
AVAILABILITY
SUNWcsu
DESCRIPTION
eject is used for those removable media devices that do not have a manual eject button, or for those that do, but are managed by Volume Management. The device may be specified by its name or by a nickname; if Volume Management is running and no device is specified, the default device is used.
Only devices that support eject under program control respond to this command. eject responds differently, depending on whether or not Volume Management is running.
With Volume Management
When eject is used on media that can only be ejected manually, it will do everything except remove the media — including unmounting the file system if it is mounted. In this case, eject displays a message that the media can now be manually ejected. If a window system is running, the message is displayed as a pop-up window. If no window system is running, a message is displayed both to stderr and to the system console that the media can now be physically removed.
Volume Management has the concept of a default device, which eject uses if no pathname or nickname is specified. Use the −d parameter to check what default device will be used.
Without Volume Management
When Volume Management is not running and a pathname is specified, eject just sends the eject command to that pathname. If a nickname is supplied instead of a pathname, eject will recognize the following lists:
| Nickname | Path |
| fd | /dev/rdiskette |
| fd0 | /dev/rdiskette |
| fd1 | /dev/rdiskette1 |
| diskette | /dev/rdiskette |
| diskette0 | /dev/rdiskette0 |
| diskette1 | /dev/rdiskette1 |
| rdiskette | /dev/rdiskette |
| rdiskette0 | /dev/rdiskette0 |
| rdiskette1 | /dev/rdiskette1 |
| floppy | /dev/rdiskette |
| floppy0 | /dev/rdiskette0 |
| floppy1 | /dev/rdiskette1 |
| Nickname | Path |
| cd | /dev/rdsk/c0t6d0s2 |
| cdrom | /dev/rdsk/c0t6d0s2 |
| cd0 | /dev/rdsk/c0t6d0s2 |
| sr | /dev/rdsk/c0t6d0s2 |
| sr0 | /dev/rdsk/c0t6d0s2 |
| /dev/sr0 | /dev/rdsk/c0t6d0s2 |
| /dev/rsr0 | /dev/rdsk/c0t6d0s2 |
| c0t6d0s2 | /dev/rdsk/c0t6d0s2 |
The lists above can be reproduced using the −n option to eject.
It is not recommended to physically eject media from a device which contains mounted filesystems. eject automatically searches for any mounted filesystems which reside on the device and attempts to umount them prior to ejecting the media (see mount(1M)). If the unmount operation fails, eject prints a warning message and exits. The −f flag may be used to specify an eject even if the device contains mounted partitions.
eject can also display its default device and a list of nicknames.
If you have inserted a floppy diskette, you must use volcheck(1) before ejecting the media to inform Volume Management of the floppy’s presence.
OPTIONS
The following options are supported:
−d Display the name of the default device to be ejected.
−f Force the device to eject even if it is busy.
−n Display the nickname to device name translation table.
−q Query to see if the media is present.
OPERANDS
The following operands are supported:
device Specify which device to eject, by the name it appears in the directory /dev.
nickname Specify which device to eject, by its nickname as known to this command.
EXIT STATUS
The following exit codes are returned:
0 If the operation was successful or, with the −q option, the media is in the drive.
1 If the operation was unsuccessful or, with the −q option, the media is not in the drive.
2 If invalid flags were specified.
3 If an ioctl() request failed.
4 Manually ejectable media is now okay to remove.
FILES
/dev/diskette0 default diskette file
/dev/sr0 default CD-ROM file (deprecated)
/dev/dsk/c0t6d0s2 default CD-ROM file
/usr/lib/vold/eject_popup
popup used for manually ejected media
SEE ALSO
volcancel(1), volcheck(1), volmissing(1) mount(1M), rmmount(1M), vold(1M), rmmount.conf(4), vold.conf(4), volfs(7FS)
EXAMPLES
To eject a CD from its drive, while Volume Management is running (assuming only one CD-ROM drive):
example> eject cdrom0
To eject a floppy disk (whether or not Volume Management is running):
example> eject floppy0
To eject a CD-ROM drive with pathname /dev/dsk/c0t3d0s2, without Volume Management running:
example> eject /dev/dsk/c0t3d0s2
DIAGNOSTICS
A short help message is printed if an unknown flag is specified. A diagnostic is printed if the device name cannot be opened or does not support eject.
Device Busy An attempt was made to eject a device that has a mounted filesystem. A warning message is printed when doing a forced eject of a mounted device.
BUGS
There should be a way to change the default on a per-user basis.
If Volume Management is not running, it is possible to eject a volume that is currently mounted (see mount(1M)). For example, if you have a CD-ROM drive at /dev/dsk/c0t3d0s2 mounted on /mnt, the following command (withough Volume Management runnning) will work:
example> eject /dev/dsk/c0t3d0s0
since both slices s0 and s2 reference the whole CD-ROM drive.
SunOS 5.5/SPARC — Last change: 25 Jan 1995