Gauche-FUSE 拡張ライブラリ v1.0 をリリースしました。

http://gauchefuse.googlecode.com/files/Gauche-fuse-1.0.tgz

ファイルシステムGaucheで書きたい!

├ 1.カーネルモジュールプログラミングを勉強する

│    [まちがい]     

│      ユーザ空間でのプログラミングと勝手が違うのが難点です。

│      それよりも別の手段を探してみませんか?

│      FUSEを使えばなんとかなるかも?

│      ↑

│    ココがポイント!

└ 2.Gauche-FUSE拡張ライブラリを使う

      [せいかい]


  • 依存ライブラリ
  • インストール方法

$ sudo gauche-package install Gauche-fuse-1.0.tgz

(use fuse)

(define (hello-getattr path)
  (define stat (make <sys-stat>))
  (cond 
   ((string=? path "/")
    (sys-stat->mode-set! stat #o0755)
    (sys-stat->file-type-set! stat 'directory)
    (sys-stat->nlink-set! stat 2)
    stat)
   ((string=? path "/hello")
    (sys-stat->mode-set! stat #o0444)
    (sys-stat->file-type-set! stat 'regular)
    (sys-stat->nlink-set! stat 1)
    (sys-stat->size-set! stat (string-size "happy hacking!\n"))
    stat)
   (else (- ENOENT))))

(define (hello-readdir path file-info)
  (if (string=? path "/")
    '("." ".." "hello")
    (- ENOENT)))

(define (hello-open path file-info)
  (if (string=? path "/hello")
    0
    (- ENOENT)))

(define (hello-read path out size offset file-info)
  (if (string=? path "/hello")
    (begin (display "happy hacking!\n" out)
	   size)
    (- ENOENT)))

(define (main args)
  (start-fuse (cadr args)
	      :args args
	      :multithreaded #f
	      :getattr hello-getattr
	      :readdir hello-readdir
	      :open hello-open
	      :read hello-read))

Have Fun!