diff options
author | Stefan Siegl <stesie@brokenpipe.de> | 2005-03-20 13:21:30 +0000 |
---|---|---|
committer | Stefan Siegl <stesie@brokenpipe.de> | 2005-03-20 13:21:30 +0000 |
commit | 5eb1c783eabf69e5f2fbf14cdd728bcd069f9df1 (patch) | |
tree | b1fe0b931b863bbcb26a2c4e175a286b30f91191 | |
parent | 7d6b660db1987d120845d88f812728e9edbe6773 (diff) |
introducing autoconf/automake cruft.
-rw-r--r-- | .cvsignore | 18 | ||||
-rw-r--r-- | AUTHORS | 1 | ||||
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | Makefile | 37 | ||||
-rw-r--r-- | Makefile.am | 18 | ||||
-rw-r--r-- | NEWS | 1 | ||||
-rw-r--r-- | README | 0 | ||||
-rwxr-xr-x | autogen.sh | 27 | ||||
-rw-r--r-- | config.h | 15 | ||||
-rw-r--r-- | configure.ac | 43 | ||||
-rw-r--r-- | example/.cvsignore | 8 | ||||
-rw-r--r-- | example/Makefile.am | 9 | ||||
-rw-r--r-- | example/fusexmp.c | 342 | ||||
-rw-r--r-- | example/hello.c | 89 | ||||
-rw-r--r-- | example/null.c | 79 | ||||
-rw-r--r-- | inode.c | 114 |
16 files changed, 640 insertions, 166 deletions
diff --git a/.cvsignore b/.cvsignore new file mode 100644 index 000000000..2c385660f --- /dev/null +++ b/.cvsignore @@ -0,0 +1,18 @@ +*.lo +.deps +Makefile +Makefile.in +aclocal.m4 +libtool +stamp-h +stamp-h.in +autom4te.cache +autoscan.log +config.h +config.h.in +config.h.in~ +config.log +config.status +configure +.libs +libfuse.la diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 000000000..68accc77c --- /dev/null +++ b/AUTHORS @@ -0,0 +1 @@ +Stefan Siegl <ssiegl@gmx.de> diff --git a/ChangeLog b/ChangeLog new file mode 100644 index 000000000..bf8f31c95 --- /dev/null +++ b/ChangeLog @@ -0,0 +1,5 @@ +#! /bin/sh +# ChangeLog is more or less available through CVS revision history +# there is no separate file telling what was changed line by line ... + +exec lynx "http://cvs.berlios.de/cgi-bin/viewcvs.cgi/cvsfs4hurd/cvsfs/" diff --git a/Makefile b/Makefile deleted file mode 100644 index d3af87f9f..000000000 --- a/Makefile +++ /dev/null @@ -1,37 +0,0 @@ -########################################################### -# Makefile -# -# Copyright 2004, Stefan Siegl <ssiegl@gmx.de>, Germany -# -# This is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Publice License, -# version 2 or any later. The license is contained in the COPYING -# file that comes with the fuse4hurd distribution. -# -# Makefile to compile fuse4hurd library -#/ - -CFLAGS=-D_FILE_OFFSET_BITS=64 -DHAVE_CONFIG_H -D_GNU_SOURCE -Wall -ggdb -LDFLAGS=$(CFLAGS) - -OBJS=main.o netfs.o node.o netnode.o - -all: libfuse.a - make -C example all - -clean: - rm -f libfuse.a - rm -f $OBJS - -libfuse.a: $(OBJS) - ar rcsv $@ $(OBJS) - -%.d:%.c - $(CC) -MM -I. $(CFLAGS) $< > .$@.dep - sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < .$@.dep > $@ - rm -f .$@.dep - --include $(OBJS:.o=.d) - -.c.o: - $(CC) -I. $(CFLAGS) -c $<
\ No newline at end of file diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 000000000..04a193ad3 --- /dev/null +++ b/Makefile.am @@ -0,0 +1,18 @@ +# Makefile.am +# Used by automake and configure to create Makefile. +# +# Copyright (C) 2005 Stefan Siegl <ssiegl@gmx.de>, Germany + +SUBDIRS = example + +lib_LTLIBRARIES = libfuse.la + +libfuse_la_SOURCES = \ + fuse.h \ + fuse_i.h \ + main.c \ + netfs.c \ + netnode.c \ + node.c + +libfuse_la_LDFLAGS = -version-number 0:0:1 @@ -0,0 +1 @@ +no news is good news. diff --git a/autogen.sh b/autogen.sh new file mode 100755 index 000000000..64075d725 --- /dev/null +++ b/autogen.sh @@ -0,0 +1,27 @@ +#!/bin/sh +AUTOMAKE_FLAGS="$AUTOMAKE_FLAGS -a " #- automatically add missing files + +echo "Running aclocal $ACLOCAL_FLAGS" +aclocal $ACLOCAL_FLAGS || exit 1 + +echo "Running autoconf $AUTOCONF_FLAGS" +autoconf $AUTOCONF_FLAGS || exit 1 + +if grep "A[MC]_CONFIG_HEADER" configure.ac >/dev/null; then + echo "Running autoheader" + autoheader || exit 1 +fi + +if [ -f Makefile.am ]; then + echo "Running automake $AUTOMAKE_FLAGS" + automake $AUTOMAKE_FLAGS || exit 1 +fi + +if grep "AM_PROG_LIBTOOL" configure.ac >/dev/null; then + echo "Running libtoolize" + libtoolize || exit 1 +fi + +./configure "$@" && ( echo ; echo "Now type \`make' to compile." ) + + diff --git a/config.h b/config.h deleted file mode 100644 index e1b75a69a..000000000 --- a/config.h +++ /dev/null @@ -1,15 +0,0 @@ -/********************************************************** - * config.h - * - * Copyright 2004, Stefan Siegl <ssiegl@gmx.de>, Germany - * - * This is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Publice License, - * version 2 or any later. The license is contained in the COPYING - * file that comes with the fuse4hurd distribution. - * - * pseudo config.h, to be replaced by ./configure script - */ - -#define PACKAGE "fuse4hurd" -#define VERSION "0.1" diff --git a/configure.ac b/configure.ac new file mode 100644 index 000000000..80ba8decc --- /dev/null +++ b/configure.ac @@ -0,0 +1,43 @@ +# -*- Autoconf -*- +# Process this file with autoconf to produce a configure script. +# +# Copyright (C) 2005 by Stefan Siegl <ssiegl@gmx.de>, Germany + +AC_PREREQ(2.59) +AC_INIT(fuse4hurd, 0.1, ssiegl@gmx.de) +AC_REVISION($Revision: 1.1 $) +AC_CONFIG_SRCDIR(main.c) +AM_CONFIG_HEADER(config.h) + +# Initialize automake +AM_INIT_AUTOMAKE(fuse4hurd, 0.1) + +# Checks for programs. +m4_ifdef([LT_INIT], [LT_INIT], [AC_PROG_LIBTOOL]) +AC_PROG_CC +AC_PROG_MAKE_SET + +# compatibility for automake < 1.8 +if test -z "$mkdir_p"; then + mkdir_p="../mkinstalldirs" + AC_SUBST(mkdir_p) +fi + +# Checks for libraries. +AC_CHECK_LIB([threads], [rwlock_init]) +AC_CHECK_LIB([ports], [hurd_ihash_init]) +AC_CHECK_LIB([fshelp], [fshelp_touch]) +AC_CHECK_LIB([iohelp], [iohelp_initialize_conch]) +#AC_CHECK_LIB([netfs], [netfs_startup]) + +LIBS="-lnetfs $LIBS" +CFLAGS="$CFLAGS -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -Wall -W -ggdb" + +# Checks for header files. + +# Checks for typedefs, structures, and compiler characteristics. + +# Checks for library functions. + +AC_CONFIG_FILES([Makefile example/Makefile]) +AC_OUTPUT diff --git a/example/.cvsignore b/example/.cvsignore new file mode 100644 index 000000000..f43f6857a --- /dev/null +++ b/example/.cvsignore @@ -0,0 +1,8 @@ +.deps +Makefile +Makefile.in +fusexmp +hello +null +test +.libs diff --git a/example/Makefile.am b/example/Makefile.am new file mode 100644 index 000000000..510dff604 --- /dev/null +++ b/example/Makefile.am @@ -0,0 +1,9 @@ +## Process this file with automake to produce Makefile.in + +noinst_PROGRAMS = fusexmp null hello + +fusexmp_SOURCES = fusexmp.c +null_SOURCES = null.c +hello_SOURCES = hello.c + +LDADD = ../libfuse.la diff --git a/example/fusexmp.c b/example/fusexmp.c new file mode 100644 index 000000000..a905b584c --- /dev/null +++ b/example/fusexmp.c @@ -0,0 +1,342 @@ +/* + FUSE: Filesystem in Userspace + Copyright (C) 2001-2004 Miklos Szeredi <miklos@szeredi.hu> + + This program can be distributed under the terms of the GNU GPL. + See the file COPYING. +*/ + +#include <config.h> + +#ifdef linux +/* For pread()/pwrite() */ +#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> +#ifdef HAVE_SETXATTR +#include <sys/xattr.h> +#endif + +static int xmp_getattr(const char *path, struct stat *stbuf) +{ + int res; + + res = lstat(path, stbuf); + if(res == -1) + return -errno; + + return 0; +} + +static int xmp_readlink(const char *path, char *buf, size_t size) +{ + int res; + + res = readlink(path, 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) +{ + DIR *dp; + struct dirent *de; + int res = 0; + + dp = opendir(path); + 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) +{ + int res; + + res = mknod(path, mode, rdev); + if(res == -1) + return -errno; + + return 0; +} + +static int xmp_mkdir(const char *path, mode_t mode) +{ + int res; + + res = mkdir(path, mode); + if(res == -1) + return -errno; + + return 0; +} + +static int xmp_unlink(const char *path) +{ + int res; + + res = unlink(path); + if(res == -1) + return -errno; + + return 0; +} + +static int xmp_rmdir(const char *path) +{ + int res; + + res = rmdir(path); + 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) +{ + int res; + + res = chmod(path, mode); + if(res == -1) + return -errno; + + return 0; +} + +static int xmp_chown(const char *path, uid_t uid, gid_t gid) +{ + int res; + + res = lchown(path, uid, gid); + if(res == -1) + return -errno; + + return 0; +} + +static int xmp_truncate(const char *path, off_t size) +{ + int res; + + res = truncate(path, size); + if(res == -1) + return -errno; + + return 0; +} + +static int xmp_utime(const char *path, struct utimbuf *buf) +{ + int res; + + res = utime(path, buf); + if(res == -1) + return -errno; + + return 0; +} + + +static int xmp_open(const char *path, int flags) +{ + int res; + + res = open(path, 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) +{ + int fd; + int res; + + fd = open(path, 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) +{ + int fd; + int res; + + fd = open(path, 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(const char *path, struct statfs *stbuf) +{ + int res; + + res = statfs(path, stbuf); + if(res == -1) + return -errno; + + return 0; +} + +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; +} + +#ifdef HAVE_SETXATTR +/* xattr operations are optional and can safely be left unimplemented */ +static int xmp_setxattr(const char *path, const char *name, const char *value, + size_t size, int flags) +{ + int res = lsetxattr(path, name, value, size, flags); + if(res == -1) + return -errno; + return 0; +} + +static int xmp_getxattr(const char *path, const char *name, char *value, + size_t size) +{ + int res = lgetxattr(path, name, value, size); + if(res == -1) + return -errno; + return res; +} + +static int xmp_listxattr(const char *path, char *list, size_t size) +{ + int res = llistxattr(path, list, size); + if(res == -1) + return -errno; + return res; +} + +static int xmp_removexattr(const char *path, const char *name) +{ + int res = lremovexattr(path, name); + if(res == -1) + return -errno; + return 0; +} +#endif /* HAVE_SETXATTR */ + +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, +#ifdef HAVE_SETXATTR + .setxattr = xmp_setxattr, + .getxattr = xmp_getxattr, + .listxattr = xmp_listxattr, + .removexattr= xmp_removexattr, +#endif +}; + +int main(int argc, char *argv[]) +{ + fuse_main(argc, argv, &xmp_oper); + return 0; +} diff --git a/example/hello.c b/example/hello.c new file mode 100644 index 000000000..040c835ce --- /dev/null +++ b/example/hello.c @@ -0,0 +1,89 @@ +/* + FUSE: Filesystem in Userspace + Copyright (C) 2001-2004 Miklos Szeredi <miklos@szeredi.hu> + + This program can be distributed under the terms of the GNU GPL. + See the file COPYING. +*/ + +#include <fuse.h> +#include <stdio.h> +#include <string.h> +#include <errno.h> +#include <fcntl.h> + +static const char *hello_str = "Hello World!\n"; +static const char *hello_path = "/hello"; + +static int hello_getattr(const char *path, struct stat *stbuf) +{ + int res = 0; + + memset(stbuf, 0, sizeof(struct stat)); + if(strcmp(path, "/") == 0) { + stbuf->st_mode = S_IFDIR | 0755; + stbuf->st_nlink = 2; + } + else if(strcmp(path, hello_path) == 0) { + stbuf->st_mode = S_IFREG | 0444; + stbuf->st_nlink = 1; + stbuf->st_size = strlen(hello_str); + } + else + res = -ENOENT; + + return res; +} + +static int hello_getdir(const char *path, fuse_dirh_t h, fuse_dirfil_t filler) +{ + if(strcmp(path, "/") != 0) + return -ENOENT; + + filler(h, ".", 0); + filler(h, "..", 0); + filler(h, hello_path + 1, 0); + + return 0; +} + +static int hello_open(const char *path, int flags) +{ + if(strcmp(path, hello_path) != 0) + return -ENOENT; + + if((flags & 3) != O_RDONLY) + return -EACCES; + + return 0; +} + +static int hello_read(const char *path, char *buf, size_t size, off_t offset) +{ + size_t len; + if(strcmp(path, hello_path) != 0) + return -ENOENT; + + len = strlen(hello_str); + if (offset < len) { + if (offset + size > len) + size = len - offset; + memcpy(buf, hello_str + offset, size); + } else + size = 0; + + return size; +} + +static struct fuse_operations hello_oper = { + .getattr = hello_getattr, + .getdir = hello_getdir, + .open = hello_open, + .read = hello_read, +}; + +int main(int argc, char *argv[]) +{ + fuse_main(argc, argv, &hello_oper); + return 0; +} diff --git a/example/null.c b/example/null.c new file mode 100644 index 000000000..2eb5c8e3c --- /dev/null +++ b/example/null.c @@ -0,0 +1,79 @@ +/* + FUSE: Filesystem in Userspace + Copyright (C) 2001-2004 Miklos Szeredi <miklos@szeredi.hu> + + This program can be distributed under the terms of the GNU GPL. + See the file COPYING. +*/ + +#include <fuse.h> +#include <string.h> +#include <unistd.h> +#include <time.h> +#include <errno.h> + +#define UNUSED(x) x __attribute__((unused)) + +static int null_getattr(const char *path, struct stat *stbuf) +{ + if(strcmp(path, "/") != 0) + return -ENOENT; + + stbuf->st_mode = S_IFREG | 0644; + stbuf->st_nlink = 1; + stbuf->st_uid = getuid(); + stbuf->st_gid = getgid(); + stbuf->st_size = (1ULL << 32); /* 4G */ + stbuf->st_blocks = 0; + stbuf->st_atime = stbuf->st_mtime = stbuf->st_ctime = time(NULL); + + return 0; +} + +static int null_truncate(const char *path, off_t UNUSED(size)) +{ + if(strcmp(path, "/") != 0) + return -ENOENT; + + return 0; +} + +static int null_open(const char *path, int UNUSED(flags)) +{ + if(strcmp(path, "/") != 0) + return -ENOENT; + + return 0; +} + +static int null_read(const char *path, char *UNUSED(buf), size_t size, + off_t UNUSED(offset)) +{ + if(strcmp(path, "/") != 0) + return -ENOENT; + + return size; +} + +static int null_write(const char *path, const char *UNUSED(buf), size_t size, + off_t UNUSED(offset)) +{ + if(strcmp(path, "/") != 0) + return -ENOENT; + + return size; +} + +static struct fuse_operations null_oper = { + .getattr = null_getattr, + .truncate = null_truncate, + .open = null_open, + .read = null_read, + .write = null_write, +}; + +int main(int argc, char *argv[]) +{ + fuse_main(argc, argv, &null_oper); + return 0; +} diff --git a/inode.c b/inode.c deleted file mode 100644 index 174b1daed..000000000 --- a/inode.c +++ /dev/null @@ -1,114 +0,0 @@ -/********************************************************** - * inode.c - * - * Copyright 2004, Stefan Siegl <ssiegl@gmx.de>, Germany - * - * This is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Publice License, - * version 2 or any later. The license is contained in the COPYING - * file that comes with the fuse4hurd distribution. - * - * handling inode numbers - we need to use right the same inode number to - * a specific file over and over again; we use a hash, mapping from full - * pathnames to the numbers. - */ - -#ifdef HAVE_CONFIG_H -# include <config.h> -#endif - -#include <stdio.h> -#include <error.h> -#include <string.h> -#include <rwlock.h> -#include <hurd/netfs.h> - -#include "fuse_i.h" -#include "fuse.h" - -#define HASH_BUCKETS 256 - -struct hash_element; -static struct hash_element { - ino_t inode; - char *path; - - struct hash_element *next; /* singly linked list */ -} fuse_inode_hash[HASH_BUCKETS] = { 0 }; - -/* rwlock needs to be held when touching either fuse_inode_hash or - * fuse_next_inode variable - */ -struct rwlock fuse_inode_hash_lock = RWLOCK_INITIALIZER; - -/* next inode number that will be assigned - * (fuse_inode_hash_lock must be write locked, when touching this) - */ -ino_t fuse_next_inode = 1; - - - -static int -fuse_inode_hash_value(const char *path) -{ - int hash = 0; - int maxlen = 8; /* use the first 8 chars for hash generation only */ - - while(maxlen -- && *path) - hash += *(path ++); - - return hash % HASH_BUCKETS; -} - - - -ino_t -fuse_lookup_ino(const char *path) -{ - int hash_value = fuse_inode_hash_value(path); - struct hash_element *hash_el; - - rwlock_reader_lock(&fuse_inode_hash_lock); - - hash_el = &fuse_inode_hash[hash_value]; - if(hash_el->path) - do - if(! strcmp(hash_el->path, path)) - { - ino_t inode = hash_el->inode; - rwlock_reader_unlock(&fuse_inode_hash_lock); - - return inode; - } - while((hash_el = hash_el->next)); - - rwlock_reader_unlock(&fuse_inode_hash_lock); - rwlock_writer_lock(&fuse_inode_hash_lock); - - /* unable to find hash element, need to generate a new one */ - if(! hash_el) - hash_el = &fuse_inode_hash[hash_value]; - - if(hash_el->path) - { - struct hash_element *new = malloc(sizeof(*new)); - - if(! new) { - rwlock_writer_lock(&fuse_inode_hash_lock); - return -ENOMEM; /* can't help, sorry. */ - } - - /* enqueue new hash_element */ - new->next = hash_el->next; - hash_el->next = new; - - hash_el = new; - } - - hash_el->name = strdup(path); - { - ino_t inode = hash_el->inode = fuse_next_inode ++; - rwlock_writer_lock(&fuse_inode_hash_lock); - return inode; - } -} |