NetBSD hammer with fuse and hammerread

Jeremy C. Reed reed at reedmedia.net
Thu Apr 16 07:15:47 PDT 2009


Prompted by Daniel's FUSE work, I tried it on NetBSD/amd64 5.0_RC3.

My changes were very minor. I built with -D_NETBSD_SOURCE, I commented out 
the include for features.h, I adjusted fusehammer/Makefile to also build 
hammerread object file (bmake is different than gmake), use -lrefuse 
instead of -fuse, and I changed a few printf formattings to use PRIu64.

Running fusehammer works, but it never returns back to shell prompt:

   752      1 fusehammer 1239888701.657193975 CALL  __mount50(0x7f7ffd70d89b,0x7f7fffffcc60,0x18,0x7f7ffd45a000,0xd70)
   752      1 fusehammer 1239888701.657195790 NAMI  "/home/reed/hammer/fusehammer/mnt"
   752      1 fusehammer 1239888701.657227708 RET   __mount50 0
   752      1 fusehammer 1239888701.657233575 CALL  kqueue
   752      1 fusehammer 1239888701.657235949 RET   kqueue 5
   752      1 fusehammer 1239888701.657238184 CALL  ioctl(4,FIONBIO,0x7f7fffffdb44)
   752      1 fusehammer 1239888701.657239371 GIO   fd 4 wrote 4 bytes
       "\^A\0\0\0"
   752      1 fusehammer 1239888701.657240838 RET   ioctl 0
   752      1 fusehammer 1239888701.657249219 CALL  kevent(5,0x7f7ffd443070,2,0,0,0)
   752      1 fusehammer 1239888701.657253898 RET   kevent 0
   752      1 fusehammer 1239888701.657258578 CALL  kevent(5,0x7f7ffd443070,0,0x7f7ffd443070,2,0)

Sits here. (the following is me pressing Ctrl-C)

   752      1 fusehammer 1239888710.745579167 RET   kevent -1 errno 4 Interrupted system call
   752      1 fusehammer 1239888710.745583078 PSIG  SIGINT SIG_DFL: code=SI_NOINFO

Nevertheless, running it in the background works. mount shows:

/dev/puffs on /home/reed/hammer/fusehammer/mnt type puffs|refuse:hammerdisk.raw (nosuid, nodev, mounted by reed)

$ ls -l /home/reed/hammer/fusehammer/mnt
total 0
drwxr-xr-x  0 root  wheel   0 Dec 31  1969 a
-rw-r--r--  0 root  wheel  12 Dec 31  1969 test
$ ls -l /home/reed/hammer/fusehammer/mnt/a
total 0
drwxr-xr-x  0 root  wheel  0 Dec 31  1969 b
$ ls -l /home/reed/hammer/fusehammer/mnt/a/b
total 0
drwxr-xr-x  0 root  wheel  0 Dec 31  1969 c
$ ls -l /home/reed/hammer/fusehammer/mnt/a/b/c
total 0
-rw-r--r--  0 root  wheel  4 Dec 31  1969 bar
$ cat /home/reed/hammer/fusehammer/mnt/a/b/c/bar      
foo
$ cat /home/reed/hammer/fusehammer/mnt/test      
Hello
World

And as expected with this for now:

$ rm /home/reed/hammer/fusehammer/mnt/test   
rm: /home/reed/hammer/fusehammer/mnt/test: Function not implemented

$ umount ./mnt
$ 
[1] + Done                 ./fusehammer ../hammerdisk.raw ./mnt

And another example:

$ ./fusehammer ../hammerdisk.raw ./mnt &         
[1] 880
$ fusehammer: puffs_mount: "./mnt" is a relative path.
fusehammer: puffs_mount: using "/home/reed/hammer/fusehammer/mnt" instead.

$ stat ./mnt/a/b/c/foo                                                         
stat: ./mnt/a/b/c/foo: lstat: No such file or directory
$ stat ./mnt/a/b/c/bar                                                         
51969 0 -rw-r--r-- 0 root wheel 0 4 "Dec 31 18:00:00 1969" "Dec 31 
18:00:00 1969" "Dec 31 18:00:00 1969" "Dec 31 18:00:00 1969" 512 0 0 
. /mnt/a/b/c/bar
$ umount ./mnt
$ 
[1] + Done                 ./fusehammer ../hammerdisk.raw ./mnt 

df (when mounted shows):

$ df -m /dev/puffs /home/reed/hammer/fusehammer/mnt
Filesystem   1M-blocks       Used      Avail %Cap Mounted on
/dev/wd0a         28543       3287      23829  12% /
/dev/puffs        28543       3287      23829  12% /home/reed/hammer/fusehammer/mnt

Maybe that is normal for NetBSD's puffs(3).

Problems:
- doesn't have number of links for directory (maybe causes find problem 
	shown below)
- doesn't have size of directory (number of blocks used)
- timestamps
- no inode numbers

And a find problem (doesn't descend):

$ find ./mnt -ls
      0      0 drwxr-xr-x    0 root              wheel                    0 Dec 31  1969 ./mnt
      0      0 -rw-r--r--    0 root              wheel                    12 Dec 31  1969 ./mnt/test
      0      0 drwxr-xr-x    0 root              wheel                     0 Dec 31  1969 ./mnt/a


Next are my hammerread examples:

$ ./hammerread ../hammerdisk.raw /                                             
signature: valid
name: HAMMER
/ 0/0 40755 0
test 8 4301368000
a 4 4302968400

$ ./hammerread ../hammerdisk.raw /test
signature: valid
name: HAMMER
/test 0/0 100644 12
Hello
World

$ ./hammerread ../hammerdisk.raw /a    
signature: valid
name: HAMMER
/a 0/0 40755 0
b 4 4304568416

$ ./hammerread ../hammerdisk.raw /a/b
signature: valid
name: HAMMER
/a/b 0/0 40755 0
c 4 4306168432

$ ./hammerread ../hammerdisk.raw /a/b/c
signature: valid
name: HAMMER
/a/b/c 0/0 40755 0
bar 8 4307768448

$ ./hammerread ../hammerdisk.raw /a/b/c/bar
signature: valid
name: HAMMER
/a/b/c/bar 0/0 100644 4
foo

Thank you Daniel for this fuse work!

Daniel: please add a license to your new source files. Please consider 
using the standard DragonFly Project license (see hammer_disk.h and
hammerread.c for same example).

Also note that the bsd_compat.h is not "BSD" specific. As DT_DBF and 
S_IFDB appear to be DragonFly specific (as for __unused, I don't know, but 
thought was some gcc attribute).

Also when building fusehammer I get this warning:

	hammerread.c:839: warning: 'hclose' defined but not used

Now I see that version of hammerread.c has lots of unused code via #if 0

And do you have your porting work available via some revision control 
system?



  Jeremy C. Reed

echo 'EhZ[h ^jjf0%%h[[Zc[Z_W$d[j%Xeeai%ZW[ced#]dk#f[d]k_d%' | \
  tr            '#-~'            '\-.-{'






More information about the Hammer mailing list