This is eject.c in view mode; [Download] [Up]
/* eject.c Eric Smeesters: 06/07/1994 Laboratoire de Telecommunications de Louvain (Belgique) Small program to eject (and unmount!), from ANY shell, the internal floppy disk of a NeXTstation. NB. IS ONLY WORKING WITH NS3.2 ! Because the floppy is referenced as /dev/rfd0b which is different from earlier versions (/dev/fd0a) */ /***************************************** Preprocessing ********************/ #include <stdio.h> #include <mntent.h> #include <strings.h> /***************************************** main() ***************************/ int main( int argc, char *argv[]) { char umountCommand[100]; FILE *mtabFile; struct mntent *mnt; int cmp; // Floppy path has to be specified if( argc<2) { fprintf( stderr, "Usage: %s <floppy name (path)>\n", argv[0]); return( -1); } // ... but cannot end with a '/'. if( (int )argv[1][strlen(argv[1])-1]=='/') { fprintf( stderr, "*** Floppy path cannot end with a '/'\n"); return( -1); } // First tests the presence of the // internal floppy in the mount table cmp = 1; mtabFile = fopen( "/etc/mtab", "r"); while( (cmp!=0) && ((mnt=getmntent(mtabFile))!=NULL)) { cmp = strncmp( "/dev/rfd0b", mnt->mnt_fsname, 9); } fclose( mtabFile); // ... and aborts if nothing. if( mnt==NULL) { fprintf( stderr, "*** No /dev/rfd0b in the mount table\n"); return( -1); } // Unmounts the internal floppy. sprintf( umountCommand, "/usr/etc/umount -v %s", argv[1]); system( umountCommand); // Tests if the internal floppy really // has been unmounted cmp=1; mtabFile = fopen( "/etc/mtab", "r"); while( (cmp!=0) && ((mnt=getmntent(mtabFile))!=NULL)) { cmp = strncmp( "/dev/rfd0b", mnt->mnt_fsname, 9); } fclose( mtabFile); // ... and ejects floppy only if // /dev/rfd0b isn't in the mount table if( mnt==NULL) { system( "/usr/etc/disk -e /dev/rfd0b"); printf( "disk: floppy ejected from /dev/rfd0b\n"); } else { fprintf( stderr, "*** Floppy not ejected (because still mounted)!\n"); } return( 0); } /****************************************************************************/
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.