Browse Source
get and delete now checks cookie
get and delete now checks cookie
adding super block adding tool to fix volume index git-svn-id: https://weed-fs.googlecode.com/svn/trunk@23 282b0af5-e82d-9cf1-ede4-77906d7719d0pull/2/head
chris.lu@gmail.com
13 years ago
6 changed files with 176 additions and 32 deletions
-
59weed-fs/src/cmd/fix_volume_index.go
-
38weed-fs/src/cmd/weedc.go
-
20weed-fs/src/pkg/storage/needle.go
-
30weed-fs/src/pkg/storage/needle_map.go
-
5weed-fs/src/pkg/storage/store.go
-
50weed-fs/src/pkg/storage/volume.go
@ -0,0 +1,59 @@ |
|||||
|
package main |
||||
|
|
||||
|
import ( |
||||
|
"storage" |
||||
|
"flag" |
||||
|
"log" |
||||
|
"os" |
||||
|
"path" |
||||
|
"strconv" |
||||
|
) |
||||
|
|
||||
|
var ( |
||||
|
dir = flag.String("dir", "/tmp", "data directory to store files") |
||||
|
volumeId = flag.Int("volumeId", -1, "volume id") |
||||
|
IsDebug = flag.Bool("debug", false, "enable debug mode") |
||||
|
|
||||
|
store *storage.Store |
||||
|
) |
||||
|
|
||||
|
func main() { |
||||
|
flag.Parse() |
||||
|
|
||||
|
if *volumeId == -1 { |
||||
|
flag.Usage() |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
fileName := strconv.Itoa(*volumeId) |
||||
|
dataFile, e := os.OpenFile(path.Join(*dir, fileName+".dat"), os.O_RDONLY, 0644) |
||||
|
if e != nil { |
||||
|
log.Fatalf("Read Volume [ERROR] %s\n", e) |
||||
|
} |
||||
|
defer dataFile.Close() |
||||
|
indexFile, ie := os.OpenFile(path.Join(*dir, fileName+".idx"), os.O_WRONLY|os.O_CREATE, 0644) |
||||
|
if ie != nil { |
||||
|
log.Fatalf("Create Volume Index [ERROR] %s\n", ie) |
||||
|
} |
||||
|
defer indexFile.Close() |
||||
|
|
||||
|
//skip the volume super block
|
||||
|
dataFile.Seek(storage.SuperBlockSize, 0) |
||||
|
|
||||
|
n, length := storage.ReadNeedle(dataFile) |
||||
|
nm := storage.NewNeedleMap(indexFile) |
||||
|
offset := uint32(storage.SuperBlockSize) |
||||
|
for n != nil { |
||||
|
if *IsDebug { |
||||
|
log.Println("key", n.Key, "volume offset", offset, "data_size", n.Size, "length", length) |
||||
|
} |
||||
|
if n.Size > 0 { |
||||
|
count, pe := nm.Put(n.Key, offset/8, n.Size) |
||||
|
if *IsDebug { |
||||
|
log.Println("saved", count, "with error", pe) |
||||
|
} |
||||
|
} |
||||
|
offset += length |
||||
|
n, length = storage.ReadNeedle(dataFile) |
||||
|
} |
||||
|
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue