Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go-fuse
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Levin Zimmermann
go-fuse
Commits
1cc8b3a4
Commit
1cc8b3a4
authored
Sep 14, 2011
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a ReadOnlyFile wrapper type, and use it in UnionFs when applicable.
parent
11e662a2
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
2 deletions
+32
-2
fuse/files.go
fuse/files.go
+27
-0
fuse/readonlyfs.go
fuse/readonlyfs.go
+2
-2
unionfs/unionfs.go
unionfs/unionfs.go
+3
-0
No files found.
fuse/files.go
View file @
1cc8b3a4
...
...
@@ -116,3 +116,30 @@ func (me *LoopbackFile) GetAttr() (*os.FileInfo, Status) {
}
return
fi
,
OK
}
////////////////////////////////////////////////////////////////
// ReadOnlyFile is a wrapper that denies writable operations
type
ReadOnlyFile
struct
{
File
}
func
(
me
*
ReadOnlyFile
)
Write
(
input
*
WriteIn
,
data
[]
byte
)
(
uint32
,
Status
)
{
return
0
,
EPERM
}
func
(
me
*
ReadOnlyFile
)
Fsync
(
*
FsyncIn
)
(
code
Status
)
{
return
OK
}
func
(
me
*
ReadOnlyFile
)
Truncate
(
size
uint64
)
Status
{
return
EPERM
}
func
(
me
*
ReadOnlyFile
)
Chmod
(
mode
uint32
)
Status
{
return
EPERM
}
func
(
me
*
ReadOnlyFile
)
Chown
(
uid
uint32
,
gid
uint32
)
Status
{
return
EPERM
}
fuse/readonlyfs.go
View file @
1cc8b3a4
...
...
@@ -61,8 +61,8 @@ func (me *ReadonlyFileSystem) Open(name string, flags uint32, context *Context)
if
flags
&
O_ANYWRITE
!=
0
{
return
nil
,
EPERM
}
// TODO - wrap the File object inside a R/O wrapper too?
return
me
.
FileSystem
.
Open
(
name
,
flags
,
context
)
file
,
code
=
me
.
FileSystem
.
Open
(
name
,
flags
,
context
)
return
&
ReadOnlyFile
{
file
},
code
}
func
(
me
*
ReadonlyFileSystem
)
OpenDir
(
name
string
,
context
*
Context
)
(
stream
chan
DirEntry
,
status
Status
)
{
...
...
unionfs/unionfs.go
View file @
1cc8b3a4
...
...
@@ -917,6 +917,9 @@ func (me *UnionFs) Open(name string, flags uint32, context *fuse.Context) (fuseF
if
fuseFile
!=
nil
{
fuseFile
=
&
UnionFsFile
{
fuseFile
,
r
.
branch
}
}
if
r
.
branch
>
0
&&
fuseFile
!=
nil
{
fuseFile
=
&
fuse
.
ReadOnlyFile
{
fuseFile
}
}
return
fuseFile
,
status
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment