static char *sccsid
= "@(#)mount.c 4.10 (Berkeley) %G%";
#define DNMAX (sizeof (mtab[0].m_dname) - 1)
#define PNMAX (sizeof (mtab[0].m_path) - 1)
struct mtab mtab
[NMOUNT
];
char *index(), *rindex();
register struct mtab
*mp
;
mf
= open("/etc/mtab", 0);
read(mf
, (char *)mtab
, sizeof (mtab
));
for (mp
= mtab
; mp
< &mtab
[NMOUNT
]; mp
++)
if (mp
->m_path
[0] != '\0')
if (!strcmp(argv
[1], "-a")) {
if (!strcmp(argv
[1], "-r")) {
if (!strcmp(argv
[1], "-f")) {
if (!strcmp(argv
[1], "-v")) {
while ((fsp
= getfsent()) != 0) {
if (strcmp(fsp
->fs_file
, "/") == 0)
if (strcmp(fsp
->fs_type
, FSTAB_RO
) &&
strcmp(fsp
->fs_type
, FSTAB_RW
) &&
strcmp(fsp
->fs_type
, FSTAB_RQ
))
mountfs(fsp
->fs_spec
, fsp
->fs_file
, fsp
->fs_type
);
mountfs(fs
->fs_spec
, fs
->fs_file
, type
);
"usage: mount [ -a ] [ -r ] [ -f ] [ -v ] [ special dir ] [ dir ]\n");
mountfs(argv
[1], argv
[2], type
);
register struct mtab
*mp
;
printf("%s on %s", mp
->m_dname
, mp
->m_path
);
if (strcmp(mp
->m_type
, FSTAB_RO
) == 0)
if (strcmp(mp
->m_type
, FSTAB_RQ
) == 0)
printf("\t(with quotas)");
mountfs(spec
, name
, type
)
char *spec
, *name
, *type
;
register struct mtab
*mp
;
if (mount(spec
, name
, strcmp(type
, FSTAB_RO
) == 0) < 0) {
fprintf(stderr
, "%s on ", spec
);
/* we don't do quotas.... */
if (strcmp(type
, FSTAB_RQ
) == 0)
for (mp
= mtab
; mp
< &mtab
[NMOUNT
]; mp
++)
if (strcmp(mp
->m_dname
, spec
) == 0)
for (mp
= mtab
; mp
< &mtab
[NMOUNT
]; mp
++)
if (mp
->m_path
[0] == '\0')
strncpy(mp
->m_dname
, spec
, DNMAX
);
mp
->m_dname
[DNMAX
] = '\0';
strncpy(mp
->m_path
, name
, PNMAX
);
mp
->m_path
[PNMAX
] = '\0';
strcpy(mp
->m_type
, type
);
while (mp
> mtab
&& mp
->m_path
[0] == '\0')
mf
= creat("/etc/mtab", 0644);
write(mf
, (char *)mtab
, (mp
- mtab
+ 1) * sizeof (struct mtab
));