Untuk instalasi FUSE, Anda dapat mengikuti langkah-langkah berikut :
1. Gunakan hak akses super user (sudo su)
2. Ketikkan perintah ./configure
3. Ketikkan perintah make
4. Ketikkan perintah make install
- Download fuse dari http://fuse.sourceforge.net/ pada bagian Download stable release
- Extract file yang sudah didownload.
- Lakukan instalasi fuse, buka terminal lebih dahulu kemudian lakukan perintah dibawah ini:
2. Ketikkan perintah ./configure
3. Ketikkan perintah make
4. Ketikkan perintah make install
- Fuse siap digunakan
Berikut adalah source code FUSE dalam bahasa C/C++
#ifdef linux
#define _XOPEN_SOURCE 500
#endif
#include <fuse.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <dirent.h>
#include <errno.h>
#include <sys/statfs.h>
char *direction={"/home/demsy/mas_Adhipur"}; //folder sumber
static int xmp_getattr(const char *path, struct stat *stbuf)
{
char i[2000];
strcpy(i,direction);
strcat(i,pathcdcd);
int res;
res = lstat(i, stbuf);
if(res == -1)
return -errno;
return 0;
}
static int xmp_readlink(const char *path, char *buf, size_t size)
{
char i[2000];
strcpy(i,direction);
strcat(i,path);
int res;
res = readlink(i, buf, size - 1);
if(res == -1)
return -errno;
buf[res] = '\0';
return 0;
}
static int xmp_getdir(const char *path, fuse_dirh_t h, fuse_dirfil_t filler)
{
char i[2000];
strcpy(i,direction);
strcat(i,path);
DIR *dp;
struct dirent *de;
int res = 0;
dp = opendir(i);
if(dp == NULL)
return -errno;
while((de = readdir(dp)) != NULL) {
res = filler(h, de->d_name, de->d_type);
if(res != 0)
break;
}
closedir(dp);
return res;
}
static int xmp_mknod(const char *path, mode_t mode, dev_t rdev)
{
char i[2000];
strcpy(i,direction);
strcat(i,path);
int res;
res = mknod(i, mode, rdev);
if(res == -1)
return -errno;
return 0;
}
static int xmp_mkdir(const char *path, mode_t mode)
{
char i[2000];
strcpy(i,direction);
strcat(i,path);
int res;
res = mkdir(i, mode);
if(res == -1)
return -errno;
return 0;
}
static int xmp_unlink(const char *path)
{
char i[2000];
strcpy(i,direction);
strcat(i,path);
int res;
res = unlink(i);
if(res == -1)
return -errno;
return 0;
}
static int xmp_rmdir(const char *path)
{
char i[2000];
strcpy(i,direction);
strcat(i,path);
int res;
res = rmdir(i);
if(res == -1)
return -errno;
return 0;
}
static int xmp_symlink(const char *from, const char *to)
{
int res;
res = symlink(from, to);
if(res == -1)
return -errno;
return 0;
}
static int xmp_rename(const char *from, const char *to)
{
int res;
res = rename(from, to);
if(res == -1)
return -errno;
return 0;
}
static int xmp_link(const char *from, const char *to)
{
int res;
res = link(from, to);
if(res == -1)
return -errno;
return 0;
}
static int xmp_chmod(const char *path, mode_t mode)
{
char i[2000];
strcpy(i,direction);
strcat(i,path);
int res;
res = chmod(i, mode);
if(res == -1)
return -errno;
return 0;
}
static int xmp_chown(const char *path, uid_t uid, gid_t gid)
{
char i[2000];
strcpy(i,direction);
strcat(i,path);
int res;
res = lchown(i, uid, gid);
if(res == -1)
return -errno;
return 0;
}
static int xmp_truncate(const char *path, off_t size)
{
char i[2000];
strcpy(i,direction);
strcat(i,path);
int res;
res = truncate(i, size);
if(res == -1)
return -errno;
return 0;
}
static int xmp_utime(const char *path, struct utimbuf *buf)
{
char i[2000];
strcpy(i,direction);
strcat(i,path);
int res;
res = utime(i, buf);
if(res == -1)
return -errno;
return 0;
}
static int xmp_open(const char *path, int flags)
{
char i[2000];
strcpy(i,direction);
strcat(i,path);
int res;
res = open(i, flags);
if(res == -1)
return -errno;
close(res);
return 0;
}
static int xmp_read(const char *path, char *buf, size_t size, off_t offset)
{
char i[2000];
strcpy(i,direction);
strcat(i,path);
int fd;
int res;
fd = open(i, O_RDONLY);
if(fd == -1)
return -errno;
res = pread(fd, buf, size, offset);
if(res == -1)
res = -errno;
close(fd);
return res;
}
static int xmp_write(const char *path, const char *buf, size_t size,
off_t offset)
{
char i[2000];
strcpy(i,direction);
strcat(i,path);
int fd;
int res;
fd = open(i, O_WRONLY);
if(fd == -1)
return -errno;
res = pwrite(fd, buf, size, offset);
if(res == -1)
res = -errno;
close(fd);
return res;
}
static int xmp_statfs(struct fuse_statfs *fst)
{
struct statfs st;
int rv = statfs("/",&st);
if(!rv) {
fst->block_size = st.f_bsize;
fst->blocks = st.f_blocks;
fst->blocks_free = st.f_bavail;
fst->files = st.f_files;
fst->files_free = st.f_ffree;
fst->namelen = st.f_namelen;
}
return rv;
}
static int xmp_release(const char *path, int flags)
{
Just a stub. This method is optional and can safely be left
unimplemented
(void) path;
(void) flags;
return 0;
}
static int xmp_fsync(const char *path, int isdatasync)
{
Just a stub. This method is optional and can safely be left
unimplemented
(void) path;
(void) isdatasync;
return 0;
}
static struct fuse_operations xmp_oper = {
.getattr = xmp_getattr,
.readlink = xmp_readlink,
.getdir = xmp_getdir,
.mknod = xmp_mknod,
.mkdir = xmp_mkdir,
.symlink = xmp_symlink,
.unlink = xmp_unlink,
.rmdir = xmp_rmdir,
.rename = xmp_rename,
.link = xmp_link,
.chmod = xmp_chmod,
.chown = xmp_chown,
.truncate = xmp_truncate,
.utime = xmp_utime,
.open = xmp_open,
.read = xmp_read,
.write = xmp_write,
.statfs = xmp_statfs,
.release = xmp_release,
.fsync = xmp_fsync
};
int main(int argc, char *argv[])
{
fuse_main(argc, argv, &xmp_oper);
return 0;
}
PENJELASAN FUNGSI
getattr: int (* getattr) (const char *, struct Stat *);
Mirip dengan stat (). st_ino dan st_blksize diabaikan. st_ino diabaikan kecuali opsi use_ino mount diberikan.
readlink: int (* readlink) (const char *, char *, size_t);
Membaca target link simbolik.
getdir: int (* getdir) (const char *, fuse_dirh_t, fuse_dirfil_t);
Membaca isi dari sebuah direktori. Operasi ini adalah opendir (), readdir (), ..., closedir () urut dalam satu panggilan.
mknod: int (* mknod) (const char *, mode_t, dev_t);
Hal ini menciptakan node berkas. mknod () akan dipanggil untuk penciptaan semua node non-direktori, non-symlink.
mkdir: int (* mkdir) (const char *, mode_t);
rmdir: int (* rmdir) (const char *);
Membuat dan menghapus direktori, masing-masing.
unlink: int (* unlink) (const char *);
rename: int (* rename) (const char *, const char *);
Menghapus dan mengganti nama file.
symlink: int (* symlink) (const char *, const char *);
Menciptakan link simbolik.
link: int (* link) (const char *, const char *);
Menciptakan hard link ke file.
chmod: int (* chmod) (const char *, mode_t);
chown: int (* chown) (const char *, uid_t, gid_t);
truncate: int (* truncate) (const char *, off_t);
utime: int (* utime) (const char *, struct utimbuf *);
Mengubah bit izin, pemilik kelompok, ukuran, dan waktu akses / modifikasi file.
open: int (* open) (const char *, struct fuse_file_info *);
Operasi membuka file.
read: int (* read) (const char *, char *, size_t, off_t, struct fuse_file_info *);
Membaca data dari file yang terbuka.
write: int (* write) (const char *, const char *, size_t, off_t, struct fuse_file_info *);
Menulis data ke file yang dibuka.
statfs: int (* statfs) (const char *, statfs struct *);
Mendapatkan statistik filesystem.
flush: int (* flush) (const char *, struct fuse_file_info *);
Merupakan data flush-cached. Tidak sama dengan fsync ()
release: int (* release) (const char *, struct fuse_file_info *);
Melepaskan file yang terbuka. release () dipanggil ketika tidak ada lagi referensi ke file yang terbuka
fsync: int (* fsync) (const char *, int, struct fuse_file_info *);
Mensinkronisasikan isi file.
Pinochle Casino & Resort - Mapyro
BalasHapusFind all information and 여주 출장안마 best deals of Pinochle Casino & 서울특별 출장샵 Resort, 제주도 출장안마 Scottsdale, AZ, 삼척 출장샵 including real-time 보령 출장마사지 driving directions, reviews and