Example #1
0
File: ufs.go Project: rjkroege/go9p
func (dir *Dir) dotu(path string, d os.FileInfo, upool p.Users, sysMode *syscall.Stat_t) {
	u := upool.Uid2User(int(sysMode.Uid))
	g := upool.Gid2Group(int(sysMode.Gid))
	dir.Uid = u.Name()
	if dir.Uid == "" {
		dir.Uid = "none"
	}

	dir.Gid = g.Name()
	if dir.Gid == "" {
		dir.Gid = "none"
	}
	dir.Muid = "none"
	dir.Ext = ""
	dir.Uidnum = uint32(u.Id())
	dir.Gidnum = uint32(g.Id())
	dir.Muidnum = p.NOUID
	if d.Mode()&os.ModeSymlink != 0 {
		var err error
		dir.Ext, err = os.Readlink(path)
		if err != nil {
			dir.Ext = ""
		}
	} else if isBlock(d) {
		dir.Ext = fmt.Sprintf("b %d %d", sysMode.Rdev>>24, sysMode.Rdev&0xFFFFFF)
	} else if isChar(d) {
		dir.Ext = fmt.Sprintf("c %d %d", sysMode.Rdev>>24, sysMode.Rdev&0xFFFFFF)
	}
}
Example #2
0
File: vufs.go Project: postfix/vufs
// Convert a string user id to a string and look up user Name.
func atouid(id string, upool p.Users) (string, error) {

	uid, err := strconv.Atoi(id)

	if err != nil {
		return "", fmt.Errorf("invalid uid %s", id)
	}

	u := upool.Uid2User(uid)

	if u == nil {
		return "", fmt.Errorf("No user found for uid %d", uid)
	}

	return u.Name(), nil

}