SCCS-vsn: sbin/mount/mount.c 4.3
-static char *sccsid = "@(#)mount.c 4.2 (Berkeley) %G%";
+static char *sccsid = "@(#)mount.c 4.3 (Berkeley) %G%";
#include <stdio.h>
#include <fstab.h>
#include <stdio.h>
#include <fstab.h>
char spec[NAMSIZ];
} mtab[NMOUNT];
char spec[NAMSIZ];
} mtab[NMOUNT];
main(argc, argv)
char **argv;
{
main(argc, argv)
char **argv;
{
register struct mtab *mp;
register char *np;
int mf;
register struct mtab *mp;
register char *np;
int mf;
if (strcmp(argv[1], "-a") == 0)
mountall++;
else {
if (strcmp(argv[1], "-a") == 0)
mountall++;
else {
- fprintf(stderr,"arg count\n");
+ fprintf(stdout,"arg count\n");
ro = 0;
if(argc > 3)
ro++;
ro = 0;
if(argc > 3)
ro++;
- if (mountfs(argv[1], argv[2], ro))
- exit(1);
- } else {
- FILE *fs_file;
- struct fstab fs;
- if ((fs_file = fopen(FSTAB, "r")) == NULL){
- perror(FSTAB);
+ if (mountfs(argv[1], argv[2], ro)){
+ perror("mount");
- while (!feof(fs_file)){
- int ro;
- fscanf(fs_file, FSTABFMT, FSTABARG(&fs));
- if (strcmp(fs.fs_file, "/") == 0)
+ } else {
+ struct fstab *fsp;
+ close(2); dup(1);
+ if (setfsent() == 0)
+ perror(FSTAB), exit(1);
+ while ( (fsp = getfsent()) != 0){
+ if (strcmp(fsp->fs_file, "/") == 0)
- ro = !strcmp(fs.fs_type, "ro");
- if (ro==0 && strcmp(fs.fs_type, "rw"))
+ ro = !strcmp(fsp->fs_type, FSTAB_RO);
+ if (ro==0 && strcmp(fsp->fs_type, FSTAB_RW))
- fprintf(stderr, "Mounting %s on %s %s",
- fs.fs_file, fs.fs_spec,
- ro ? "(Read Only)\n" : "\n");
- mountfs(fs.fs_spec, fs.fs_file, ro);
+ if (mountfs(fsp->fs_spec, fsp->fs_file, ro))
+ failed(fsp);
+ else
+ succeed(fsp);
+failed(fsp)
+ register struct fstab *fsp;
+{
+ extern int errno;
+ extern char *sys_errlist[];
+ int err = errno;
+ printf("Attempt to mount ");
+ location(fsp);
+ printf("FAILED: %s\n", sys_errlist[err]);
+}
+succeed(fsp)
+ register struct fstab *fsp;
+{
+ printf("Mounted ");
+ location(fsp);
+ printf("\n");
+}
+location(fsp)
+ register struct fstab *fsp;
+{
+ extern int ro;
+ printf("%s on %s %s ",
+ fsp->fs_file, fsp->fs_spec,
+ ro ? "(Read Only)" : "");
+}
mountfs(spec, name, ro)
char *spec, *name;
mountfs(spec, name, ro)
char *spec, *name;
int mf;
if(mount(spec, name, ro) < 0) {
int mf;
if(mount(spec, name, ro) < 0) {