当前位置: 首页>>代码示例>>Golang>>正文


Golang Inode.IsDirectory方法代码示例

本文整理汇总了Golang中github.com/jnwhiteh/minixfs/common.Inode.IsDirectory方法的典型用法代码示例。如果您正苦于以下问题:Golang Inode.IsDirectory方法的具体用法?Golang Inode.IsDirectory怎么用?Golang Inode.IsDirectory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/jnwhiteh/minixfs/common.Inode的用法示例。


在下文中一共展示了Inode.IsDirectory方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: Unlink

func Unlink(rip *common.Inode, name string) error {
	if !rip.IsDirectory() {
		return common.ENOTDIR
	}

	dirp := rip

	inum := 0
	err := search_dir(dirp, name, &inum, DELETE)
	return err
}
开发者ID:jnwhiteh,项目名称:minixfs,代码行数:11,代码来源:dirops.go

示例2: Link

func Link(rip *common.Inode, name string, inum int) error {
	if !rip.IsDirectory() {
		return common.ENOTDIR
	}

	dirp := rip

	// Add the entry to the directory
	err := search_dir(dirp, name, &inum, ENTER)
	return err
}
开发者ID:jnwhiteh,项目名称:minixfs,代码行数:11,代码来源:dirops.go

示例3: IsEmpty

func IsEmpty(rip *common.Inode) bool {
	if !rip.IsDirectory() {
		return false
	}

	dirp := rip

	zeroinode := 0
	if err := search_dir(dirp, "", &zeroinode, IS_EMPTY); err != nil {
		return false
	}
	return true
}
开发者ID:jnwhiteh,项目名称:minixfs,代码行数:13,代码来源:dirops.go

示例4: Lookup

func Lookup(rip *common.Inode, name string) (bool, int, int) {
	if !rip.IsDirectory() {
		return false, common.NO_DEV, common.NO_INODE
	}

	dirp := rip

	inum := 0
	err := search_dir(dirp, name, &inum, LOOKUP)
	if err != nil {
		return false, common.NO_DEV, common.NO_INODE
	}

	return true, dirp.Devinfo.Devnum, inum
}
开发者ID:jnwhiteh,项目名称:minixfs,代码行数:15,代码来源:dirops.go

示例5: do_mount

func (fs *FileSystem) do_mount(proc *Process, dev common.BlockDevice, path string) error {
	if dev == nil {
		return common.EINVAL
	}

	// scan bitmap block table to see if 'dev' is already mounted
	found := false
	freeIndex := -1
	for i := 0; i < common.NR_DEVICES; i++ {
		if fs.devices[i] == dev {
			found = true
		} else if fs.devices[i] == nil {
			freeIndex = i
		}
	}

	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)
//.........这里部分代码省略.........
开发者ID:jnwhiteh,项目名称:minixfs,代码行数:101,代码来源:syscalls.go


注:本文中的github.com/jnwhiteh/minixfs/common.Inode.IsDirectory方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。