Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 5 additions & 22 deletions continuityfs/fuse.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"io"
"os"
"path/filepath"
"strconv"
"syscall"

"bazil.org/fuse"
Expand Down Expand Up @@ -35,24 +34,14 @@ func NewFile(inode uint64, provider FileContentProvider) *File {
}

func (f *File) setResource(r continuity.Resource) (err error) {
f.uid, err = parseUint32(r.UID())
if err != nil {
return
}
f.gid, err = parseUint32(r.GID())
if err != nil {
return
}
// TODO: error out if uid excesses uint32?
f.uid = uint32(r.UID())
f.gid = uint32(r.GID())
f.resource = r

return
}

func parseUint32(s string) (uint32, error) {
i, err := strconv.ParseUint(s, 10, 32)
return uint32(i), err
}

// Attr sets the fuse attribute for the file
func (f *File) Attr(ctx context.Context, attr *fuse.Attr) (err error) {
// Set attributes from resource metadata
Expand Down Expand Up @@ -215,14 +204,8 @@ func (d *Dir) ReadDirAll(ctx context.Context) ([]fuse.Dirent, error) {
}

func (d *Dir) setResource(r continuity.Resource) (err error) {
d.uid, err = parseUint32(r.UID())
if err != nil {
return
}
d.gid, err = parseUint32(r.GID())
if err != nil {
return
}
d.uid = uint32(r.UID())
d.gid = uint32(r.GID())
d.resource = r

return
Expand Down
16 changes: 4 additions & 12 deletions driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package continuity

import (
"os"
"strconv"
)

// Driver provides all of the system-level functions in a common interface.
Expand All @@ -25,7 +24,7 @@ type Driver interface {

Link(oldname, newname string) error
Lchmod(path string, mode os.FileMode) error
Lchown(path, uid, gid string) error
Lchown(path string, uid, gid int64) error
Symlink(oldname, newname string) error

// TODO(aaronl): These methods might move outside the main Driver
Expand Down Expand Up @@ -127,16 +126,9 @@ func (d *driver) Link(oldname, newname string) error {
return os.Link(oldname, newname)
}

func (d *driver) Lchown(name, uidStr, gidStr string) error {
uid, err := strconv.Atoi(uidStr)
if err != nil {
return err
}
gid, err := strconv.Atoi(gidStr)
if err != nil {
return err
}
return os.Lchown(name, uid, gid)
func (d *driver) Lchown(name string, uid, gid int64) error {
// TODO: error out if uid excesses int bit width?
return os.Lchown(name, int(uid), int(gid))
}

func (d *driver) Symlink(oldname, newname string) error {
Expand Down
31 changes: 14 additions & 17 deletions manifest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"os"
"path/filepath"
"sort"
"strconv"
"syscall"
"testing"

Expand Down Expand Up @@ -216,8 +215,8 @@ type dresource struct {
target string // hard/soft link target
digest digest.Digest
size int
uid int
gid int
uid int64
gid int64
major, minor int
}

Expand Down Expand Up @@ -269,8 +268,8 @@ func generateTestFiles(t *testing.T, root string, resources []dresource) {
if err != nil {
t.Fatalf("error statting after creation: %v", err)
}
resources[i].uid = int(st.Sys().(*syscall.Stat_t).Uid)
resources[i].gid = int(st.Sys().(*syscall.Stat_t).Gid)
resources[i].uid = int64(st.Sys().(*syscall.Stat_t).Uid)
resources[i].gid = int64(st.Sys().(*syscall.Stat_t).Gid)
resources[i].mode = st.Mode()

// TODO: Readback and join xattr
Expand Down Expand Up @@ -316,16 +315,14 @@ func expectedResourceList(root string, resources []dresource) ([]Resource, error
if !filepath.IsAbs(absPath) {
absPath = "/" + absPath
}
uidStr := strconv.Itoa(r.uid)
gidStr := strconv.Itoa(r.gid)
switch r.kind {
case rfile:
f := &regularFile{
resource: resource{
paths: []string{absPath},
mode: r.mode,
uid: uidStr,
gid: gidStr,
uid: r.uid,
gid: r.gid,
},
size: int64(r.size),
digests: []digest.Digest{r.digest},
Expand All @@ -337,8 +334,8 @@ func expectedResourceList(root string, resources []dresource) ([]Resource, error
resource: resource{
paths: []string{absPath},
mode: r.mode,
uid: uidStr,
gid: gidStr,
uid: r.uid,
gid: r.gid,
},
}
resourceMap[absPath] = d
Expand Down Expand Up @@ -371,8 +368,8 @@ func expectedResourceList(root string, resources []dresource) ([]Resource, error
resource: resource{
paths: []string{absPath},
mode: r.mode,
uid: uidStr,
gid: gidStr,
uid: r.uid,
gid: r.gid,
},
target: targetPath,
}
Expand All @@ -383,8 +380,8 @@ func expectedResourceList(root string, resources []dresource) ([]Resource, error
resource: resource{
paths: []string{absPath},
mode: r.mode,
uid: uidStr,
gid: gidStr,
uid: r.uid,
gid: r.gid,
},
major: uint64(r.major),
minor: uint64(r.minor),
Expand All @@ -396,8 +393,8 @@ func expectedResourceList(root string, resources []dresource) ([]Resource, error
resource: resource{
paths: []string{absPath},
mode: r.mode,
uid: uidStr,
gid: gidStr,
uid: r.uid,
gid: r.gid,
},
}
resourceMap[absPath] = p
Expand Down
52 changes: 25 additions & 27 deletions proto/manifest.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 4 additions & 6 deletions proto/manifest.proto
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,11 @@ message Resource {

// NOTE(stevvooe): Need to define clear precedence for user/group/uid/gid precedence.

// Uid specifies the user id for the resource. A string type is used for
// compatibility across different OS.
string uid = 2;
// Uid specifies the user id for the resource.
int64 uid = 2;

// Gid specifies the group id for the resource. A string type is used for
// compatibility across different OS.
string gid = 3;
// Gid specifies the group id for the resource.
int64 gid = 3;

// user and group are not currently used but their field numbers have been
// reserved for future use. As such, they are marked as deprecated.
Expand Down
10 changes: 5 additions & 5 deletions resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ type Resource interface {
// Mode returns the
Mode() os.FileMode

UID() string
GID() string
UID() int64
GID() int64
}

// ByPath provides the canonical sort order for a set of resources. Use with
Expand Down Expand Up @@ -240,7 +240,7 @@ type Device interface {
type resource struct {
paths []string
mode os.FileMode
uid, gid string
uid, gid int64
xattrs map[string][]byte
}

Expand All @@ -258,11 +258,11 @@ func (r *resource) Mode() os.FileMode {
return r.mode
}

func (r *resource) UID() string {
func (r *resource) UID() int64 {
return r.uid
}

func (r *resource) GID() string {
func (r *resource) GID() int64 {
return r.gid
}

Expand Down
4 changes: 2 additions & 2 deletions resource_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ func newBaseResource(p string, fi os.FileInfo) (*resource, error) {
paths: []string{p},
mode: fi.Mode(),

uid: fmt.Sprint(sys.Uid),
gid: fmt.Sprint(sys.Gid),
uid: int64(sys.Uid),
gid: int64(sys.Gid),

// NOTE(stevvooe): Population of shared xattrs field is deferred to
// the resource types that populate it. Since they are a property of
Expand Down