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


Golang syscall.Stat_t类代码示例

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


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

示例1: watchDaemon

func watchDaemon(mdbFileName string, mdbChannel chan<- *mdb.Mdb,
	logger *log.Logger) {
	var lastStat syscall.Stat_t
	var lastMdb *mdb.Mdb
	for ; ; time.Sleep(time.Second) {
		var stat syscall.Stat_t
		if err := syscall.Stat(mdbFileName, &stat); err != nil {
			logger.Printf("Error stating file: %s\t%s\n", mdbFileName, err)
			continue
		}
		stat.Atim = lastStat.Atim
		if stat != lastStat {
			mdb := loadFile(mdbFileName, logger)
			if mdb == nil {
				continue
			}
			compareStartTime := time.Now()
			if lastMdb == nil || !compare(lastMdb, mdb) {
				if lastMdb != nil {
					mdbCompareTimeDistribution.Add(time.Since(compareStartTime))
				}
				mdbChannel <- mdb
				lastMdb = mdb
			}
			lastStat = stat
		}
	}
}
开发者ID:datatonic,项目名称:Dominator,代码行数:28,代码来源:watchd.go

示例2: GetAttr

// GetAttr - FUSE call
func (f *virtualFile) GetAttr(a *fuse.Attr) fuse.Status {
	var st syscall.Stat_t
	err := syscall.Lstat(f.parentFile, &st)
	if err != nil {
		fmt.Printf("Lstat %q: %v\n", f.parentFile, err)
		return fuse.ToStatus(err)
	}
	st.Ino = f.ino
	st.Size = int64(len(f.content))
	st.Mode = syscall.S_IFREG | 0400
	st.Nlink = 1
	a.FromStat(&st)
	return fuse.OK
}
开发者ID:rfjakob,项目名称:gocryptfs,代码行数:15,代码来源:virtualfile.go

示例3: TestMemUnionResetDelete

func TestMemUnionResetDelete(t *testing.T) {
	wd, ufs, clean := setupMemUfs(t)
	defer clean()
	ioutil.WriteFile(wd+"/ro/todelete", []byte{42}, 0644)

	var before, after, afterReset syscall.Stat_t
	syscall.Lstat(wd+"/mnt/todelete", &before)
	before.Ino = 0
	os.Remove(wd + "/mnt/todelete")
	syscall.Lstat(wd+"/mnt/todelete", &after)
	testEq(t, after, before, false)
	ufs.Reset()
	syscall.Lstat(wd+"/mnt/todelete", &afterReset)
	afterReset.Ino = 0
	testEq(t, afterReset, before, true)
}
开发者ID:janneke,项目名称:termite,代码行数:16,代码来源:memunionfs_test.go

示例4: Lstat

func (constor *Constor) Lstat(li int, id string, stat *syscall.Stat_t) error {
	path := constor.getPath(li, id)
	if err := syscall.Lstat(path, stat); err != nil {
		return err
	}
	count := 1
	linksbyte, err := Lgetxattr(path, LINKSXATTR)
	if err == nil && len(linksbyte) != 0 {
		linksstr := string(linksbyte)
		linksint, err := strconv.Atoi(linksstr)
		if err != nil {
			constor.error("%s : %s", id, err)
			return err
		}
		count = linksint
	}
	stat.Nlink = uint64(count)
	stat.Ino = idtoino(id)
	return nil
}
开发者ID:krishnasrinivas,项目名称:confs,代码行数:20,代码来源:helpers.go

示例5: GetAttr

func (constor *Constor) GetAttr(input *fuse.GetAttrIn, out *fuse.AttrOut) (code fuse.Status) {
	stat := syscall.Stat_t{}
	inode := constor.inodemap.findInodePtr(input.NodeId)
	if inode == nil {
		constor.error("%d not in inodemap", input.NodeId)
		return fuse.ENOENT
	}
	if inode.id == ROOTID && inode.layer == -1 {
		inode.layer = constor.getLayer(inode.id)
		if inode.layer == -1 {
			constor.error("Unable to find root inode")
			return fuse.ENOENT
		}
	}
	F := constor.fdlookup(inode.id, input.Pid)
	var err error
	// FIXME check to see if F.layer needs to be changed
	if F == nil {
		if inode.layer == -1 {
			constor.error("layer is -1 for %s", inode.id)
			return fuse.ENOENT
		}
		constor.log("Lstat on %s", inode.id)
		err = constor.Lstat(inode.layer, inode.id, &stat)
	} else {
		constor.log("Fstat on %s", inode.id)
		err = syscall.Fstat(F.fd, &stat)
		stat.Ino = idtoino(F.id)
		// FIXME take care of hard links too
	}
	if err != nil {
		constor.error("%s: %s", inode.id, err)
		return fuse.ToStatus(err)
	}
	attr := (*fuse.Attr)(&out.Attr)
	attr.FromStat(&stat)
	out.AttrValid = 1000
	constor.log("%s", inode.id)
	return fuse.OK
}
开发者ID:krishnasrinivas,项目名称:confs,代码行数:40,代码来源:main.go

示例6: watchDaemon

func watchDaemon(mdbFileName string, mdbChannel chan *Mdb, logger *log.Logger) {
	var lastStat syscall.Stat_t
	var lastMdb *Mdb
	for ; ; time.Sleep(time.Second) {
		var stat syscall.Stat_t
		if err := syscall.Stat(mdbFileName, &stat); err != nil {
			logger.Printf("Error stating file: %s\t%s\n", mdbFileName, err)
			continue
		}
		stat.Atim = lastStat.Atim
		if stat != lastStat {
			file, err := os.Open(mdbFileName)
			if err != nil {
				logger.Printf("Error opening file\t%s\n", err)
				continue
			}
			decoder := json.NewDecoder(file)
			var mdb Mdb
			decodeStartTime := time.Now()
			if err = decoder.Decode(&mdb.Machines); err != nil {
				logger.Printf("Error decoding\t%s\n", err)
				continue
			}
			sortStartTime := time.Now()
			mdbDecodeTimeDistribution.Add(sortStartTime.Sub(decodeStartTime))
			sort.Sort(&mdb)
			compareStartTime := time.Now()
			mdbSortTimeDistribution.Add(compareStartTime.Sub(sortStartTime))
			if lastMdb == nil || !compare(lastMdb, &mdb) {
				if lastMdb != nil {
					mdbCompareTimeDistribution.Add(time.Since(compareStartTime))
				}
				mdbChannel <- &mdb
				lastMdb = &mdb
			}
			lastStat = stat
		}
	}
}
开发者ID:JohnTheodore,项目名称:Dominator,代码行数:39,代码来源:watchd.go

示例7: LstatInode

func (constor *Constor) LstatInode(path string, stat *syscall.Stat_t, inode *Inode) error {
	li := inode.layer
	if li == -1 {
		li = constor.getLayer(path)
		if li == -1 {
			return syscall.ENOENT
		}
		inode.layer = li
	}
	pathl := Path.Join(constor.layers[li], path)
	err := syscall.Lstat(pathl, stat)
	if err != nil {
		return err
	}
	if li != 0 {
		// INOXATTR valid only for layer-0
		return nil
	}
	// var inobyte []byte
	// inobyte = make([]byte, 100, 100)
	// size, err := syscall.Getxattr(pathl, INOXATTR, inobyte)
	inobyte, err := Lgetxattr(pathl, INOXATTR)
	if err != nil {
		return nil
	}
	if len(inobyte) == 0 {
		return nil
	}
	inostr := string(inobyte)
	ino, err := strconv.Atoi(inostr)
	if err != nil {
		return err
	}
	stat.Ino = uint64(ino)
	if inode.ino == 1 {
		stat.Ino = 1
	}
	return nil
}
开发者ID:krishnasrinivas,项目名称:constor,代码行数:39,代码来源:helpers.go

示例8: Sys

func (self *fileInfo) Sys() interface{} {
	var statbuf syscall.Stat_t = *self.FileInfo.Sys().(*syscall.Stat_t)
	statbuf.Dev = self.dev
	statbuf.Rdev = self.rdev
	return &statbuf
}
开发者ID:maciejmrowiec,项目名称:mender,代码行数:6,代码来源:rootfs_test.go


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