當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。