⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ufs_mount.c

📁 <B>Digital的Unix操作系统VAX 4.2源码</B>
💻 C
📖 第 1 页 / 共 2 页
字号:
#ifndef lintstatic	char	*sccsid = "@(#)ufs_mount.c	4.4	(ULTRIX)	2/28/91";#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 * * 27 Feb 91 -- chet *	Fix filesystem timestamping. * * 21 Jan 91 -- dws *	Added initialization of partition ID in ufs_mount(). * * 17 Nov 89 -- prs *	Fixed the error message in ufs_mount() when the default *	clean byte timeout factor does not exist. * * 14 Jun 89 -- condylis *      Added code to insure we are placing a unique dev *      number in the mount table entry. * * 14 Jun 89 -- prs *	Added clean byte timeout logic. * * 13-Jun-89 -- Fred Canter *	Fix improper use of DEVIOCGET category_stat. * * 03-May-89 -- Tim Burke *      Allow for the unit number of root disks to be 3 digits; ie ra100a. * * 06 Apr 89 -- prs *	Added SMP quota locks. * * 28 Jul 88 -- prs *	SMP - System call turn on. * * 19 May 88 -- prs *	SMP - Added locks around calls to driver routines. * * 06 Apr 88 -- prs *      Changed handling of the clean byte in the super block *      from the fs_fmod field to fs_clean. * * 12-11-87	Robin L. and Larry C. *	Added new kmalloc memory allocation to system. * * 27 Oct 87 -- rsp *	Added bzero just before DEVIOCGET request. * * 12 May 87 -- prs *	Added call to check_mountp to verify local mount point *	exists. * * 02 Mar 87 -- logcher *	Merged in diskless changes, added changes for new ops * * 15 Jan 87 -- prs *	Added or'ing in the M_QUOTA bit to the mount structures flags *	field. * * 04 Dec 86 -- prs *	Made changes to not set FS_CLEAN byte if a file system *	was mounted with -o force in ufs_sbupdat. * * 11 Sep 86 -- koehler *	made changes for synchronous fs and user level mounts * ***********************************************************************/#include "../h/param.h"#include "../h/systm.h"#include "../h/dir.h"#include "../h/user.h"#include "../h/gnode_common.h"#include "../ufs/ufs_inode.h"#include "../h/gnode.h"#include "../h/proc.h"#include "../ufs/fs.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 "../ufs/ufs_mount.h"#include "../h/kmalloc.h"#include "../h/cpudata.h"int		ufs_umount(),	ufs_sbupdat(),	ufs_ginit(),	ufs_inactive();struct gnode	*ufs_namei();int		ufs_link(),	ufs_unlink(),	ufs_rmdir();struct gnode	*ufs_mkdir();struct gnode	*ufs_maknode();int		ufs_rename(),	ufs_getdirent();struct gnode	*ufs_galloc();int		ufs_syncgp(),	ufs_gfree(),	ufs_gtrunc();int		ufs_rwgp();int		ufs_rlock();int		ufs_seek(),	ufs_stat(),	ufs_glock();int		ufs_gunlock(),	ufs_gupdat(),	ufs_open();int		ufs_close(),	ufs_select(),	ufs_readlink();int		ufs_symlink();struct fs_data	*ufs_getfsdata();int		ufs_fcntl(),	ufs_bmap();struct	mount_ops Ufs_mount_ops = {/* begin mount ops */	ufs_umount,	ufs_sbupdat,	ufs_ginit,	0,		/* match */	0,		/* reclaim */	ufs_inactive,	ufs_getfsdata,};struct	gnode_ops Ufs_gnode_ops = {/* begin gnode ops */	ufs_namei,	ufs_link,	ufs_unlink,	ufs_mkdir,	ufs_rmdir,	ufs_maknode,	ufs_rename,	ufs_getdirent,	0,	ufs_syncgp,	ufs_gtrunc,	0, 		/*getval*/	ufs_rwgp,	ufs_rlock,	ufs_seek,	ufs_stat,	ufs_glock,	ufs_gunlock,	ufs_gupdat,	ufs_open,	ufs_close,	ufs_select,	ufs_readlink,	ufs_symlink,	ufs_fcntl,	0,		/* gfreegn */	ufs_bmap};struct  mount_ops  *ufs_mount_ops = &Ufs_mount_ops;struct  gnode_ops  *ufs_gnode_ops = &Ufs_gnode_ops;gno_t rootino = (gno_t) ROOTINO;/* this routine has lousy error codes *//* this routine has races if running twice */struct mount *ufs_mount(devname, name, ronly, mp, fs_specific)	char *devname;	char *name;	int ronly;	register struct mount *mp;	struct ufs_specific *fs_specific;{	dev_t	dev;	register struct buf *tp = NULL;	register struct buf *bp = NULL;	register struct fs *fs;	register struct mount *nmp;	register struct gnode *gp;	int blks;	caddr_t space;	int i, size;	int root;	struct gnode gnode;	struct devget devget;	struct ufs_specific ufs_sp;	int force = 0;	int saveaffinity;	extern struct lock_t lk_mount_table;	/* special case this when we are mounting the root fs */		root = devname == NULL;		if (!root) { /* we are not mounting / */		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)			&ufs_sp, sizeof(ufs_sp));			if (u.u_error)				goto done;			fs_specific = &ufs_sp;		}		/*		 * check_mountp will verify local mount point exists and is		 * ok to mount on.		 */		if (!(check_mountp(mp, name)))			goto done;	} else {		force = 1;		dev = rootdev;		/* map the root device from config */	}	/* 	 * 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 = ufs_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 = ufs_mount_ops;	mp->m_flags = ((ronly) ? M_RONLY : 0) | M_LOCAL;	if (fs_specific != NULL) {		int pg_thresh = fs_specific->ufs_pgthresh * 1024;		mp->m_flags |= (fs_specific->ufs_flags & (M_RONLY | M_NOEXEC |			M_QUOTA | M_NOSUID | M_NODEV | M_FORCE | M_SYNC));		mp->m_fs_data->fd_pgthresh = 			clrnd(btoc((pg_thresh > MINPGTHRESH) ?				pg_thresh : MINPGTHRESH));				/* only the superuser can mount forceably */		force = (fs_specific->ufs_flags & M_FORCE) && (u.u_uid == 0);	} else {		/*		 * if we don't specify the threshhold, use 64kB		 */		mp->m_fs_data->fd_pgthresh = clrnd(btoc(MINPGTHRESH * 8));	}	CALL_TO_NONSMP_DRIVER(bdevsw[major(dev)], saveaffinity);	u.u_error = (*bdevsw[major(dev)].d_open)(dev, ronly ? FREAD : FREAD|FWRITE);	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) {		if (!root) {			printf("file system device ioctl failure");		} else {			printf("root file system device ioctl failure");		}	}	if (devget.stat & DEV_OFFLINE) {		u.u_error = ENODEV;		goto ERROR;	}	if ((devget.stat & DEV_WRTLCK) && !ronly) {		if (!root) {			u.u_error = EROFS;			goto ERROR;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -