28 lines
651 B
Awk
28 lines
651 B
Awk
|
#!/usr/bin/awk -f
|
||
|
|
||
|
BEGIN {
|
||
|
LOG = ENVIRON["HOME"] "/.fuse.log"
|
||
|
file1 = "hello world"
|
||
|
log_command()
|
||
|
|
||
|
if (ARGC < 2) exit 1
|
||
|
cmd = ARGV[1]; path = (ARGC > 2 ? ARGV[2] : "")
|
||
|
|
||
|
if (cmd == "readdir") print "file1"
|
||
|
else if (cmd == "getattr") print_getattr(path)
|
||
|
else if (cmd == "read" && path == "/file1") print file1
|
||
|
else exit 1
|
||
|
}
|
||
|
|
||
|
function log_command() {
|
||
|
for (i = 0; i < ARGC; i++) printf "%s ", ARGV[i] >> LOG
|
||
|
print "" >> LOG; close(LOG)
|
||
|
}
|
||
|
|
||
|
function print_getattr(p) {
|
||
|
if (p == "/") print "16877 2 1000 1000 4096 8"
|
||
|
else if (p == "/file1") print "33188 1 1000 1000 " length(file1) " 1"
|
||
|
else exit 1
|
||
|
}
|
||
|
|