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


Golang syscall.Fchmod函数代码示例

本文整理汇总了Golang中syscall.Fchmod函数的典型用法代码示例。如果您正苦于以下问题:Golang Fchmod函数的具体用法?Golang Fchmod怎么用?Golang Fchmod使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: Chmod

// Chmod changes the mode of the file to mode.
// If there is an error, it will be of type *PathError.
func (f *File) Chmod(mode FileMode) error {
	if err := f.checkValid("chmod"); err != nil {
		return err
	}
	if e := syscall.Fchmod(f.fd, syscallMode(mode)); e != nil {
		return &PathError{"chmod", f.name, e}
	}
	return nil
}
开发者ID:achanda,项目名称:go,代码行数:11,代码来源:file_posix.go

示例2: Chmod

// Chmod changes the mode of the file to mode.
// If there is an error, it will be of type *PathError.
func (f *File) Chmod(mode FileMode) error {
	if f == nil {
		return ErrInvalid
	}
	if e := syscall.Fchmod(f.fd, syscallMode(mode)); e != nil {
		return &PathError{"chmod", f.name, e}
	}
	return nil
}
开发者ID:ds2dev,项目名称:gcc,代码行数:11,代码来源:file_posix.go

示例3: Chmod

func (f *file) Chmod(mode uint32) fuse.Status {
	f.fdLock.RLock()
	defer f.fdLock.RUnlock()

	// os.File.Chmod goes through the "syscallMode" translation function that messes
	// up the suid and sgid bits. So use syscall.Fchmod directly.
	err := syscall.Fchmod(f.intFd(), mode)
	return fuse.ToStatus(err)
}
开发者ID:rfjakob,项目名称:gocryptfs,代码行数:9,代码来源:file.go

示例4: Chmod

// Chmod changes the mode of the file to mode.
func (f *File) Chmod(mode int) Error {
	if e := syscall.Fchmod(f.fd, mode); e != 0 {
		return &PathError{"chmod", f.name, Errno(e)}
	}
	return nil
}
开发者ID:lougxing,项目名称:golang-china,代码行数:7,代码来源:file.go

示例5: Chmod

// Chmod changes the mode of the file to mode.
func (f *File) Chmod(mode uint32) error {
	if e := syscall.Fchmod(f.fd, mode); iserror(e) {
		return &PathError{"chmod", f.name, Errno(e)}
	}
	return nil
}
开发者ID:aubonbeurre,项目名称:gcc,代码行数:7,代码来源:file_posix.go

示例6: Fchmod

func (k *PosixKernel) Fchmod(fd int, mode uint32) uint64 {
	return Errno(syscall.Fchmod(fd, mode))
}
开发者ID:lunixbochs,项目名称:usercorn,代码行数:3,代码来源:io.go

示例7: SetAttr

func (constor *Constor) SetAttr(input *fuse.SetAttrIn, out *fuse.AttrOut) fuse.Status {
	var err error
	uid := -1
	gid := -1

	inode := constor.inodemap.findInodePtr(input.NodeId)
	if inode == nil {
		constor.error("inode nil")
		return fuse.EIO
	}
	constor.log("%s %d", inode.id, input.Valid)
	// if ((input.Valid & fuse.FATTR_FH) !=0) && ((input.Valid & (fuse.FATTR_ATIME | fuse.FATTR_MTIME)) == 0) {
	if ((input.Valid & fuse.FATTR_FH) != 0) && ((input.Valid & fuse.FATTR_SIZE) != 0) {
		ptr := uintptr(input.Fh)
		F := constor.getfd(ptr)
		if F == nil {
			constor.error("F == nil for %s", inode.id)
			return fuse.EIO
		}
		if F.layer != 0 && inode.layer == -1 {
			/* FIXME handle this valid case */
			// file is in lower layer, opened, deleted, setattr-called
			constor.error("FSetAttr F.layer=%d inode.layer=%d", F.layer, inode.layer)
			return fuse.EIO
		}

		if F.layer != 0 && inode.layer != 0 {
			err := constor.copyup(inode)
			if err != nil {
				constor.error("copyup failed for %s - %s", inode.id, err)
				return fuse.ToStatus(err)
			}
			path := constor.getPath(0, inode.id)
			syscall.Close(F.fd)
			fd, err := syscall.Open(path, F.flags, 0)
			if err != nil {
				constor.error("open failed on %s - %s", path, err)
				return fuse.ToStatus(err)
			}
			F.fd = fd
			F.layer = 0
			constor.log("reset fd for %s", path)
		} else if F.layer != 0 && inode.layer == 0 {
			// when some other process already has done a copyup
			syscall.Close(F.fd)
			path := constor.getPath(0, inode.id)
			fd, err := syscall.Open(path, F.flags, 0)
			if err != nil {
				constor.error("open failed on %s - %s", path, err)
				return fuse.ToStatus(err)
			}
			F.fd = fd
			F.layer = 0
			constor.log("reset fd for %s", path)
		}

		if F.layer != 0 {
			constor.error("layer not 0")
			return fuse.EIO
		}

		if input.Valid&fuse.FATTR_MODE != 0 {
			permissions := uint32(07777) & input.Mode
			err = syscall.Fchmod(F.fd, permissions)
			if err != nil {
				constor.error("Fchmod failed on %s - %d : %s", F.id, permissions, err)
				return fuse.ToStatus(err)
			}
		}
		if input.Valid&(fuse.FATTR_UID) != 0 {
			uid = int(input.Uid)
		}
		if input.Valid&(fuse.FATTR_GID) != 0 {
			gid = int(input.Gid)
		}

		if input.Valid&(fuse.FATTR_UID|fuse.FATTR_GID) != 0 {
			err = syscall.Fchown(F.fd, uid, gid)
			if err != nil {
				constor.error("Fchown failed on %s - %d %d : %s", F.id, uid, gid, err)
				return fuse.ToStatus(err)
			}
		}
		if input.Valid&fuse.FATTR_SIZE != 0 {
			err := syscall.Ftruncate(F.fd, int64(input.Size))
			if err != nil {
				constor.error("Ftruncate failed on %s - %d : %s", F.id, input.Size, err)
				return fuse.ToStatus(err)
			}
		}
		if input.Valid&(fuse.FATTR_ATIME|fuse.FATTR_MTIME|fuse.FATTR_ATIME_NOW|fuse.FATTR_MTIME_NOW) != 0 {
			now := time.Now()
			var tv []syscall.Timeval

			tv = make([]syscall.Timeval, 2)

			if input.Valid&fuse.FATTR_ATIME_NOW != 0 {
				tv[0].Sec = now.Unix()
				tv[0].Usec = now.UnixNano() / 1000
			} else {
//.........这里部分代码省略.........
开发者ID:krishnasrinivas,项目名称:confs,代码行数:101,代码来源:main.go


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