mplemented the complete set of FUSE functions for libcaptive.
authorlace <>
Mon, 19 Dec 2005 20:28:09 +0000 (20:28 +0000)
committerlace <>
Mon, 19 Dec 2005 20:28:09 +0000 (20:28 +0000)
20 files changed:
src/client/fuse/Makefile.am
src/client/fuse/main.c
src/client/fuse/op_chmod.c [new file with mode: 0644]
src/client/fuse/op_chmod.h [new file with mode: 0644]
src/client/fuse/op_mkdir.c [new file with mode: 0644]
src/client/fuse/op_mkdir.h [new file with mode: 0644]
src/client/fuse/op_mknod.c [new file with mode: 0644]
src/client/fuse/op_mknod.h [new file with mode: 0644]
src/client/fuse/op_rename.c [new file with mode: 0644]
src/client/fuse/op_rename.h [new file with mode: 0644]
src/client/fuse/op_rmdir.c [new file with mode: 0644]
src/client/fuse/op_rmdir.h [new file with mode: 0644]
src/client/fuse/op_truncate.c [new file with mode: 0644]
src/client/fuse/op_truncate.h [new file with mode: 0644]
src/client/fuse/op_unlink.c [new file with mode: 0644]
src/client/fuse/op_unlink.h [new file with mode: 0644]
src/client/fuse/op_utime.c [new file with mode: 0644]
src/client/fuse/op_utime.h [new file with mode: 0644]
src/client/fuse/op_write.c [new file with mode: 0644]
src/client/fuse/op_write.h [new file with mode: 0644]

index 837908e..fcf2ead 100644 (file)
@@ -40,6 +40,24 @@ mount_captive_SOURCES= \
                op_release.h \
                op_getattr.c \
                op_getattr.h \
+               op_mknod.c \
+               op_mknod.h \
+               op_unlink.c \
+               op_unlink.h \
+               op_mkdir.c \
+               op_mkdir.h \
+               op_rmdir.c \
+               op_rmdir.h \
+               op_chmod.c \
+               op_chmod.h \
+               op_truncate.c \
+               op_truncate.h \
+               op_write.c \
+               op_write.h \
+               op_rename.c \
+               op_rename.h \
+               op_utime.c \
+               op_utime.h \
                gnomevfsresult.c \
                gnomevfsresult.h \
                gnomevfsfileinfo.c \
index 9778182..9092e80 100644 (file)
 #include "op_read.h"
 #include "op_release.h"
 #include "op_getattr.h"
+#include "op_mknod.h"
+#include "op_unlink.h"
+#include "op_mkdir.h"
+#include "op_rmdir.h"
+#include "op_chmod.h"
+#include "op_truncate.h"
+#include "op_write.h"
+#include "op_rename.h"
+#include "op_utime.h"
 
 
 CaptiveVfsObject *capfuse_captive_vfs_object;
@@ -60,18 +69,15 @@ static const struct fuse_operations capfuse_operations={
        read:       op_read,
        release:    op_release,
        getattr:    op_getattr,
-#if 0
-       flush:      op_flush,
        mknod:      op_mknod,
-       mkdir:      op_mkdir,
        unlink:     op_unlink,
+       mkdir:      op_mkdir,
        rmdir:      op_rmdir,
-       rename:     op_rename,
        chmod:      op_chmod,
        truncate:   op_truncate,
-       utime:      op_utime,
        write:      op_write,
-#endif
+       rename:     op_rename,
+       utime:      op_utime,
        };
 
 /* argv[0] expected as the program name. */
diff --git a/src/client/fuse/op_chmod.c b/src/client/fuse/op_chmod.c
new file mode 100644 (file)
index 0000000..e09e6c3
--- /dev/null
@@ -0,0 +1,65 @@
+/* $Id$
+ * Client fuse interface operation "chmod" for libcaptive
+ * Copyright (C) 2005 Jan Kratochvil <project-captive@jankratochvil.net>
+ * 
+ * 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; exactly version 2 of June 1991 is required
+ * 
+ * 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; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+
+#include "config.h"
+
+#include <glib/gmessages.h>
+#include <fuse.h>
+#include <errno.h>
+#include <captive/client-file.h>
+#include <sys/stat.h>
+#include <captive/macros.h>
+
+#include "op_chmod.h"  /* self */
+#include "main.h"
+#include "gnomevfsresult.h"
+#include "gnomevfsfileinfo.h"
+
+
+int op_chmod(const char *path,mode_t mode)
+{
+CaptiveFileObject *captive_file_object;
+GnomeVFSResult errvfsresult;
+GnomeVFSFileInfo file_info;
+
+       g_return_val_if_fail(path!=NULL,-EINVAL);
+
+       if (1
+                       && !S_ISREG(mode)
+                       && !S_ISDIR(mode))
+               return -EPERM;
+
+       /* Do not: GNOME_VFS_OPEN_WRITE
+        * as we would get EPERM for setting back: chmod u+w
+        */
+       if (GNOME_VFS_OK!=(errvfsresult=captive_file_new_open(&captive_file_object,capfuse_captive_vfs_object,path,0)))
+               return -gnomevfsresult_to_errno(errvfsresult);
+
+       file_info.valid_fields=0
+                       |GNOME_VFS_FILE_INFO_FIELDS_PERMISSIONS
+                       |GNOME_VFS_FILE_INFO_FIELDS_ACCESS;
+       file_info.permissions=mode;
+       errvfsresult=captive_file_file_info_set(captive_file_object,&file_info,GNOME_VFS_SET_FILE_INFO_PERMISSIONS);
+
+       g_object_unref(captive_file_object);
+       if (GNOME_VFS_OK!=errvfsresult)
+               return -gnomevfsresult_to_errno(errvfsresult);
+
+       return 0;
+}
diff --git a/src/client/fuse/op_chmod.h b/src/client/fuse/op_chmod.h
new file mode 100644 (file)
index 0000000..a6e3d52
--- /dev/null
@@ -0,0 +1,31 @@
+/* $Id$
+ * Include file for client fuse interface operation "chmod" for libcaptive
+ * Copyright (C) 2005 Jan Kratochvil <project-captive@jankratochvil.net>
+ * 
+ * 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; exactly version 2 of June 1991 is required
+ * 
+ * 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; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+
+#ifndef _CAPTIVE_CLIENT_FUSE_OP_CHMOD_H
+#define _CAPTIVE_CLIENT_FUSE_OP_CHMOD_H 1
+
+
+#include <fuse.h>
+#include <sys/stat.h>
+
+
+int op_chmod(const char *path,mode_t mode);
+
+
+#endif /* _CAPTIVE_CLIENT_FUSE_OP_CHMOD_H */
diff --git a/src/client/fuse/op_mkdir.c b/src/client/fuse/op_mkdir.c
new file mode 100644 (file)
index 0000000..a9a646f
--- /dev/null
@@ -0,0 +1,54 @@
+/* $Id$
+ * Client fuse interface operation "mkdir" for libcaptive
+ * Copyright (C) 2005 Jan Kratochvil <project-captive@jankratochvil.net>
+ * 
+ * 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; exactly version 2 of June 1991 is required
+ * 
+ * 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; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+
+#include "config.h"
+
+#include <glib/gmessages.h>
+#include <fuse.h>
+#include <errno.h>
+#include <captive/client-directory.h>
+#include <sys/stat.h>
+
+#include "op_mkdir.h"  /* self */
+#include "main.h"
+#include "gnomevfsresult.h"
+
+
+int op_mkdir(const char *path,mode_t mode)
+{
+CaptiveDirectoryObject *captive_directory_object;
+GnomeVFSResult errvfsresult;
+
+       g_return_val_if_fail(path!=NULL,-EINVAL);
+
+       /* Do not: if (!S_ISDIR(mode))
+        * as FUSE does not set it.
+        */
+       if (mode&S_IFMT)
+               return -EPERM;
+
+       if (GNOME_VFS_OK!=(errvfsresult=captive_directory_new_make(&captive_directory_object,capfuse_captive_vfs_object,
+                               path,   /* pathname */
+                               mode))) /* perm */
+               return -gnomevfsresult_to_errno(errvfsresult);
+
+       g_object_unref(captive_directory_object);
+
+       return 0;
+}
diff --git a/src/client/fuse/op_mkdir.h b/src/client/fuse/op_mkdir.h
new file mode 100644 (file)
index 0000000..5d851c3
--- /dev/null
@@ -0,0 +1,31 @@
+/* $Id$
+ * Include file for client fuse interface operation "mkdir" for libcaptive
+ * Copyright (C) 2005 Jan Kratochvil <project-captive@jankratochvil.net>
+ * 
+ * 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; exactly version 2 of June 1991 is required
+ * 
+ * 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; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+
+#ifndef _CAPTIVE_CLIENT_FUSE_OP_MKDIR_H
+#define _CAPTIVE_CLIENT_FUSE_OP_MKDIR_H 1
+
+
+#include <fuse.h>
+#include <sys/stat.h>
+
+
+int op_mkdir(const char *path,mode_t mode);
+
+
+#endif /* _CAPTIVE_CLIENT_FUSE_OP_MKDIR_H */
diff --git a/src/client/fuse/op_mknod.c b/src/client/fuse/op_mknod.c
new file mode 100644 (file)
index 0000000..79a445d
--- /dev/null
@@ -0,0 +1,53 @@
+/* $Id$
+ * Client fuse interface operation "mknod" for libcaptive
+ * Copyright (C) 2005 Jan Kratochvil <project-captive@jankratochvil.net>
+ * 
+ * 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; exactly version 2 of June 1991 is required
+ * 
+ * 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; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+
+#include "config.h"
+
+#include <glib/gmessages.h>
+#include <fuse.h>
+#include <errno.h>
+#include <captive/client-file.h>
+#include <sys/stat.h>
+
+#include "op_mknod.h"  /* self */
+#include "main.h"
+#include "gnomevfsresult.h"
+
+
+int op_mknod(const char *path,mode_t mode,dev_t rdev)
+{
+CaptiveFileObject *captive_file_object;
+GnomeVFSResult errvfsresult;
+
+       g_return_val_if_fail(path!=NULL,-EINVAL);
+
+       if (!S_ISREG(mode))
+               return -EPERM;
+
+       if (GNOME_VFS_OK!=(errvfsresult=captive_file_new_create(&captive_file_object,capfuse_captive_vfs_object,
+                               path,   /* pathname */
+                               0,      /* mode */
+                               TRUE,   /* exclusive */
+                               mode))) /* perm */
+               return -gnomevfsresult_to_errno(errvfsresult);
+
+       g_object_unref(captive_file_object);
+
+       return 0;
+}
diff --git a/src/client/fuse/op_mknod.h b/src/client/fuse/op_mknod.h
new file mode 100644 (file)
index 0000000..c4a0cae
--- /dev/null
@@ -0,0 +1,31 @@
+/* $Id$
+ * Include file for client fuse interface operation "mknod" for libcaptive
+ * Copyright (C) 2005 Jan Kratochvil <project-captive@jankratochvil.net>
+ * 
+ * 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; exactly version 2 of June 1991 is required
+ * 
+ * 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; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+
+#ifndef _CAPTIVE_CLIENT_FUSE_OP_MKNOD_H
+#define _CAPTIVE_CLIENT_FUSE_OP_MKNOD_H 1
+
+
+#include <fuse.h>
+#include <sys/stat.h>
+
+
+int op_mknod(const char *path,mode_t mode,dev_t rdev);
+
+
+#endif /* _CAPTIVE_CLIENT_FUSE_OP_MKNOD_H */
diff --git a/src/client/fuse/op_rename.c b/src/client/fuse/op_rename.c
new file mode 100644 (file)
index 0000000..eb42cf8
--- /dev/null
@@ -0,0 +1,57 @@
+/* $Id$
+ * Client fuse interface operation "rename" for libcaptive
+ * Copyright (C) 2005 Jan Kratochvil <project-captive@jankratochvil.net>
+ * 
+ * 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; exactly version 2 of June 1991 is required
+ * 
+ * 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; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+
+#include "config.h"
+
+#include <glib/gmessages.h>
+#include <fuse.h>
+#include <errno.h>
+#include <captive/client-file.h>
+#include <sys/stat.h>
+
+#include "op_rename.h" /* self */
+#include "main.h"
+#include "gnomevfsresult.h"
+
+
+int op_rename(const char *oldpath,const char *newpath)
+{
+CaptiveFileObject *captive_file_object;
+GnomeVFSResult errvfsresult;
+
+       g_return_val_if_fail(oldpath!=NULL,-EINVAL);
+       g_return_val_if_fail(newpath!=NULL,-EINVAL);
+
+       if (GNOME_VFS_OK!=(errvfsresult=captive_file_new_open(&captive_file_object,capfuse_captive_vfs_object,oldpath,
+                       GNOME_VFS_OPEN_WRITE|GNOME_VFS_OPEN_RANDOM)))
+               return -gnomevfsresult_to_errno(errvfsresult);
+
+       /* Do not: FALSE==force_replace
+        * as it would really return EEXIST on mv(1) over an existing file.
+        */
+       errvfsresult=captive_file_move(
+                       captive_file_object,    /* captive_file_object_old */
+                       newpath,        /* pathname_new */
+                       TRUE);  /* force_replace */
+
+       g_object_unref(captive_file_object);
+       if (GNOME_VFS_OK!=errvfsresult)
+               return -gnomevfsresult_to_errno(errvfsresult);
+       return 0;
+}
diff --git a/src/client/fuse/op_rename.h b/src/client/fuse/op_rename.h
new file mode 100644 (file)
index 0000000..8cc5e8c
--- /dev/null
@@ -0,0 +1,31 @@
+/* $Id$
+ * Include file for client fuse interface operation "rename" for libcaptive
+ * Copyright (C) 2005 Jan Kratochvil <project-captive@jankratochvil.net>
+ * 
+ * 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; exactly version 2 of June 1991 is required
+ * 
+ * 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; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+
+#ifndef _CAPTIVE_CLIENT_FUSE_OP_RENAME_H
+#define _CAPTIVE_CLIENT_FUSE_OP_RENAME_H 1
+
+
+#include <fuse.h>
+#include <sys/stat.h>
+
+
+int op_rename(const char *oldpath,const char *newpath);
+
+
+#endif /* _CAPTIVE_CLIENT_FUSE_OP_RENAME_H */
diff --git a/src/client/fuse/op_rmdir.c b/src/client/fuse/op_rmdir.c
new file mode 100644 (file)
index 0000000..5648ae8
--- /dev/null
@@ -0,0 +1,49 @@
+/* $Id$
+ * Client fuse interface operation "rmdir" for libcaptive
+ * Copyright (C) 2005 Jan Kratochvil <project-captive@jankratochvil.net>
+ * 
+ * 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; exactly version 2 of June 1991 is required
+ * 
+ * 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; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+
+#include "config.h"
+
+#include <glib/gmessages.h>
+#include <fuse.h>
+#include <errno.h>
+#include <captive/client-directory.h>
+#include <sys/stat.h>
+
+#include "op_rmdir.h"  /* self */
+#include "main.h"
+#include "gnomevfsresult.h"
+
+
+int op_rmdir(const char *path)
+{
+CaptiveDirectoryObject *captive_directory_object;
+GnomeVFSResult errvfsresult;
+
+       g_return_val_if_fail(path!=NULL,-EINVAL);
+
+       if (GNOME_VFS_OK!=(errvfsresult=captive_directory_new_open(&captive_directory_object,capfuse_captive_vfs_object,path)))
+               return -gnomevfsresult_to_errno(errvfsresult);
+
+       errvfsresult=captive_directory_remove(captive_directory_object);
+       g_object_unref(captive_directory_object);
+       if (GNOME_VFS_OK!=errvfsresult)
+               return -gnomevfsresult_to_errno(errvfsresult);
+
+       return 0;
+}
diff --git a/src/client/fuse/op_rmdir.h b/src/client/fuse/op_rmdir.h
new file mode 100644 (file)
index 0000000..bca2cb4
--- /dev/null
@@ -0,0 +1,31 @@
+/* $Id$
+ * Include file for client fuse interface operation "rmdir" for libcaptive
+ * Copyright (C) 2005 Jan Kratochvil <project-captive@jankratochvil.net>
+ * 
+ * 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; exactly version 2 of June 1991 is required
+ * 
+ * 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; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+
+#ifndef _CAPTIVE_CLIENT_FUSE_OP_RMDIR_H
+#define _CAPTIVE_CLIENT_FUSE_OP_RMDIR_H 1
+
+
+#include <fuse.h>
+#include <sys/stat.h>
+
+
+int op_rmdir(const char *path);
+
+
+#endif /* _CAPTIVE_CLIENT_FUSE_OP_RMDIR_H */
diff --git a/src/client/fuse/op_truncate.c b/src/client/fuse/op_truncate.c
new file mode 100644 (file)
index 0000000..c8f5946
--- /dev/null
@@ -0,0 +1,52 @@
+/* $Id$
+ * Client fuse interface operation "truncate" for libcaptive
+ * Copyright (C) 2005 Jan Kratochvil <project-captive@jankratochvil.net>
+ * 
+ * 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; exactly version 2 of June 1991 is required
+ * 
+ * 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; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+
+#include "config.h"
+
+#include <glib/gmessages.h>
+#include <fuse.h>
+#include <errno.h>
+#include <captive/client-file.h>
+#include <sys/stat.h>
+#include <captive/macros.h>
+
+#include "op_truncate.h"       /* self */
+#include "main.h"
+#include "gnomevfsresult.h"
+
+
+int op_truncate(const char *path,off_t size)
+{
+CaptiveFileObject *captive_file_object;
+GnomeVFSResult errvfsresult;
+
+       g_return_val_if_fail(path!=NULL,-EINVAL);
+       g_return_val_if_fail(size>=0,-EINVAL);
+
+       if (GNOME_VFS_OK!=(errvfsresult=captive_file_new_open(&captive_file_object,capfuse_captive_vfs_object,path,
+                       GNOME_VFS_OPEN_WRITE|GNOME_VFS_OPEN_RANDOM)))
+               return -gnomevfsresult_to_errno(errvfsresult);
+
+       errvfsresult=captive_file_truncate(captive_file_object,size);
+       g_object_unref(captive_file_object);
+       if (GNOME_VFS_OK!=errvfsresult)
+               return -gnomevfsresult_to_errno(errvfsresult);
+
+       return 0;
+}
diff --git a/src/client/fuse/op_truncate.h b/src/client/fuse/op_truncate.h
new file mode 100644 (file)
index 0000000..f1aa05e
--- /dev/null
@@ -0,0 +1,31 @@
+/* $Id$
+ * Include file for client fuse interface operation "truncate" for libcaptive
+ * Copyright (C) 2005 Jan Kratochvil <project-captive@jankratochvil.net>
+ * 
+ * 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; exactly version 2 of June 1991 is required
+ * 
+ * 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; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+
+#ifndef _CAPTIVE_CLIENT_FUSE_OP_TRUNCATE_H
+#define _CAPTIVE_CLIENT_FUSE_OP_TRUNCATE_H 1
+
+
+#include <fuse.h>
+#include <sys/stat.h>
+
+
+int op_truncate(const char *path,off_t size);
+
+
+#endif /* _CAPTIVE_CLIENT_FUSE_OP_TRUNCATE_H */
diff --git a/src/client/fuse/op_unlink.c b/src/client/fuse/op_unlink.c
new file mode 100644 (file)
index 0000000..d100ee2
--- /dev/null
@@ -0,0 +1,51 @@
+/* $Id$
+ * Client fuse interface operation "unlink" for libcaptive
+ * Copyright (C) 2005 Jan Kratochvil <project-captive@jankratochvil.net>
+ * 
+ * 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; exactly version 2 of June 1991 is required
+ * 
+ * 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; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+
+#include "config.h"
+
+#include <glib/gmessages.h>
+#include <fuse.h>
+#include <errno.h>
+#include <captive/client-file.h>
+#include <captive/macros.h>
+
+#include "op_unlink.h" /* self */
+#include "main.h"
+#include "gnomevfsresult.h"
+
+
+int op_unlink(const char *path)
+{
+CaptiveFileObject *captive_file_object;
+GnomeVFSResult errvfsresult;
+
+       g_return_val_if_fail(path!=NULL,-EINVAL);
+
+       if (GNOME_VFS_OK!=(errvfsresult=captive_file_new_open(&captive_file_object,capfuse_captive_vfs_object,path,
+                       GNOME_VFS_OPEN_WRITE|GNOME_VFS_OPEN_RANDOM)))
+               return -gnomevfsresult_to_errno(errvfsresult);
+
+       errvfsresult=captive_file_remove(captive_file_object);
+
+       g_object_unref(captive_file_object);
+
+       if (GNOME_VFS_OK!=errvfsresult)
+               return -gnomevfsresult_to_errno(errvfsresult);
+       return 0;
+}
diff --git a/src/client/fuse/op_unlink.h b/src/client/fuse/op_unlink.h
new file mode 100644 (file)
index 0000000..5634309
--- /dev/null
@@ -0,0 +1,31 @@
+/* $Id$
+ * Include file for client fuse interface operation "unlink" for libcaptive
+ * Copyright (C) 2005 Jan Kratochvil <project-captive@jankratochvil.net>
+ * 
+ * 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; exactly version 2 of June 1991 is required
+ * 
+ * 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; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+
+#ifndef _CAPTIVE_CLIENT_FUSE_OP_UNLINK_H
+#define _CAPTIVE_CLIENT_FUSE_OP_UNLINK_H 1
+
+
+#include <fuse.h>
+#include <sys/stat.h>
+
+
+int op_unlink(const char *path);
+
+
+#endif /* _CAPTIVE_CLIENT_FUSE_OP_UNLINK_H */
diff --git a/src/client/fuse/op_utime.c b/src/client/fuse/op_utime.c
new file mode 100644 (file)
index 0000000..e106bbd
--- /dev/null
@@ -0,0 +1,67 @@
+/* $Id$
+ * Client fuse interface operation "utime" for libcaptive
+ * Copyright (C) 2005 Jan Kratochvil <project-captive@jankratochvil.net>
+ * 
+ * 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; exactly version 2 of June 1991 is required
+ * 
+ * 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; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+
+#include "config.h"
+
+#include <glib/gmessages.h>
+#include <fuse.h>
+#include <errno.h>
+#include <captive/client-file.h>
+#include <sys/stat.h>
+#include <captive/macros.h>
+
+#include "op_utime.h"  /* self */
+#include "main.h"
+#include "gnomevfsresult.h"
+#include "gnomevfsfileinfo.h"
+
+
+int op_utime(const char *path,struct utimbuf *buf)
+{
+CaptiveFileObject *captive_file_object;
+GnomeVFSResult errvfsresult;
+GnomeVFSFileInfo file_info;
+
+       g_return_val_if_fail(path!=NULL,-EINVAL);
+       g_return_val_if_fail(buf!=NULL,-EINVAL);
+       g_return_val_if_fail(buf->actime!=0,-EINVAL);
+       g_return_val_if_fail(buf->modtime!=0,-EINVAL);
+
+       if (GNOME_VFS_OK!=(errvfsresult=captive_file_new_open(&captive_file_object,capfuse_captive_vfs_object,path,
+                       GNOME_VFS_OPEN_WRITE|GNOME_VFS_OPEN_RANDOM)))
+               return -gnomevfsresult_to_errno(errvfsresult);
+
+       file_info.valid_fields=0
+                       |GNOME_VFS_FILE_INFO_FIELDS_ATIME
+                       |GNOME_VFS_FILE_INFO_FIELDS_MTIME;
+       file_info.atime=buf->actime;
+       file_info.mtime=buf->modtime;
+       /* It is probably not GnomeVFS compliant but still libcaptive compatible.
+        * GnomeVFS looks as assuming all the three fields set.
+        * GnomeVFS also does not check 'valid_fields' at all.
+        */
+       file_info.ctime=0;      /* Just sanity for sure. */
+       errvfsresult=captive_file_file_info_set(captive_file_object,&file_info,GNOME_VFS_SET_FILE_INFO_TIME);
+
+       g_object_unref(captive_file_object);
+       if (GNOME_VFS_OK!=errvfsresult)
+               return -gnomevfsresult_to_errno(errvfsresult);
+
+       return 0;
+}
diff --git a/src/client/fuse/op_utime.h b/src/client/fuse/op_utime.h
new file mode 100644 (file)
index 0000000..40861d9
--- /dev/null
@@ -0,0 +1,31 @@
+/* $Id$
+ * Include file for client fuse interface operation "utime" for libcaptive
+ * Copyright (C) 2005 Jan Kratochvil <project-captive@jankratochvil.net>
+ * 
+ * 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; exactly version 2 of June 1991 is required
+ * 
+ * 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; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+
+#ifndef _CAPTIVE_CLIENT_FUSE_OP_UTIME_H
+#define _CAPTIVE_CLIENT_FUSE_OP_UTIME_H 1
+
+
+#include <fuse.h>
+#include <sys/stat.h>
+
+
+int op_utime(const char *path,struct utimbuf *buf);
+
+
+#endif /* _CAPTIVE_CLIENT_FUSE_OP_UTIME_H */
diff --git a/src/client/fuse/op_write.c b/src/client/fuse/op_write.c
new file mode 100644 (file)
index 0000000..5be8f2c
--- /dev/null
@@ -0,0 +1,54 @@
+/* $Id$
+ * Client fuse interface operation "write" for libcaptive
+ * Copyright (C) 2005 Jan Kratochvil <project-captive@jankratochvil.net>
+ * 
+ * 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; exactly version 2 of June 1991 is required
+ * 
+ * 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; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+
+#include "config.h"
+
+#include <glib/gmessages.h>
+#include <fuse.h>
+#include <errno.h>
+#include <captive/client-file.h>
+
+#include "op_write.h"  /* self */
+#include "main.h"
+#include "gnomevfsresult.h"
+
+
+int op_write(const char *path,const char *buf,size_t size,off_t off,struct fuse_file_info *fi)
+{
+CaptiveFileObject *captive_file_object;
+GnomeVFSResult errvfsresult;
+GnomeVFSFileSize bytes_written;
+
+       g_return_val_if_fail(path!=NULL,-EINVAL);
+       g_return_val_if_fail(buf!=NULL,-EINVAL);
+       g_return_val_if_fail(size>0,-EINVAL);
+       g_return_val_if_fail(off>=0,-EINVAL);
+       g_return_val_if_fail(fi!=NULL,-EINVAL);
+
+       captive_file_object=(gpointer)fi->fh;
+       g_return_val_if_fail(CAPTIVE_FILE_IS_OBJECT(captive_file_object),-EINVAL);
+
+       if (GNOME_VFS_OK!=(errvfsresult=captive_file_seek(captive_file_object,GNOME_VFS_SEEK_START,off)))
+               return -gnomevfsresult_to_errno(errvfsresult);
+
+       if (GNOME_VFS_OK!=(errvfsresult=captive_file_write(captive_file_object,buf,size,&bytes_written)))
+               return -gnomevfsresult_to_errno(errvfsresult);
+
+       return bytes_written;
+}
diff --git a/src/client/fuse/op_write.h b/src/client/fuse/op_write.h
new file mode 100644 (file)
index 0000000..47595d2
--- /dev/null
@@ -0,0 +1,30 @@
+/* $Id$
+ * Include file for client fuse interface operation "write" for libcaptive
+ * Copyright (C) 2005 Jan Kratochvil <project-captive@jankratochvil.net>
+ * 
+ * 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; exactly version 2 of June 1991 is required
+ * 
+ * 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; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+
+#ifndef _CAPTIVE_CLIENT_FUSE_OP_WRITE_H
+#define _CAPTIVE_CLIENT_FUSE_OP_WRITE_H 1
+
+
+#include <fuse.h>
+
+
+int op_write(const char *path,const char *buf,size_t size,off_t off,struct fuse_file_info *fi);
+
+
+#endif /* _CAPTIVE_CLIENT_FUSE_OP_WRITE_H */