Permalink
Browse files

merge from renzo branch rev #140

  • Loading branch information...
1 parent 79f7f5a commit 792239a4b5ddb6bd5206f444181ef415152fb6a2 @alperakcan committed Sep 2, 2009
View
@@ -1,5 +1,6 @@
Alper Akcan <alper.akcan@gmail.com>
+Renzo Davoli <renzo@cs.unibo.it>
- Contributors (in name order)
View
@@ -1,13 +1,21 @@
+moddir = $(libdir)/umview/modules
+
+DEVELFLAGS =
bin_PROGRAMS = \
fuse-ext2 \
fuse-ext2.probe
+if LINUX
+mod_LTLIBRARIES = umfuseext2.la
+endif
+
fuse_ext2_probe_SOURCES = \
fuse-ext2.h \
fuse-ext2.probe.c \
do_probe.c
+if DARWIN
fuse_ext2_probe_CFLAGS = \
-Wall \
-DHAVE_CONFIG_H \
@@ -20,10 +28,25 @@ fuse_ext2_probe_LDADD = \
../e2fsprogs-1.41.6/et/libcom_err.a \
-L/usr/local/lib \
-lfuse
+endif
+if LINUX
+fuse_ext2_probe_CFLAGS = \
+ -Wall \
+ -DHAVE_CONFIG_H \
+ -D_FILE_OFFSET_BITS=64 \
+ -I/usr/local/include
+
+fuse_ext2_probe_LDADD = \
+ -L/usr/local/lib \
+ -lfuse \
+ -lext2fs
+endif
fuse_ext2_SOURCES = \
fuse-ext2.h \
fuse-ext2.c \
+ ext2-fileio.c \
+ vnode_hash.c \
do_probe.c \
do_check.c \
do_fillstatbuf.c \
@@ -53,7 +76,62 @@ fuse_ext2_SOURCES = \
op_mknod.c \
op_symlink.c \
op_truncate.c \
- op_link.c
+ op_link.c \
+ op_rename.c
+
+if LINUX
+umfuseext2_la_SOURCES = \
+ fuse-ext2.h \
+ fuse-ext2.c \
+ ext2-fileio.c \
+ vnode_hash.c \
+ do_probe.c \
+ do_check.c \
+ do_fillstatbuf.c \
+ do_readinode.c \
+ do_killfilebyinode.c \
+ op_init.c \
+ op_destroy.c \
+ op_access.c \
+ op_fgetattr.c \
+ op_getattr.c \
+ op_open.c \
+ op_read.c \
+ op_readdir.c \
+ op_readlink.c \
+ op_release.c \
+ op_statfs.c \
+ op_chown.c \
+ op_chmod.c \
+ op_create.c \
+ op_flush.c \
+ op_fsync.c \
+ op_mkdir.c \
+ op_rmdir.c \
+ op_unlink.c \
+ op_utimens.c \
+ op_write.c \
+ op_mknod.c \
+ op_symlink.c \
+ op_truncate.c \
+ op_link.c \
+ op_rename.c
+
+umfuseext2_la_CFLAGS = \
+ -Wall \
+ -DHAVE_CONFIG_H \
+ -D_FILE_OFFSET_BITS=64 \
+ -D_GNU_SOURCE \
+ $(DEVELFLAGS) \
+ -I$(includedir)/umview \
+ -I/usr/local/include
+
+umfuseext2_la_LDFLAGS = \
+ -module \
+ -avoid-version \
+ -export-dynamic \
+ -lext2fs
+endif
fuse_ext2_CFLAGS = \
-Wall \
@@ -81,13 +159,22 @@ fuse_ext2_probe_CFLAGS += \
fuse_ext2_CFLAGS += \
-D__FreeBSD__=10
-endif
fuse_ext2_LDADD = \
../e2fsprogs-1.41.6/ext2fs/libext2fs.a \
../e2fsprogs-1.41.6/et/libcom_err.a \
-L/usr/local/lib \
-lfuse
+endif
+if LINUX
+fuse_ext2_LDADD = \
+ -L/usr/local/lib \
+ -lfuse \
+ -lext2fs
+endif
+
+install-data-hook:
+ cd "$(DESTDIR)/$(moddir)" && rm -f $(mod_LTLIBRARIES)
if DARWIN
install-exec-local:
View
@@ -1,5 +1,6 @@
/**
* Copyright (c) 2008-2009 Alper Akcan <alper.akcan@gmail.com>
+ * Copyright (c) 2009 Renzo Davoli <renzo@cs.unibo.it>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -21,34 +22,44 @@
int do_check (const char *path)
{
- char *p_path;
- char *r_path;
- char *t_path;
-
- debugf("enter");
- debugf("path = %s", path);
-
- p_path = strdup(path);
- if (p_path == NULL) {
- return -ENOMEM;
- }
- t_path = strrchr(p_path, '/');
- if (t_path == NULL) {
- debugf("this should not happen %s", p_path);
- free(p_path);
+ char *basename_path;
+ basename_path = strrchr(path, '/');
+ if (basename_path == NULL) {
+ debugf("this should not happen %s", path);
return -ENOENT;
}
- *t_path = '\0';
- r_path = t_path + 1;
- debugf("parent: %s, child: %s, pathmax: %d", p_path, r_path, PATH_MAX);
-
- if (strlen(r_path) > 255) {
- debugf("path exceeds 255 characters");
- free(p_path);
+ basename_path++;
+ if (strlen(basename_path) > 255) {
+ debugf("basename exceeds 255 characters %s",path);
return -ENAMETOOLONG;
}
- free(p_path);
+ return 0;
+}
- debugf("leave");
+int do_check_split (const char *path,char **dirname,char **basename)
+{
+ char *cpath=strdup(path);
+ char *tmp;
+ tmp = strrchr(cpath, '/');
+ if (tmp == NULL) {
+ debugf("this should not happen %s", path);
+ free(cpath);
+ return -ENOENT;
+ }
+ *tmp='\0';
+ tmp++;
+ if (strlen(tmp) > 255) {
+ debugf("basename exceeds 255 characters %s",path);
+ free(cpath);
+ return -ENAMETOOLONG;
+ }
+ *dirname=cpath;
+ *basename=tmp;
return 0;
}
+
+void free_split(char *dirname, char *basename)
+{
+ free(dirname);
+}
+
@@ -1,5 +1,6 @@
/**
* Copyright (c) 2008-2009 Alper Akcan <alper.akcan@gmail.com>
+ * Copyright (c) 2009 Renzo Davoli <renzo@cs.unibo.it>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -19,19 +20,39 @@
#include "fuse-ext2.h"
-void do_fillstatbuf (ext2_ino_t ino, struct ext2_inode *inode, struct stat *st)
+static inline dev_t old_decode_dev(__u16 val)
+{
+ return makedev((val >> 8) & 255, val & 255);
+}
+
+static inline dev_t new_decode_dev(__u32 dev)
+{
+ unsigned major = (dev & 0xfff00) >> 8;
+ unsigned minor = (dev & 0xff) | ((dev >> 12) & 0xfff00);
+ return makedev(major, minor);
+}
+
+void do_fillstatbuf (ext2_filsys e2fs, ext2_ino_t ino, struct ext2_inode *inode, struct stat *st)
{
debugf("enter");
memset(st, 0, sizeof(*st));
- /* st_dev */
+ /* XXX workaround
+ * should be unique and != existing devices */
+ st->st_dev = (dev_t) ((long)e2fs);
st->st_ino = ino;
st->st_mode = inode->i_mode;
st->st_nlink = inode->i_links_count;
st->st_uid = inode->i_uid; /* add in uid_high */
st->st_gid = inode->i_gid; /* add in gid_high */
- /* st_rdev */
+ if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode)) {
+ if (inode->i_block[0])
+ st->st_rdev = old_decode_dev(ext2fs_le32_to_cpu(inode->i_block[0]));
+ else
+ st->st_rdev = new_decode_dev(ext2fs_le32_to_cpu(inode->i_block[1]));
+ } else
+ st->st_rdev = 0;
st->st_size = inode->i_size;
- st->st_blksize = EXT2_BLOCK_SIZE(priv.fs->super);
+ st->st_blksize = EXT2_BLOCK_SIZE(e2fs->super);
st->st_blocks = inode->i_blocks;
st->st_atime = inode->i_atime;
st->st_mtime = inode->i_mtime;
@@ -1,3 +1,22 @@
+/**
+ * Copyright (c) 2008-2009 Alper Akcan <alper.akcan@gmail.com>
+ * Copyright (c) 2009 Renzo Davoli <renzo@cs.unibo.it>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program (in the main directory of the fuse-ext2
+ * distribution in the file COPYING); if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
#include "fuse-ext2.h"
@@ -11,33 +30,40 @@ static int release_blocks_proc (ext2_filsys fs, blk_t *blocknr, int blockcnt, vo
ext2fs_block_alloc_stats(fs, block, -1);
debugf("leave");
+#ifdef CLEAN_UNUSED_BLOCKS
+ *blocknr = 0;
+ return BLOCK_CHANGED;
+#else
return 0;
+#endif
}
-int do_killfilebyinode (ext2_ino_t ino, struct ext2_inode *inode)
+int do_killfilebyinode (ext2_filsys e2fs, ext2_ino_t ino, struct ext2_inode *inode)
{
errcode_t rc;
+ char scratchbuf[3*e2fs->blocksize];
debugf("enter");
inode->i_links_count = 0;
inode->i_dtime = time(NULL);
- rc = ext2fs_write_inode(priv.fs, ino, inode);
+ rc = ext2fs_write_inode(e2fs, ino, inode);
if (rc) {
- debugf("ext2fs_write_inode(priv.fs, ino, inode); failed");
+ debugf("ext2fs_write_inode(e2fs, ino, inode); failed");
return -EIO;
}
- if (!ext2fs_inode_has_valid_blocks(inode)) {
- debugf("inode has no blocks, leaving");
- return 0;
+ if (ext2fs_inode_has_valid_blocks(inode)) {
+ debugf("start block delete for %d", ino);
+#ifdef CLEAN_UNUSED_BLOCKS
+ ext2fs_block_iterate(e2fs, ino, BLOCK_FLAG_DEPTH_TRAVERSE, scratchbuf, release_blocks_proc, NULL);
+#else
+ ext2fs_block_iterate(e2fs, ino, 0, scratchbuf, release_blocks_proc, NULL);
+#endif
}
- debugf("start block delete for %d", ino);
-
- ext2fs_block_iterate(priv.fs, ino, 0, NULL, release_blocks_proc, NULL);
- ext2fs_inode_alloc_stats2(priv.fs, ino, -1, LINUX_S_ISDIR(inode->i_mode));
+ ext2fs_inode_alloc_stats2(e2fs, ino, -1, LINUX_S_ISDIR(inode->i_mode));
debugf("leave");
return 0;
Oops, something went wrong.

0 comments on commit 792239a

Please sign in to comment.