Mount options is working
This commit is contained in:
parent
5b1af8b3a2
commit
1a57dca7b0
|
@ -142,6 +142,14 @@ alive.
|
|||
|
||||
Map rbd image and mount it
|
||||
|
||||
Allowed mount options:
|
||||
* ro
|
||||
* noatime
|
||||
* relatime
|
||||
* nosuid
|
||||
* noexec
|
||||
* nodiratime
|
||||
|
||||
#### Example
|
||||
|
||||
Accept JSON
|
||||
|
|
|
@ -224,7 +224,8 @@ func (r RBDDevice) UnmapDevice() ([]byte, error) {
|
|||
|
||||
//MountFS mount file system
|
||||
func (r RBDDevice) MountFS(device string) error {
|
||||
err := syscall.Mount(device, r.Mountpoint, r.Fstype, 0, r.Mountopts)
|
||||
err := syscall.Mount(device, r.Mountpoint, r.Fstype, ParseMountOpts(r.Mountopts), "")
|
||||
log.Print("[DEBUG] RBDDevice: ", r)
|
||||
if err != nil {
|
||||
log.Print("[DEBUG] sys 207 ", err)
|
||||
return err
|
||||
|
@ -233,6 +234,28 @@ func (r RBDDevice) MountFS(device string) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
//ParseMountOpts parse RBDDevice.Mountopts. Return uintptr
|
||||
func ParseMountOpts(mountopts string) uintptr {
|
||||
// Mount options map
|
||||
opts := make(map[string]uintptr)
|
||||
opts["ro"] = syscall.MS_RDONLY
|
||||
opts["noatime"] = syscall.MS_NOATIME
|
||||
opts["relatime"] = syscall.MS_RELATIME
|
||||
opts["nosuid"] = syscall.MS_NOSUID
|
||||
opts["noexec"] = syscall.MS_NOEXEC
|
||||
opts["nodiratime"] = syscall.MS_NODIRATIME
|
||||
|
||||
var msOpts uintptr
|
||||
if mountopts != "" {
|
||||
for _, o := range strings.Split(mountopts, ",") {
|
||||
msOpts = uintptr(msOpts|opts[o])
|
||||
}
|
||||
return msOpts
|
||||
}
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
//UnmountFS unmount file system
|
||||
func (r RBDDevice) UnmountFS() error {
|
||||
err := syscall.Unmount(r.Mountpoint, 0)
|
||||
|
|
|
@ -8,6 +8,6 @@ import (
|
|||
|
||||
//VersionShow show version and exit
|
||||
func VersionShow() {
|
||||
fmt.Println("RBMD 0.0.3", runtime.Version(), runtime.GOARCH)
|
||||
fmt.Println("RBMD 0.0.4", runtime.Version(), runtime.GOARCH)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user