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
Kirill Smelkov
go-fuse
Commits
e94ac04f
Commit
e94ac04f
authored
Feb 23, 2014
by
Tiziano Santoro
Committed by
Han-Wen Nienhuys
Feb 24, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add files_darwin.go
parent
60558b93
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
86 additions
and
0 deletions
+86
-0
fuse/nodefs/files_darwin.go
fuse/nodefs/files_darwin.go
+86
-0
No files found.
fuse/nodefs/files_darwin.go
0 → 100644
View file @
e94ac04f
package
nodefs
import
(
"syscall"
"time"
"unsafe"
"github.com/hanwen/go-fuse/fuse"
)
func
(
f
*
loopbackFile
)
Allocate
(
off
uint64
,
sz
uint64
,
mode
uint32
)
fuse
.
Status
{
// TODO: Handle `mode` parameter.
f
.
lock
.
Lock
()
// From `man fcntl` on OSX:
// The F_PREALLOCATE command operates on the following structure:
//
// typedef struct fstore {
// u_int32_t fst_flags; /* IN: flags word */
// int fst_posmode; /* IN: indicates offset field */
// off_t fst_offset; /* IN: start of the region */
// off_t fst_length; /* IN: size of the region */
// off_t fst_bytesalloc; /* OUT: number of bytes allocated */
// } fstore_t;
//
// The flags (fst_flags) for the F_PREALLOCATE command are as follows:
//
// F_ALLOCATECONTIG Allocate contiguous space.
//
// F_ALLOCATEALL Allocate all requested space or no space at all.
//
// The position modes (fst_posmode) for the F_PREALLOCATE command indicate how to use the offset field. The modes are as fol-
// lows:
//
// F_PEOFPOSMODE Allocate from the physical end of file.
//
// F_VOLPOSMODE Allocate from the volume offset.
k
:=
struct
{
Flags
uint32
// u_int32_t
Posmode
int64
// int
Offset
int64
// off_t
Length
int64
// off_t
Bytesalloc
int64
// off_t
}{
0
,
0
,
int64
(
off
),
int64
(
sz
),
0
,
}
// Linux version for reference:
// err := syscall.Fallocate(int(f.File.Fd()), mode, int64(off), int64(sz))
_
,
_
,
errno
:=
syscall
.
Syscall
(
syscall
.
SYS_FCNTL
,
f
.
File
.
Fd
(),
uintptr
(
syscall
.
F_PREALLOCATE
),
uintptr
(
unsafe
.
Pointer
(
&
k
)))
f
.
lock
.
Unlock
()
if
errno
!=
0
{
return
fuse
.
ToStatus
(
errno
)
}
return
fuse
.
OK
}
const
_UTIME_NOW
=
((
1
<<
30
)
-
1
)
const
_UTIME_OMIT
=
((
1
<<
30
)
-
2
)
func
(
f
*
loopbackFile
)
Utimens
(
a
*
time
.
Time
,
m
*
time
.
Time
)
fuse
.
Status
{
tv
:=
make
([]
syscall
.
Timeval
,
2
)
if
a
==
nil
{
tv
[
0
]
.
Usec
=
_UTIME_OMIT
}
else
{
n
:=
a
.
UnixNano
()
tv
[
0
]
=
syscall
.
NsecToTimeval
(
n
)
}
if
m
==
nil
{
tv
[
1
]
.
Usec
=
_UTIME_OMIT
}
else
{
n
:=
a
.
UnixNano
()
tv
[
1
]
=
syscall
.
NsecToTimeval
(
n
)
}
err
:=
syscall
.
Futimes
(
int
(
f
.
File
.
Fd
()),
tv
)
return
fuse
.
ToStatus
(
err
)
}
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