📄 cdfs_mount.c
字号:
#ifndef lintstatic char *sccsid = "@(#)cdfs_mount.c 4.1 (ULTRIX) 11/9/90";#endif lint/************************************************************************ * * * Copyright (c) 1986, 87, 89 by * * Digital Equipment Corporation, Maynard, MA * * All rights reserved. * * * * This software is furnished under a license and may be used and * * copied only in accordance with the terms of such license and * * with the inclusion of the above copyright notice. This * * software or any other copies thereof may not be provided or * * otherwise made available to any other person. No title to and * * ownership of the software is hereby transferred. * * * * This software is derived from software received from the * * University of California, Berkeley, and from Bell * * Laboratories. Use, duplication, or disclosure is subject to * * restrictions under license agreements with University of * * California and with AT&T. * * * * The information in this software is subject to change without * * notice and should not be construed as a commitment by Digital * * Equipment Corporation. * * * * Digital assumes no responsibility for the use or reliability * * of its software on equipment which is not supplied by Digital. * * * ************************************************************************//*********************************************************************** * Modification History * fs/cdfs/cdfs_mount.c * * 08-Jun-90 -- prs * Initial creation cdfs_mount.c * ***********************************************************************/#include "../h/param.h"#include "../h/systm.h"#include "../h/dir.h"#include "../h/user.h"#include "../h/gnode_common.h"#include "../fs/cdfs/cdfs_fs.h"#include "../fs/cdfs/cdfs_inode.h"#include "../h/gnode.h"#include "../h/proc.h"#include "../h/fs_types.h"#include "../h/buf.h"#include "../h/mount.h"#include "../h/file.h"#include "../h/kernel.h"#include "../h/conf.h"#include "../h/ioctl.h"#include "../h/devio.h"#include "../cdfs/cdfs_mount.h"#include "../h/kmalloc.h"#include "../h/cpudata.h"int cdfs_umount(), cdfs_ginit(), cdfs_inactive();struct gnode *cdfs_namei();int cdfs_link(), cdfs_unlink(), cdfs_rmdir();struct gnode *cdfs_mkdir();struct gnode *cdfs_maknode();int cdfs_rename(), cdfs_getdirent();struct gnode *cdfs_galloc();int cdfs_syncgp(), cdfs_gfree(), cdfs_gtrunc();int cdfs_rwgp(), cdfs_rlock();int cdfs_seek(), cdfs_stat(), cdfs_glock();int cdfs_gunlock(), cdfs_gupdat(), cdfs_open();int cdfs_close(), cdfs_select(), cdfs_readlink();int cdfs_symlink();struct fs_data *cdfs_getfsdata();int cdfs_fcntl(), cdfs_bmap();struct mount_ops Cdfs_mount_ops = {/* begin mount ops */ cdfs_umount, 0, /* sb update */ cdfs_ginit, 0, /* match */ 0, /* reclaim */ cdfs_inactive, cdfs_getfsdata,};struct gnode_ops Cdfs_gnode_ops = {/* begin gnode ops */ cdfs_namei, cdfs_link, cdfs_unlink, cdfs_mkdir, cdfs_rmdir, cdfs_maknode, cdfs_rename, cdfs_getdirent, 0, cdfs_syncgp, 0, /* truncate */ 0, /*getval*/ cdfs_rwgp, cdfs_rlock, cdfs_seek, cdfs_stat, cdfs_glock, cdfs_gunlock, cdfs_gupdat, cdfs_open, cdfs_close, cdfs_select, cdfs_readlink, cdfs_symlink, cdfs_fcntl, 0, /* gfreegn */ cdfs_bmap};struct mount_ops *cdfs_mount_ops = &Cdfs_mount_ops;struct gnode_ops *cdfs_gnode_ops = &Cdfs_gnode_ops;int isodebug = 0;int strat_begin_initialized = 0;struct iso_strat iso_strat_begin;/* this routine has lousy error codes *//* this routine has races if running twice */struct mount *cdfs_mount(devname, name, ronly, mp, fs_specific) char *devname; char *name; int ronly; register struct mount *mp; struct iso_specific *fs_specific;{ dev_t dev; register struct buf *tp = NULL; register struct buf *bp = NULL; register struct iso_fs *iso_fs = 0; register struct hsg_fs *hsg_fs = 0; register struct fs *fs; register struct mount *nmp; register struct gnode *gp; struct iso_dir *iso_tdir; struct hsg_dir *hsg_tdir; int blks; caddr_t space; int i, size; struct gnode gnode; struct devget devget; struct iso_specific iso_sp; int saveaffinity; unsigned int loc; unsigned int primary_loc, supplementary_loc; union { unsigned char incoming[4]; unsigned int outgoing; } convert_extent; extern struct lock_t lk_mount_table;#ifdef notdef if (strat_begin_initialized == 0) { strat_begin_initialized++; iso_strat_begin.strat_forw = &iso_strat_begin; iso_strat_begin.strat_back = &iso_strat_begin; }#endif notdef if (u.u_error = getmdev(&dev, devname, u.u_uid)) { goto done; } GETMP(nmp, dev); if (nmp != NULL) { u.u_error = EBUSY; /* someone has us mounted */ goto done; } if (fs_specific != NULL) { u.u_error = copyin((caddr_t) fs_specific, (caddr_t) &iso_sp, sizeof(iso_sp)); if (u.u_error) goto done; fs_specific = &iso_sp; } dnlc_purge(); /* * check_mountp will verify local mount point exists and is * ok to mount on. */ if (!(check_mountp(mp, name))) goto done; /* * this is a hack but I can't see a way around it * we need a gnode before we have the system mounted so we push * one on the stack and hand craft it. The gget at the end replaces * this fake gnode with the real one. */ gnode.g_mode = GFBLK; gnode.g_dev = gnode.g_rdev = dev; gnode.g_ops = cdfs_gnode_ops; /* set pointer to file ops */ gnode.g_mp = mp; mp->m_rootgp = &gnode; /* set up some stuff that smount cannot accomplish */ /* Search mount table for entry using tdev */ smp_lock(&lk_mount_table, LK_RETRY); for (nmp = mount; nmp < &mount[nmount]; nmp++) { if (nmp->m_dev == dev) { smp_unlock(&lk_mount_table); u.u_error = EBUSY; goto done; } } mp->m_dev = dev; smp_unlock(&lk_mount_table); mp->iostrat = bdevsw[major(dev)].d_strategy; /* set this now! */ mp->m_ops = cdfs_mount_ops; mp->m_flags = M_RONLY | M_LOCAL; if (fs_specific != NULL) { int pg_thresh = fs_specific->iso_pgthresh * 1024; mp->m_flags |= (fs_specific->iso_flags & (M_DEFPERM | M_NODEFPERM | M_NOVERSION | M_PRIMARY)); mp->m_fs_data->fd_pgthresh = clrnd(btoc((pg_thresh > MINPGTHRESH) ? pg_thresh : MINPGTHRESH)); } else { /* * if we don't specify the threshhold, use 64kB */ mp->m_fs_data->fd_pgthresh = clrnd(btoc(MINPGTHRESH * 8)); mp->m_flags |= M_DEFPERM; } /* * Non super users cannot look at entire disk by default. */ if (!suser()) mp->m_flags &= ~M_PRIMARY; CALL_TO_NONSMP_DRIVER(bdevsw[major(dev)], saveaffinity); u.u_error = (*bdevsw[major(dev)].d_open)(dev, FREAD); RETURN_FROM_NONSMP_DRIVER(bdevsw[major(dev)], saveaffinity); if (u.u_error) goto done; bzero(&devget,sizeof(struct devget)); CALL_TO_NONSMP_DRIVER(bdevsw[major(dev)], saveaffinity); u.u_error = (*bdevsw[major(dev)].d_ioctl)(dev, DEVIOCGET, &devget, 0); RETURN_FROM_NONSMP_DRIVER(bdevsw[major(dev)], saveaffinity); if (u.u_error) { printf("file system device ioctl failure"); } if (devget.stat & DEV_OFFLINE) { u.u_error = ENODEV; goto ERROR; } primary_loc = supplementary_loc = 0; loc = PVD_BLOCK; for (;;) { /* * Read Primary Volume Descriptor */ tp = bread(dev, loc, ISO_SECSIZE, (struct gnode *) NULL); if (tp->b_flags & B_ERROR) { uprintf("cdfs_mount: Terminating volume descriptor not found\n"); brelse(tp); goto ERROR; } iso_fs = (struct iso_fs *)tp->b_un.b_fs; /* * Check the magic number and see * if we have a valid filesystem.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -