* Copyright (c) 1980 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
"@(#) Copyright (c) 1980 Regents of the University of California.\n\
static char sccsid
[] = "@(#)mount.c 5.3 (Berkeley) %G%";
(strcmp(type, FSTAB_RO) && strcmp(type, FSTAB_RW) && \
(!strcmp(type, FSTAB_RW) || !strcmp(type, FSTAB_RQ))
static struct mtab mtab
[NMOUNT
];
static int fake
, verbose
;
register struct mtab
*mp
;
register struct fstab
*fs
;
while ((ch
= getopt(argc
, argv
, "afrwv")) != EOF
)
if ((fd
= open(MTAB
, O_RDONLY
, 0)) >= 0) {
if (read(fd
, (char *)mtab
, NMOUNT
* sizeof(struct mtab
)) < 0)
while ((fs
= getfsent()))
if (strcmp(fs
->fs_file
, "/") && !BADTYPE(fs
->fs_type
))
mountfs(fs
->fs_spec
, fs
->fs_file
,
type
? type
: fs
->fs_type
);
if (verbose
|| fake
|| type
)
for (mp
= mtab
, cnt
= NMOUNT
; cnt
--; ++mp
)
if (!(fs
= getfsfile(*argv
)) && !(fs
= getfsspec(*argv
))) {
"mount: unknown special file or file system %s.\n",
if (BADTYPE(fs
->fs_type
)) {
"mount: %s has unknown file system type.\n", *argv
);
mountfs(fs
->fs_spec
, fs
->fs_file
, type
? type
: fs
->fs_type
);
mountfs(argv
[0], argv
[1], type
? type
: "rw");
mountfs(spec
, name
, type
)
char *spec
, *name
, *type
;
register struct mtab
*mp
, *space
;
char *index(), *rindex(), *strcpy();
if (mount(spec
, name
, type
)) {
fprintf(stderr
, "%s on %s: ", spec
, name
);
fprintf(stderr
, "Mount table full\n");
fprintf(stderr
, "Bogus super block\n");
/* we don't do quotas.... */
if (strcmp(type
, FSTAB_RQ
) == 0)
/* trim trailing /'s and find last component of name */
for (p
= index(spec
, '\0'); *--p
== '/';);
if (p
= rindex(spec
, '/')) {
for (mp
= mtab
, cnt
= NMOUNT
, space
= NULL
; cnt
--; ++mp
) {
if (!strcmp(mp
->m_dname
, spec
))
if (!space
&& !*mp
->m_path
)
fprintf(stderr
, "mount: no more room in %s.\n", MTAB
);
#define DNMAX (sizeof(mtab[0].m_dname) - 1)
#define PNMAX (sizeof(mtab[0].m_path) - 1)
(void)strncpy(mp
->m_dname
, spec
, DNMAX
);
mp
->m_dname
[DNMAX
] = '\0';
(void)strncpy(mp
->m_path
, name
, PNMAX
);
mp
->m_path
[PNMAX
] = '\0';
(void)strcpy(mp
->m_type
, type
);
for (mp
= mtab
+ NMOUNT
- 1; mp
> mtab
&& !*mp
->m_path
; --mp
);
if ((fd
= open(MTAB
, O_WRONLY
|O_CREAT
|O_TRUNC
, 0644)) < 0)
cnt
= (mp
- mtab
+ 1) * sizeof(struct mtab
);
if (write(fd
, (char *)mtab
, cnt
) != cnt
)
register struct mtab
*mp
;
printf("%s on %s", mp
->m_dname
, mp
->m_path
);
if (!strcmp(mp
->m_type
, FSTAB_RO
))
else if (!strcmp(mp
->m_type
, FSTAB_RQ
))
printf("\t(with quotas)");
fprintf(stderr
, "mount: %s: ", MTAB
);
fprintf(stderr
, "usage: mount [-arw]\nor mount [-rw] special | node\nor mount [-rw] special node\n");