Browse Source
Revert "add "freeze" subcommand to volume"
Revert "add "freeze" subcommand to volume"
This reverts commit f262fed197
.
pull/2/head
Chris Lu
12 years ago
7 changed files with 16 additions and 144 deletions
-
27weed-fs/src/cmd/weed/fix.go
-
1weed-fs/src/cmd/weed/weed.go
-
7weed-fs/src/pkg/storage/cdb_map.go
-
35weed-fs/src/pkg/storage/needle_map.go
-
9weed-fs/src/pkg/storage/store.go
-
6weed-fs/src/pkg/storage/volume.go
-
63weed-fs/src/pkg/util/file.go
@ -1,63 +0,0 @@ |
|||||
package util |
|
||||
|
|
||||
import ( |
|
||||
"errors" |
|
||||
"log" |
|
||||
"os" |
|
||||
) |
|
||||
|
|
||||
// sets file (fh if not nil, otherwise fileName) permission to mask
|
|
||||
// it will
|
|
||||
// AND with the permission iff direction < 0
|
|
||||
// OR with the permission iff direction > 0
|
|
||||
// otherwise it will SET the permission to the mask
|
|
||||
func SetFilePerm(fh *os.File, fileName string, mask os.FileMode, direction int8) (err error) { |
|
||||
var stat os.FileInfo |
|
||||
if fh == nil { |
|
||||
stat, err = os.Stat(fileName) |
|
||||
} else { |
|
||||
stat, err = fh.Stat() |
|
||||
} |
|
||||
if err != nil { |
|
||||
return err |
|
||||
} |
|
||||
|
|
||||
mode := stat.Mode() & ^os.ModePerm |
|
||||
// log.Printf("mode1=%d mask=%d", mode, mask)
|
|
||||
if direction == 0 { |
|
||||
mode |= mask |
|
||||
} else if direction > 0 { |
|
||||
mode |= stat.Mode().Perm() | mask |
|
||||
} else { |
|
||||
mode |= stat.Mode().Perm() & mask |
|
||||
} |
|
||||
log.Printf("pmode=%d operm=%d => nmode=%d nperm=%d", |
|
||||
stat.Mode(), stat.Mode()&os.ModePerm, |
|
||||
mode, mode&os.ModePerm) |
|
||||
if mode == 0 { |
|
||||
return errors.New("Zero FileMode") |
|
||||
} |
|
||||
if fh == nil { |
|
||||
err = os.Chmod(fileName, mode) |
|
||||
} else { |
|
||||
err = fh.Chmod(mode) |
|
||||
} |
|
||||
return err |
|
||||
} |
|
||||
|
|
||||
// returns whether the filename exists - errors doesn't mean not exists!
|
|
||||
func FileExists(fileName string) bool { |
|
||||
if _, e := os.Stat(fileName); e != nil && os.IsNotExist(e) { |
|
||||
return false |
|
||||
} |
|
||||
return true |
|
||||
} |
|
||||
|
|
||||
// returns whether the filename is POSSIBLY writable
|
|
||||
//- whether it has some kind of writable bit set
|
|
||||
func FileIsWritable(fileName string) bool { |
|
||||
if stat, e := os.Stat(fileName); e == nil { |
|
||||
return stat.Mode().Perm()&0222 > 0 |
|
||||
} |
|
||||
return false |
|
||||
} |
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue