當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Inode.Mounted方法代碼示例

本文整理匯總了Golang中github.com/jnwhiteh/minixfs/common.Inode.Mounted方法的典型用法代碼示例。如果您正苦於以下問題:Golang Inode.Mounted方法的具體用法?Golang Inode.Mounted怎麽用?Golang Inode.Mounted使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/jnwhiteh/minixfs/common.Inode的用法示例。


在下文中一共展示了Inode.Mounted方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: loadInode

func (c *server_InodeTbl) loadInode(xp *common.Inode) {
	// The count at this point is guaranteed to be > 0, so the device cannot
	// be unmounted until the load has completed and the inode has been 'put'

	inum := xp.Inum - 1

	info := xp.Devinfo

	inodes_per_block := info.Blocksize / common.V2_INODE_SIZE
	ioffset := inum % inodes_per_block
	blocknum := info.MapOffset + (inum / inodes_per_block)

	// Load the inode from the disk and create an in-memory version of it
	bp := c.bcache.GetBlock(info.Devnum, blocknum, common.INODE_BLOCK, common.NORMAL)
	inodeb := bp.Block.(common.InodeBlock)

	// We have the full block, now get the correct inode entry
	inode_d := &inodeb[ioffset]
	xp.Disk_Inode = inode_d
	xp.Dirty = false
	xp.Mounted = nil
}
開發者ID:jnwhiteh,項目名稱:minixfs,代碼行數:22,代碼來源:inode.go

示例2: do_mount


//.........這裏部分代碼省略.........
	if found {
		return common.EBUSY // already mounted
	}

	if freeIndex == -1 {
		return common.ENFILE // no device slot available
	}

	// Invalidate the cache for this index to be sure
	fs.bcache.Invalidate(freeIndex)

	// Fill in the device info
	devinfo, err := common.GetDeviceInfo(dev)

	// If it a recognized Minix filesystem
	if err != nil {
		return err
	}

	// Create a new allocation table for this device
	alloc := alloctbl.NewAllocTbl(devinfo, fs.bcache, freeIndex)

	// Update the device number/alloc table
	devinfo.Devnum = freeIndex
	devinfo.AllocTbl = alloc

	// Add the device to the block cache/inode table
	fs.bcache.MountDevice(freeIndex, dev, devinfo)
	fs.itable.MountDevice(freeIndex, devinfo)
	fs.devices[freeIndex] = dev
	fs.devinfo[freeIndex] = devinfo

	// Get the inode of the file to be mounted on
	rip, err := fs.eatPath(fs.procs[common.ROOT_PROCESS], path)

	if err != nil {
		// Perform lots of cleanup
		fs.devices[freeIndex] = nil
		fs.devinfo[freeIndex] = nil
		fs.bcache.UnmountDevice(freeIndex)
		fs.itable.UnmountDevice(freeIndex)
		return err
	}

	var r error = nil

	// It may not be busy
	if rip.Count > 1 {
		r = common.EBUSY
	}

	// It may not be spacial
	bits := rip.Type()
	if bits == common.I_BLOCK_SPECIAL || bits == common.I_CHAR_SPECIAL {
		r = common.ENOTDIR
	}

	// Get the root inode of the mounted file system
	var root_ip *common.Inode
	if r == nil {
		root_ip, err = fs.itable.GetInode(freeIndex, common.ROOT_INODE)
		if err != nil {
			r = err
		}
	}

	if root_ip != nil && root_ip.Mode == 0 {
		r = common.EINVAL
	}

	// File types of 'rip' and 'root_ip' may not conflict
	if r == nil {
		if !rip.IsDirectory() && root_ip.IsDirectory() {
			r = common.EISDIR
		}
	}

	// If error, return the bitmap and both inodes; release the maps
	if r != nil {
		// TODO: Refactor this error handling code?
		// Perform lots of cleanup
		fs.devices[freeIndex] = nil
		fs.devinfo[freeIndex] = nil
		fs.bcache.UnmountDevice(freeIndex)
		fs.itable.UnmountDevice(freeIndex)
		return r
	}

	// Nothing else can go wrong, so perform the mount
	minfo := &common.MountInfo{
		MountPoint:  rip,
		MountTarget: root_ip,
	}
	rip.Mounted = minfo     // so we can find the root inode during lookup
	root_ip.Mounted = minfo // so we can easily resolve from a mount target to the mount point

	// Store the mountinfo in the device info table for easy mapping
	devinfo.MountInfo = minfo
	return nil
}
開發者ID:jnwhiteh,項目名稱:minixfs,代碼行數:101,代碼來源:syscalls.go


注:本文中的github.com/jnwhiteh/minixfs/common.Inode.Mounted方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。