5. Fuse

9
FUSE EX NO : 5 DATE : 25.09.2012 AIM: ALGORITHM: [39]

Transcript of 5. Fuse

Page 1: 5. Fuse

FUSE

EX NO : 5

DATE : 25.09.2012

AIM:

ALGORITHM:

[39]

Page 2: 5. Fuse

Program & Output: [fosslab@fosslabserver ~]$ rpm -qa|grep fusefuse-gmailfs-0.8.0-5.fc14.noarchfuse-emulator-utils-0.10.0.1-5.fc13.i686fuse-sshfs-2.2-6.fc14.i686fuse-convmvfs-0.2.6-1.fc14.i686ifuse-1.0.0-1.fc14.i686fuse-zip-0.2.11-1.fc13.i686fuse-2.8.4-1.fc14.i686fuse-emulator-roms-0.9.0-3.fc11.noarchafuse-0.2-5.fc12.i686diffuse-0.4.3-1.fc14.noarchfuse-emulator-0.10.0.2-3.fc12.i686gvfs-fuse-1.6.4-2.fc14.i686ceph-fuse-0.20.2-1.fc14.i686fuse-s3fs-0.7-4.fc12.noarchfuse-devel-2.8.4-1.fc14.i686libconfuse-2.6-3.fc12.i686fuseiso-20070708-9.fc13.i686libconfuse-devel-2.6-3.fc12.i686fusecompress_offline1-1.99.19-6.fc12.i686fuse-libs-2.8.4-1.fc14.i686fuse-python-0.2.1-2.fc14.i686fuse-encfs-1.7.2-1.fc14.i686zfs-fuse-0.6.9-7.20100709git.fc14.i686fuse-afp-0.8.1-6.fc12.i686fuse-smb-0.8.7-8.fc13.i686fusecompress-2.6-8.20100223git754bc0de.fc14.i686===[fosslab@fosslabserver ~]$ rpm -qi fuseName : fuse Relocations: (not relocatable)Version : 2.8.4 Vendor: Fedora ProjectRelease : 1.fc14 Build Date: Tue 08 Jun 2010 10:42:44 AM ISTInstall Date: Sun 10 Jun 2012 09:36:31 PM IST Build Host: x86-04.phx2.fedoraproject.orgGroup : System Environment/Base Source RPM: fuse-2.8.4-1.fc14.src.rpmSize : 187240 License: GPL+Signature : RSA/SHA256, Sun 25 Jul 2010 03:27:02 AM IST, Key ID 421caddb97a1071fPackager : Fedora ProjectURL : http://fuse.sf.netSummary : File System in Userspace (FUSE) utilitiesDescription :With FUSE it is possible to implement a fully functional filesystem in auserspace program. This package contains the FUSE userspace tools tomount a FUSE filesystem.====

[40]

Page 3: 5. Fuse

[41]

Page 4: 5. Fuse

places --> downloads --> right click on --> fuse-tutorial.tgz --> extract the file after extraction --> close the downloads folder=====[fosslab@fosslabserver ~]$ pwd/home/fosslab[fosslab@fosslabserver ~]$ cd downloads/bash: cd: downloads/: No such file or directory[fosslab@fosslabserver ~]$ cd Downloads[fosslab@fosslabserver Downloads]$ ls -ltotal 355636-rw-rw-r-- 1 fosslab fosslab 74072485 Sep 21 13:32 CollabNetSubversionEdge-1.3.2_linux-x86.tar.gzdrwxrwxr-x 11 fosslab fosslab 4096 Mar 2 2011 csvndrwxr-xr-x 4 fosslab fosslab 4096 Jan 13 2011 fuse-tutorial-rw-rw-r-- 1 fosslab fosslab 21656 Sep 22 14:17 fuse-tutorial.tgzdrwxrwxr-x 24 fosslab fosslab 4096 Sep 15 16:16 linux-3.0-rw-rw-r-- 1 fosslab fosslab 96687674 Sep 15 15:10 linux-3.0.1(2).tar.gz-rw-rw-r-- 1 fosslab fosslab 96687674 Sep 15 15:07 linux-3.0.1.tar.gz-rw-rw-r-- 1 fosslab fosslab 96675825 Sep 15 15:11 linux-3.0.tar.gz====[fosslab@fosslabserver Downloads]$ cd fuse-tutorial/[fosslab@fosslabserver fuse-tutorial]$ ls -ltotal 60-rw-r--r-- 1 fosslab fosslab 6426 Jan 13 2011 callbacks.htmldrwxr-xr-x 4 fosslab fosslab 4096 Jan 13 2011 example-rw-r--r-- 1 fosslab fosslab 2899 Jan 13 2011 files.html-rw-r--r-- 1 fosslab fosslab 5074 Jan 13 2011 index.html-rw-r--r-- 1 fosslab fosslab 3721 Jan 13 2011 init.html-rw-r--r-- 1 fosslab fosslab 2142 Jan 13 2011 private.html-rw-r--r-- 1 fosslab fosslab 3576 Jan 13 2011 running.html-rw-r--r-- 1 fosslab fosslab 6069 Jan 13 2011 security.htmldrwxr-xr-x 2 fosslab fosslab 4096 Jan 13 2011 src-rw-r--r-- 1 fosslab fosslab 1505 Jan 13 2011 thanks.html-rw-r--r-- 1 fosslab fosslab 6269 Jan 13 2011 unclear.html====

[42]

Page 5: 5. Fuse

[fosslab@fosslabserver fuse-tutorial]$ cd src[fosslab@fosslabserver src]$ ls -ltotal 48-rw-r--r-- 1 fosslab fosslab 27060 Jan 13 2011 bbfs.c-rw-r--r-- 1 fosslab fosslab 4994 Jan 13 2011 log.c-rw-r--r-- 1 fosslab fosslab 420 Jan 13 2011 log.h-rw-r--r-- 1 fosslab fosslab 649 Jan 13 2011 Makefile-rw-r--r-- 1 fosslab fosslab 687 Jan 13 2011 params.h====/* Big Brother File System The point of this FUSE filesystem is to provide an introduction to FUSE. It was my first FUSE filesystem as I got to know the software; hopefully, the comments in this code will help people who follow later to get a gentler introduction. This might be called a no-op filesystem: it doesn't impose filesystem semantics on top of any other existing structure. It simply reports the requests that come in, and passes them to an underlying filesystem. The information is saved in a logfile named bbfs.log, in the directory from which you run bbfs. gcc -Wall `pkg-config fuse --cflags --libs` -o bbfs bbfs.c */===[fosslab@fosslabserver src]$ vi log.c// Since the point of this filesystem is to learn FUSE and its// datastructures, I want to see *everything* that happens related to// its data structures. This file contains macros and functions to// accomplish this.#include "params.h"#include <fuse.h>#include <stdarg.h>#include <stdio.h>#include <stdlib.h>#include <unistd.h>#include <sys/types.h>#include <sys/stat.h>#include "log.h"FILE *log_open(){ FILE *logfile; // very first thing, open up the logfile and mark that we got in"log.c" 176L, 4994C 1,1 Top===[fosslab@fosslabserver src]$ pkg-config fuse --cflags-D_FILE_OFFSET_BITS=64 -I/usr/include/fuse [fosslab@fosslabserver src]$ makegcc -g -Wall `pkg-config fuse --cflags` -c bbfs.cgcc -g -Wall `pkg-config fuse --cflags` -c log.cgcc -g `pkg-config fuse --libs` -o bbfs bbfs.o log.o===[fosslab@fosslabserver src]$ ls -ltotal 132-rwxrwxr-x 1 fosslab fosslab 37502 Sep 22 14:27 bbfs

[43]

Page 6: 5. Fuse

-rw-r--r-- 1 fosslab fosslab 27060 Jan 13 2011 bbfs.c-rw-rw-r-- 1 fosslab fosslab 31260 Sep 22 14:27 bbfs.o-rw-r--r-- 1 fosslab fosslab 4994 Jan 13 2011 log.c-rw-r--r-- 1 fosslab fosslab 420 Jan 13 2011 log.h-rw-rw-r-- 1 fosslab fosslab 10064 Sep 22 14:27 log.o-rw-r--r-- 1 fosslab fosslab 649 Jan 13 2011 Makefile-rw-r--r-- 1 fosslab fosslab 687 Jan 13 2011 params.h========[fosslab@fosslabserver src]$ cd ../example/[fosslab@fosslabserver example]$ ls -ltotal 8drwxr-xr-x 2 fosslab fosslab 4096 Jan 13 2011 mountdirdrwxr-xr-x 2 fosslab fosslab 4096 Jan 13 2011 rootdir[fosslab@fosslabserver example]$ ls -al mountdir/total 8drwxr-xr-x 2 fosslab fosslab 4096 Jan 13 2011 .drwxr-xr-x 4 fosslab fosslab 4096 Jan 13 2011 ..[fosslab@fosslabserver example]$ ls -al rootdir/total 12drwxr-xr-x 2 fosslab fosslab 4096 Jan 13 2011 .drwxr-xr-x 4 fosslab fosslab 4096 Jan 13 2011 ..-rw-r--r-- 1 fosslab fosslab 13 Jan 13 2011 bogus.txt====[fosslab@fosslabserver example]$ cd rootdir/[fosslab@fosslabserver rootdir]$ pwd/home/fosslab/Downloads/fuse-tutorial/example/rootdir[fosslab@fosslabserver rootdir]$ touch myfile[fosslab@fosslabserver rootdir]$ mkdir fusetest[fosslab@fosslabserver rootdir]$ touch fusefile[fosslab@fosslabserver rootdir]$ ls -ltotal 8-rw-r--r-- 1 fosslab fosslab 13 Jan 13 2011 bogus.txt-rw-rw-r-- 1 fosslab fosslab 0 Sep 22 14:30 fusefiledrwxrwxr-x 2 fosslab fosslab 4096 Sep 22 14:30 fusetest-rw-rw-r-- 1 fosslab fosslab 0 Sep 22 14:30 myfile====

[fosslab@fosslabserver rootdir]$ ls -l mountdir/ls: cannot access mountdir/: No such file or directory[fosslab@fosslabserver rootdir]$ pwd/home/fosslab/Downloads/fuse-tutorial/example/rootdir[fosslab@fosslabserver rootdir]$ cd ..[fosslab@fosslabserver example]$ ls -l mountdir/total 0[fosslab@fosslabserver example]$ ls -l rootdir/total 8-rw-r--r-- 1 fosslab fosslab 13 Jan 13 2011 bogus.txt-rw-rw-r-- 1 fosslab fosslab 0 Sep 22 14:30 fusefiledrwxrwxr-x 2 fosslab fosslab 4096 Sep 22 14:30 fusetest

[44]

Page 7: 5. Fuse

-rw-rw-r-- 1 fosslab fosslab 0 Sep 22 14:30 myfile===[fosslab@fosslabserver example]$ ../src bbfs rootdir/mountdir/[fosslab@fosslabserver example]$ ls -l mountdir/total 0[fosslab@fosslabserver example]$ ls -l rootdir/total 8-rw-r--r-- 1 fosslab fosslab 13 Jan 13 2011 bogus.txt-rw-rw-r-- 1 fosslab fosslab 0 Sep 22 14:30 fusefiledrwxrwxr-x 2 fosslab fosslab 4096 Sep 22 14:30 fusetest-rw-rw-r-- 1 fosslab fosslab 0 Sep 22 14:30 myfile===[fosslab@fosslabserver example]$ fusermount -u mountdirfusermount: entry for /home/fosslab/Downloads/fuse-tutorial/example/mountdir not found in /etc/mtab[fosslab@fosslabserver example]$ mount/dev/sda6 on / type ext4 (rw)proc on /proc type proc (rw)sysfs on /sys type sysfs (rw)devpts on /dev/pts type devpts (rw,gid=5,mode=620)tmpfs on /dev/shm type tmpfs (rw)/dev/sda1 on /boot type ext3 (rw)/dev/sda7 on /pub type ext4 (rw)none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)/tmp on /tmp type none (rw,bind)/var/tmp on /var/tmp type none (rw,bind)/home on /home type none (rw,bind)capifs on /dev/capi type capifs (rw,mode=0666)sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)nfsd on /proc/fs/nfsd type nfsd (rw)fusectl on /sys/fs/fuse/connections type fusectl (rw)gvfs-fuse-daemon on /home/fosslab/.gvfs type fuse.gvfs-fuse-daemon (rw,nosuid,nodev,user=fosslab)/dev/sdb1 on /media/BHARATHI type vfat (rw,nosuid,nodev,uhelper=udisks,uid=502,gid=502,shortname=mixed,dmask=0077,utf8=1,flush)====[fosslab@fosslabserver example]$ ls -l mountdir/total 0[fosslab@fosslabserver example]$ tail -f bbfs.log^C[fosslab@fosslabserver example]$ pwd/home/fosslab/Downloads/fuse-tutorial/example[fosslab@fosslabserver example]$ echo "FUSE EXAMPLE COMPLETED"

Result:

[45]