From 74a87e72d158f8927dfc768a0b3c7e23534d3bee Mon Sep 17 00:00:00 2001 From: Dominic Della Valle Date: Fri, 25 Nov 2022 03:54:40 -0500 Subject: [PATCH] filesystem: all - use new permission const names --- internal/filesystem/ipfscore.go | 16 +++++++++------- internal/filesystem/ipfskeys.go | 3 ++- internal/filesystem/ipfsmfs.go | 8 +++++--- internal/filesystem/ipfspins.go | 6 ++++-- 4 files changed, 20 insertions(+), 13 deletions(-) diff --git a/internal/filesystem/ipfscore.go b/internal/filesystem/ipfscore.go index 0d3d281b..2a0d4f92 100644 --- a/internal/filesystem/ipfscore.go +++ b/internal/filesystem/ipfscore.go @@ -55,8 +55,9 @@ type ( const ipfsCoreTimeout = 10 * time.Second func NewIPFS(core coreiface.CoreAPI, systemID ID) *ipfsCoreAPI { + const permissions = readAll | executeAll return &ipfsCoreAPI{ - root: newRoot(s_IRXA, nil), + root: newRoot(permissions, nil), core: core, systemID: systemID, } @@ -100,7 +101,7 @@ func (ci *ipfsCoreAPI) openNode(name string, ) (fs.File, error) { const ( op fserrors.Op = "ipfscore.openNode" - defaultPermissions = s_IRXA + defaultPermissions = readAll | executeAll ) // stat, err := ci.stat(name, ipldNode) defaultMtime := ci.root.stat.ModTime() @@ -232,7 +233,7 @@ func translateCoreEntry(entry *coreiface.DirEntry) fs.DirEntry { name: entry.Name, size: int64(entry.Size), mode: coreTypeToGoType(entry.Type) | - s_IRXA, // TODO: from root. + readAll | executeAll, // TODO: from root. modTime: time.Now(), // TODO: from root. } } @@ -410,12 +411,13 @@ func openUFSNode(name string, core coreiface.CoreAPI, ipldNode ipld.Node, ), ) } + // TODO: store/get permissions from root. + const permissions = readAll | executeAll return &coreFile{ stat: staticStat{ - name: name, - size: int64(ufsNode.FileSize()), - mode: unixfsTypeToGoType(ufsNode.Type()) | - s_IRXA, // TODO: from root + name: name, + size: int64(ufsNode.FileSize()), + mode: unixfsTypeToGoType(ufsNode.Type()) | permissions, modTime: time.Now(), // TODO: from root }, File: fileNode, diff --git a/internal/filesystem/ipfskeys.go b/internal/filesystem/ipfskeys.go index cb6be6a0..7d378425 100644 --- a/internal/filesystem/ipfskeys.go +++ b/internal/filesystem/ipfskeys.go @@ -103,11 +103,12 @@ func (kfs *IPFSKeyAPI) openRoot() (fs.ReadDirFile, error) { return keys, err } ) + const permissions = readAll | executeAll return &keyDirectory{ ipns: kfs.ipns, stat: staticStat{ name: rootName, - mode: fs.ModeDir | s_IRXA, + mode: fs.ModeDir | permissions, modTime: time.Now(), // Not really modified, but key-set as-of right now. }, cancel: cancel, diff --git a/internal/filesystem/ipfsmfs.go b/internal/filesystem/ipfsmfs.go index 46ec2e51..1b949850 100644 --- a/internal/filesystem/ipfsmfs.go +++ b/internal/filesystem/ipfsmfs.go @@ -167,13 +167,14 @@ func (mi *IPFSMFS) openFileNode(name string, mfsNode mfs.FSNode, flag int) (fs.F if err != nil { return nil, fserrors.New(fserrors.Permission) } + const permissions = readAll | writeAll | executeAll // TODO: set/get perms from elsewhere. return &mfsFile{ descriptor: descriptor, stat: &mfsStat{ // TODO: retrieve metadata from node if present; timestamps from constructor otherwise. sizeFn: mfsFileIntf.Size, staticStat: staticStat{ name: path.Base(name), - mode: s_IRXA, // TODO: perms + mode: permissions, modTime: time.Now(), }, }, @@ -223,13 +224,14 @@ func (mi *IPFSMFS) openDirNode(name string, mfsNode mfs.FSNode) (fs.ReadDirFile, return nil, fserrors.New(fserrors.NotDir) // TODO: convert old-style errors. } ctx, cancel := context.WithCancel(context.Background()) + const permissions = readAll | writeAll | executeAll // TODO: set/get perms from elsewhere. return &mfsDirectory{ ctx: ctx, cancel: cancel, listing: _hackListAsync(ctx, mfsDir), mfsDir: mfsDir, stat: &staticStat{ // TODO: retrieve metadata from node if present; timestamps from constructor otherwise. name: path.Base(name), - mode: fs.ModeDir | s_IRXA, // TODO: perms + mode: fs.ModeDir | permissions, modTime: time.Now(), }, }, nil @@ -320,7 +322,7 @@ func translateUFSLinkEntry(parent *mfs.Directory, link *ipld.Link) (fs.DirEntry, typ = fs.ModeSymlink } */ - const permissions = s_IRXA // TODO: perms from caller or node if present. + const permissions = readAll | writeAll | executeAll // TODO: perms from caller or node if present. var ( mode fs.FileMode size int64 diff --git a/internal/filesystem/ipfspins.go b/internal/filesystem/ipfspins.go index 9a73270a..d93c5d19 100644 --- a/internal/filesystem/ipfspins.go +++ b/internal/filesystem/ipfspins.go @@ -84,7 +84,7 @@ func (pfs *IPFSPinAPI) openRoot() (fs.ReadDirFile, error) { } } // TODO: retrieve permission from somewhere else. (Passed into FS constructor) - const permissions = s_IRXA + const permissions = readAll | executeAll stream := &pinStream{ ipfs: pfs.ipfs, pins: pins, @@ -222,9 +222,11 @@ func (pe *pinDirEntry) Info() (fs.FileInfo, error) { if ipfs := pe.ipfs; ipfs != nil { return fs.Stat(pe.ipfs, pinCid.String()) } + // TODO: permission come from somewhere else. + const permissions = readAll | executeAll return staticStat{ name: pinCid.String(), - mode: fs.ModeDir | s_IRWXA, // TODO: permission come from somewhere else. + mode: fs.ModeDir | permissions, modTime: time.Now(), }, nil }