build with automake
authorMiklos Szeredi <miklos@szeredi.hu>
Wed, 7 Nov 2001 12:09:43 +0000 (12:09 +0000)
committerMiklos Szeredi <miklos@szeredi.hu>
Wed, 7 Nov 2001 12:09:43 +0000 (12:09 +0000)
33 files changed:
.cvsignore
AUTHORS [new file with mode: 0644]
COPYING [new file with mode: 0644]
ChangeLog [new file with mode: 0644]
INSTALL [new file with mode: 0644]
Makefile [deleted file]
Makefile.am [new file with mode: 0644]
NEWS [new file with mode: 0644]
README [new file with mode: 0644]
avfsd.c [deleted file]
configure.in [new file with mode: 0644]
example/.cvsignore [new file with mode: 0644]
example/Makefile.am [new file with mode: 0644]
example/fusexmp.c [new file with mode: 0644]
fusexmp.c [deleted file]
include/.cvsignore [new file with mode: 0644]
kernel/.cvsignore [new file with mode: 0644]
kernel/Makefile [deleted file]
kernel/Makefile.am [new file with mode: 0644]
kernel/dev.c
kernel/dir.c
kernel/file.c
kernel/fuse_i.h
kernel/inode.c
kernel/util.c
lib/.cvsignore [new file with mode: 0644]
lib/Makefile [deleted file]
lib/Makefile.am [new file with mode: 0644]
lib/fuse.c
lib/fuse_i.h
lib/mount.c
makeconf.sh [new file with mode: 0755]
usermux.c [deleted file]

index d6dac71133122da36213b4f9b38741b405b94e3a..993b68fff7ff728f4cb8ca0c27a7acd6102bc169 100644 (file)
@@ -1,2 +1,11 @@
-fusexmp
-avfsd
+Makefile.in
+Makefile
+aclocal.m4
+configure
+install-sh
+mkinstalldirs
+missing
+config.log
+config.h
+config.cache
+config.status
diff --git a/AUTHORS b/AUTHORS
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/COPYING b/COPYING
new file mode 100644 (file)
index 0000000..d60c31a
--- /dev/null
+++ b/COPYING
@@ -0,0 +1,340 @@
+                   GNU GENERAL PUBLIC LICENSE
+                      Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+     59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+                           Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users.  This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it.  (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.)  You can apply it to
+your programs, too.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+  To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+  For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have.  You must make sure that they, too, receive or can get the
+source code.  And you must show them these terms so they know their
+rights.
+
+  We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+  Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software.  If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+  Finally, any free program is threatened constantly by software
+patents.  We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary.  To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+\f
+                   GNU GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License.  The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language.  (Hereinafter, translation is included without limitation in
+the term "modification".)  Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+  1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+  2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) You must cause the modified files to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    b) You must cause any work that you distribute or publish, that in
+    whole or in part contains or is derived from the Program or any
+    part thereof, to be licensed as a whole at no charge to all third
+    parties under the terms of this License.
+
+    c) If the modified program normally reads commands interactively
+    when run, you must cause it, when started running for such
+    interactive use in the most ordinary way, to print or display an
+    announcement including an appropriate copyright notice and a
+    notice that there is no warranty (or else, saying that you provide
+    a warranty) and that users may redistribute the program under
+    these conditions, and telling the user how to view a copy of this
+    License.  (Exception: if the Program itself is interactive but
+    does not normally print such an announcement, your work based on
+    the Program is not required to print an announcement.)
+\f
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+    a) Accompany it with the complete corresponding machine-readable
+    source code, which must be distributed under the terms of Sections
+    1 and 2 above on a medium customarily used for software interchange; or,
+
+    b) Accompany it with a written offer, valid for at least three
+    years, to give any third party, for a charge no more than your
+    cost of physically performing source distribution, a complete
+    machine-readable copy of the corresponding source code, to be
+    distributed under the terms of Sections 1 and 2 above on a medium
+    customarily used for software interchange; or,
+
+    c) Accompany it with the information you received as to the offer
+    to distribute corresponding source code.  (This alternative is
+    allowed only for noncommercial distribution and only if you
+    received the program in object code or executable form with such
+    an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it.  For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable.  However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+\f
+  4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License.  Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+  5. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Program or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+  6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+  7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+\f
+  8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded.  In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+  9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time.  Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation.  If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+  10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission.  For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this.  Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+                           NO WARRANTY
+
+  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+                    END OF TERMS AND CONDITIONS
+\f
+           How to Apply These Terms to Your New Programs
+
+  If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+  To do so, attach the following notices to the program.  It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the program's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    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; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+    Gnomovision version 69, Copyright (C) year  name of author
+    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+    This is free software, and you are welcome to redistribute it
+    under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License.  Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary.  Here is a sample; alter the names:
+
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+  `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+  <signature of Ty Coon>, 1 April 1989
+  Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs.  If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library.  If this is what you want to do, use the GNU Library General
+Public License instead of this License.
diff --git a/ChangeLog b/ChangeLog
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/INSTALL b/INSTALL
new file mode 100644 (file)
index 0000000..b42a17a
--- /dev/null
+++ b/INSTALL
@@ -0,0 +1,182 @@
+Basic Installation
+==================
+
+   These are generic installation instructions.
+
+   The `configure' shell script attempts to guess correct values for
+various system-dependent variables used during compilation.  It uses
+those values to create a `Makefile' in each directory of the package.
+It may also create one or more `.h' files containing system-dependent
+definitions.  Finally, it creates a shell script `config.status' that
+you can run in the future to recreate the current configuration, a file
+`config.cache' that saves the results of its tests to speed up
+reconfiguring, and a file `config.log' containing compiler output
+(useful mainly for debugging `configure').
+
+   If you need to do unusual things to compile the package, please try
+to figure out how `configure' could check whether to do them, and mail
+diffs or instructions to the address given in the `README' so they can
+be considered for the next release.  If at some point `config.cache'
+contains results you don't want to keep, you may remove or edit it.
+
+   The file `configure.in' is used to create `configure' by a program
+called `autoconf'.  You only need `configure.in' if you want to change
+it or regenerate `configure' using a newer version of `autoconf'.
+
+The simplest way to compile this package is:
+
+  1. `cd' to the directory containing the package's source code and type
+     `./configure' to configure the package for your system.  If you're
+     using `csh' on an old version of System V, you might need to type
+     `sh ./configure' instead to prevent `csh' from trying to execute
+     `configure' itself.
+
+     Running `configure' takes awhile.  While running, it prints some
+     messages telling which features it is checking for.
+
+  2. Type `make' to compile the package.
+
+  3. Optionally, type `make check' to run any self-tests that come with
+     the package.
+
+  4. Type `make install' to install the programs and any data files and
+     documentation.
+
+  5. You can remove the program binaries and object files from the
+     source code directory by typing `make clean'.  To also remove the
+     files that `configure' created (so you can compile the package for
+     a different kind of computer), type `make distclean'.  There is
+     also a `make maintainer-clean' target, but that is intended mainly
+     for the package's developers.  If you use it, you may have to get
+     all sorts of other programs in order to regenerate files that came
+     with the distribution.
+
+Compilers and Options
+=====================
+
+   Some systems require unusual options for compilation or linking that
+the `configure' script does not know about.  You can give `configure'
+initial values for variables by setting them in the environment.  Using
+a Bourne-compatible shell, you can do that on the command line like
+this:
+     CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure
+
+Or on systems that have the `env' program, you can do it like this:
+     env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure
+
+Compiling For Multiple Architectures
+====================================
+
+   You can compile the package for more than one kind of computer at the
+same time, by placing the object files for each architecture in their
+own directory.  To do this, you must use a version of `make' that
+supports the `VPATH' variable, such as GNU `make'.  `cd' to the
+directory where you want the object files and executables to go and run
+the `configure' script.  `configure' automatically checks for the
+source code in the directory that `configure' is in and in `..'.
+
+   If you have to use a `make' that does not supports the `VPATH'
+variable, you have to compile the package for one architecture at a time
+in the source code directory.  After you have installed the package for
+one architecture, use `make distclean' before reconfiguring for another
+architecture.
+
+Installation Names
+==================
+
+   By default, `make install' will install the package's files in
+`/usr/local/bin', `/usr/local/man', etc.  You can specify an
+installation prefix other than `/usr/local' by giving `configure' the
+option `--prefix=PATH'.
+
+   You can specify separate installation prefixes for
+architecture-specific files and architecture-independent files.  If you
+give `configure' the option `--exec-prefix=PATH', the package will use
+PATH as the prefix for installing programs and libraries.
+Documentation and other data files will still use the regular prefix.
+
+   In addition, if you use an unusual directory layout you can give
+options like `--bindir=PATH' to specify different values for particular
+kinds of files.  Run `configure --help' for a list of the directories
+you can set and what kinds of files go in them.
+
+   If the package supports it, you can cause programs to be installed
+with an extra prefix or suffix on their names by giving `configure' the
+option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
+
+Optional Features
+=================
+
+   Some packages pay attention to `--enable-FEATURE' options to
+`configure', where FEATURE indicates an optional part of the package.
+They may also pay attention to `--with-PACKAGE' options, where PACKAGE
+is something like `gnu-as' or `x' (for the X Window System).  The
+`README' should mention any `--enable-' and `--with-' options that the
+package recognizes.
+
+   For packages that use the X Window System, `configure' can usually
+find the X include and library files automatically, but if it doesn't,
+you can use the `configure' options `--x-includes=DIR' and
+`--x-libraries=DIR' to specify their locations.
+
+Specifying the System Type
+==========================
+
+   There may be some features `configure' can not figure out
+automatically, but needs to determine by the type of host the package
+will run on.  Usually `configure' can figure that out, but if it prints
+a message saying it can not guess the host type, give it the
+`--host=TYPE' option.  TYPE can either be a short name for the system
+type, such as `sun4', or a canonical name with three fields:
+     CPU-COMPANY-SYSTEM
+
+See the file `config.sub' for the possible values of each field.  If
+`config.sub' isn't included in this package, then this package doesn't
+need to know the host type.
+
+   If you are building compiler tools for cross-compiling, you can also
+use the `--target=TYPE' option to select the type of system they will
+produce code for and the `--build=TYPE' option to select the type of
+system on which you are compiling the package.
+
+Sharing Defaults
+================
+
+   If you want to set default values for `configure' scripts to share,
+you can create a site shell script called `config.site' that gives
+default values for variables like `CC', `cache_file', and `prefix'.
+`configure' looks for `PREFIX/share/config.site' if it exists, then
+`PREFIX/etc/config.site' if it exists.  Or, you can set the
+`CONFIG_SITE' environment variable to the location of the site script.
+A warning: not all `configure' scripts look for a site script.
+
+Operation Controls
+==================
+
+   `configure' recognizes the following options to control how it
+operates.
+
+`--cache-file=FILE'
+     Use and save the results of the tests in FILE instead of
+     `./config.cache'.  Set FILE to `/dev/null' to disable caching, for
+     debugging `configure'.
+
+`--help'
+     Print a summary of the options to `configure', and exit.
+
+`--quiet'
+`--silent'
+`-q'
+     Do not print messages saying which checks are being made.  To
+     suppress all normal output, redirect it to `/dev/null' (any error
+     messages will still be shown).
+
+`--srcdir=DIR'
+     Look for the package's source code in directory DIR.  Usually
+     `configure' can determine that directory automatically.
+
+`--version'
+     Print the version of Autoconf used to generate the `configure'
+     script, and exit.
+
+`configure' also accepts some other, not widely useful, options.
diff --git a/Makefile b/Makefile
deleted file mode 100644 (file)
index 92d91ad..0000000
--- a/Makefile
+++ /dev/null
@@ -1,34 +0,0 @@
-CC = gcc
-CFLAGS = -Wall -g `glib-config --cflags`
-LDFLAGS = `glib-config --libs` -ldl -L ../avfs/libneon/ -L lib
-#LIBXML = -lxml
-LIBXML = -lxmltok -lxmlparse
-LDLIBS = -lneon $(LIBXML) -lfuse -lpthread
-CPPFLAGS = -Iinclude -I ../avfs/include
-
-all: kernel/fuse.o fusexmp avfsd
-
-kernel/fuse.o: FORCE
-       make -C kernel fuse.o
-
-lib/libfuse.a: FORCE
-       make -C lib libfuse.a
-
-lib/libfuse.so: FORCE
-       make -C lib libfuse.so
-
-fusexmp: fusexmp.o lib/libfuse.so
-       gcc $(CFLAGS) $(LDFLAGS) -o fusexmp fusexmp.o $(LDLIBS)
-
-avfsd_objs = usermux.o avfsd.o ../avfs/lib/avfs.o
-avfsd: $(avfsd_objs) lib/libfuse.so
-       gcc $(CFLAGS) $(LDFLAGS) -o avfsd $(avfsd_objs) $(LDLIBS)
-
-clean:
-       make -C kernel clean
-       make -C lib clean
-       rm -f *.o
-       rm -f fusexmp avfsd
-       rm -f *~
-
-FORCE:
diff --git a/Makefile.am b/Makefile.am
new file mode 100644 (file)
index 0000000..e9b161a
--- /dev/null
@@ -0,0 +1,3 @@
+## Process this file with automake to produce Makefile.in
+
+SUBDIRS = kernel lib example
diff --git a/NEWS b/NEWS
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/README b/README
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/avfsd.c b/avfsd.c
deleted file mode 100644 (file)
index c86e831..0000000
--- a/avfsd.c
+++ /dev/null
@@ -1,367 +0,0 @@
-#include <fuse.h>
-#include <virtual.h>
-
-#include <stdio.h>
-#include <unistd.h>
-#include <errno.h>
-#include <fcntl.h>
-
-static int check_cred(struct fuse_cred *cred)
-{
-    if(cred->uid != getuid())
-        return -EACCES;
-    else
-        return 0;
-}
-
-static int avfs_getattr(struct fuse_cred *cred, const char *path,
-                        struct stat *stbuf)
-{
-    int res;
-
-    res = check_cred(cred);
-    if(res)
-        return res;
-
-    res = virt_lstat(path, stbuf);
-    if(res == -1)
-        return -errno;
-
-    return 0;
-}
-
-static int avfs_readlink(struct fuse_cred *cred, const char *path, char *buf,
-                         size_t size)
-{
-    int res;
-
-    res = check_cred(cred);
-    if(res)
-        return res;
-
-    res = virt_readlink(path, buf, size - 1);
-    if(res == -1)
-        return -errno;
-
-    buf[res] = '\0';
-    return 0;
-}
-
-
-static int avfs_getdir(struct fuse_cred *cred, const char *path,
-                       fuse_dirh_t h, fuse_dirfil_t filler)
-{
-    DIR *dp;
-    struct dirent *de;
-    int res;
-
-    res = check_cred(cred);
-    if(res)
-        return res;
-
-    dp = virt_opendir(path);
-    if(dp == NULL)
-        return -errno;
-
-    while((de = virt_readdir(dp)) != NULL) {
-        res = filler(h, de->d_name, de->d_type);
-        if(res != 0)
-            break;
-    }
-
-    virt_closedir(dp);
-    return res;
-}
-
-static int avfs_mknod(struct fuse_cred *cred, const char *path, mode_t mode,
-                      dev_t rdev)
-{
-    int res;
-
-    res = check_cred(cred);
-    if(res)
-        return res;
-
-    res = virt_mknod(path, mode, rdev);
-    if(res == -1)
-        return -errno;
-
-    return 0;
-}
-
-static int avfs_mkdir(struct fuse_cred *cred, const char *path, mode_t mode)
-{
-    int res;
-
-    res = check_cred(cred);
-    if(res)
-        return res;
-
-    res = virt_mkdir(path, mode);
-    if(res == -1)
-        return -errno;
-
-    return 0;
-}
-
-static int avfs_unlink(struct fuse_cred *cred, const char *path)
-{
-    int res;
-
-    res = check_cred(cred);
-    if(res)
-        return res;
-
-    res = virt_unlink(path);
-    if(res == -1)
-        return -errno;
-
-    return 0;
-}
-
-static int avfs_rmdir(struct fuse_cred *cred, const char *path)
-{
-    int res;
-
-    res = check_cred(cred);
-    if(res)
-        return res;
-
-    res = virt_rmdir(path);
-    if(res == -1)
-        return -errno;
-
-    return 0;
-}
-
-static int avfs_symlink(struct fuse_cred *cred, const char *from,
-                        const char *to)
-{
-    int res;
-
-    res = check_cred(cred);
-    if(res)
-        return res;
-
-    res = virt_symlink(from, to);
-    if(res == -1)
-        return -errno;
-
-    return 0;
-}
-
-static int avfs_rename(struct fuse_cred *cred, const char *from,
-                       const char *to)
-{
-    int res;
-
-    res = check_cred(cred);
-    if(res)
-        return res;
-
-    res = virt_rename(from, to);
-    if(res == -1)
-        return -errno;
-
-    return 0;
-}
-
-static int avfs_link(struct fuse_cred *cred, const char *from, const char *to)
-{
-    int res;
-
-    res = check_cred(cred);
-    if(res)
-        return res;
-
-    res = virt_link(from, to);
-    if(res == -1)
-        return -errno;
-
-    return 0;
-}
-
-static int avfs_chmod(struct fuse_cred *cred, const char *path, mode_t mode)
-{
-    int res;
-
-    res = check_cred(cred);
-    if(res)
-        return res;
-
-    res = virt_chmod(path, mode);
-    if(res == -1)
-        return -errno;
-    
-    return 0;
-}
-
-static int avfs_chown(struct fuse_cred *cred, const char *path, uid_t uid,
-                       gid_t gid)
-{
-    int res;
-
-    res = check_cred(cred);
-    if(res)
-        return res;
-
-    res = virt_lchown(path, uid, gid);
-    if(res == -1)
-        return -errno;
-
-    return 0;
-}
-
-static int avfs_truncate(struct fuse_cred *cred, const char *path, off_t size)
-{
-    int res;
-    
-    res = check_cred(cred);
-    if(res)
-        return res;
-
-    res = virt_truncate(path, size);
-    if(res == -1)
-        return -errno;
-
-    return 0;
-}
-
-static int avfs_utime(struct fuse_cred *cred, const char *path,
-                      struct utimbuf *buf)
-{
-    int res;
-    
-    res = check_cred(cred);
-    if(res)
-        return res;
-
-    res = virt_utime(path, buf);
-    if(res == -1)
-        return -errno;
-
-    return 0;
-}
-
-
-static int avfs_open(struct fuse_cred *cred, const char *path, int flags)
-{
-    int res;
-
-    res = check_cred(cred);
-    if(res)
-        return res;
-
-    res = virt_open(path, flags, 0);
-    if(res == -1) 
-        return -errno;
-
-    virt_close(res);
-    return 0;
-}
-
-static int avfs_read(struct fuse_cred *cred, const char *path, char *buf,
-                     size_t size, off_t offset)
-{
-    int fd;
-    int res;
-
-    res = check_cred(cred);
-    if(res)
-        return res;
-
-    fd = virt_open(path, O_RDONLY, 0);
-    if(fd == -1)
-        return -errno;
-
-    res = virt_lseek(fd, offset, SEEK_SET);
-    if(res == -1)
-        res = -errno;
-    else {
-        res = virt_read(fd, buf, size);
-        if(res == -1)
-            res = -errno;
-    }
-    
-    virt_close(fd);
-    return res;
-}
-
-static int avfs_write(struct fuse_cred *cred, const char *path,
-                      const char *buf, size_t size, off_t offset)
-{
-    int fd;
-    int res;
-
-    res = check_cred(cred);
-    if(res)
-        return res;
-
-    fd = virt_open(path, O_WRONLY, 0);
-    if(fd == -1)
-        return -errno;
-
-    res = virt_lseek(fd, offset, SEEK_SET);
-    if(res == -1)
-        res = -errno;
-    else {
-        res = virt_write(fd, buf, size);
-        if(res == -1)
-            res = -errno;
-    }
-    
-    virt_close(fd);
-    return res;
-}
-
-static struct fuse_operations avfs_oper = {
-    getattr:   avfs_getattr,
-    readlink:  avfs_readlink,
-    getdir:     avfs_getdir,
-    mknod:     avfs_mknod,
-    mkdir:     avfs_mkdir,
-    symlink:   avfs_symlink,
-    unlink:    avfs_unlink,
-    rmdir:     avfs_rmdir,
-    rename:     avfs_rename,
-    link:      avfs_link,
-    chmod:     avfs_chmod,
-    chown:     avfs_chown,
-    truncate:  avfs_truncate,
-    utime:     avfs_utime,
-    open:      avfs_open,
-    read:      avfs_read,
-    write:     avfs_write,
-};
-
-
-void avfs_main(struct fuse *fuse)
-{
-    fuse_set_operations(fuse, &avfs_oper);
-    fuse_loop(fuse);
-}
-
-#if 0
-int main(int argc, char *argv[])
-{
-    int res;
-    const char *avfs_dir;
-    struct fuse *fuse;
-
-    if(argc != 2) {
-        fprintf(stderr, "usage: %s mount_dir\n", argv[0]);
-        exit(1);
-    }
-    
-    avfs_dir = argv[1];
-
-    fuse = fuse_new(0);
-    res = fuse_mount(fuse, avfs_dir);
-    if(res == -1)
-        exit(1);
-        
-    avfs_main(fuse);
-
-    return 0;
-}
-#endif
diff --git a/configure.in b/configure.in
new file mode 100644 (file)
index 0000000..df5a457
--- /dev/null
@@ -0,0 +1,34 @@
+AC_INIT(lib/fuse.c)
+AM_INIT_AUTOMAKE(fuse, 1.0)
+AM_CONFIG_HEADER(include/config.h)
+
+AC_PROG_CC
+AC_PROG_RANLIB
+
+CFLAGS="-Wall -W -g -O2"
+
+AC_MSG_CHECKING([kernel source directory])
+kernelsrc=
+AC_ARG_WITH(kernel,
+       [  --with-kernel          Specify location of kernel source ],
+       [kernelsrc="$withval"])
+
+if test -z "$kernelsrc"; then
+       buildlink=/lib/modules/`uname -r`/build
+       if test -e $buildlink; then
+               kernelsrc=`(cd $buildlink; /bin/pwd)`
+       else
+               AC_MSG_RESULT([not found])
+               AC_MSG_ERROR([
+*** Please specify the location of the kernel source with
+*** the '--with-kernel=SRCDIR' option])
+       fi
+fi
+AC_MSG_RESULT([$kernelsrc])
+
+KERNINCLUDE=$kernelsrc/include
+AC_SUBST(KERNINCLUDE)
+
+AC_OUTPUT([Makefile kernel/Makefile lib/Makefile example/Makefile])
+
+
diff --git a/example/.cvsignore b/example/.cvsignore
new file mode 100644 (file)
index 0000000..e440faf
--- /dev/null
@@ -0,0 +1,3 @@
+Makefile.in
+Makefile
+.deps
diff --git a/example/Makefile.am b/example/Makefile.am
new file mode 100644 (file)
index 0000000..0e666b5
--- /dev/null
@@ -0,0 +1,7 @@
+## Process this file with automake to produce Makefile.in
+
+bin_PROGRAMS = fusexmp
+
+fusexmp_SOURCES = fusexmp.c
+
+fusexmp_LDADD = ../lib/libfuse.a
diff --git a/example/fusexmp.c b/example/fusexmp.c
new file mode 100644 (file)
index 0000000..b00039d
--- /dev/null
@@ -0,0 +1,410 @@
+#ifdef linux
+/* For pread()/pwrite() */
+#define _XOPEN_SOURCE 500
+#endif
+
+/* For setgroups() */
+#define _BSD_SOURCE
+
+#include <fuse.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <dirent.h>
+#include <errno.h>
+#include <signal.h>
+#include <utime.h>
+#include <fcntl.h>
+#include <grp.h>
+#include <sys/fsuid.h>
+
+static struct fuse *xmp_fuse;
+
+static int set_creds(struct fuse_cred *cred)
+{
+    int res;
+
+    res = setfsuid(cred->uid);
+    if(res == -1)
+        return -errno;
+
+    res = setfsgid(cred->gid);
+    if(res == -1)
+        return -errno;
+
+    return 0;
+}
+
+static void restore_creds()
+{
+    setfsuid(getuid());
+    setfsgid(getgid());
+}
+
+static int xmp_getattr(struct fuse_cred *cred, const char *path,
+                       struct stat *stbuf)
+{
+    int res;
+
+    res = set_creds(cred);
+    if(res)
+        return res;
+    res = lstat(path, stbuf);
+    restore_creds();
+    if(res == -1)
+        return -errno;
+
+    return 0;
+}
+
+static int xmp_readlink(struct fuse_cred *cred, const char *path, char *buf,
+                        size_t size)
+{
+    int res;
+
+    res = set_creds(cred);
+    if(res)
+        return res;
+    res = readlink(path, buf, size - 1);
+    restore_creds();
+    if(res == -1)
+        return -errno;
+
+    buf[res] = '\0';
+    return 0;
+}
+
+
+static int xmp_getdir(struct fuse_cred *cred, const char *path, fuse_dirh_t h,
+                      fuse_dirfil_t filler)
+{
+    DIR *dp;
+    struct dirent *de;
+    int res;
+
+    res = set_creds(cred);
+    if(res)
+        return res;
+    dp = opendir(path);
+    restore_creds();
+    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(struct fuse_cred *cred, const char *path, mode_t mode,
+                     dev_t rdev)
+{
+    int res;
+
+    res = set_creds(cred);
+    if(res)
+        return res;
+    res = mknod(path, mode, rdev);
+    restore_creds();
+    if(res == -1)
+        return -errno;
+
+    return 0;
+}
+
+static int xmp_mkdir(struct fuse_cred *cred, const char *path, mode_t mode)
+{
+    int res;
+
+    res = set_creds(cred);
+    if(res)
+        return res;
+    res = mkdir(path, mode);
+    restore_creds();
+    if(res == -1)
+        return -errno;
+
+    return 0;
+}
+
+static int xmp_unlink(struct fuse_cred *cred, const char *path)
+{
+    int res;
+
+    res = set_creds(cred);
+    if(res)
+        return res;
+    res = unlink(path);
+    restore_creds();
+    if(res == -1)
+        return -errno;
+
+    return 0;
+}
+
+static int xmp_rmdir(struct fuse_cred *cred, const char *path)
+{
+    int res;
+
+    res = set_creds(cred);
+    if(res)
+        return res;
+    res = rmdir(path);
+    restore_creds();
+    if(res == -1)
+        return -errno;
+
+    return 0;
+}
+
+static int xmp_symlink(struct fuse_cred *cred, const char *from,
+                       const char *to)
+{
+    int res;
+
+    res = set_creds(cred);
+    if(res)
+        return res;
+    res = symlink(from, to);
+    restore_creds();
+    if(res == -1)
+        return -errno;
+
+    return 0;
+}
+
+static int xmp_rename(struct fuse_cred *cred, const char *from, const char *to)
+{
+    int res;
+
+    res = set_creds(cred);
+    if(res)
+        return res;
+    res = rename(from, to);
+    restore_creds();
+    if(res == -1)
+        return -errno;
+
+    return 0;
+}
+
+static int xmp_link(struct fuse_cred *cred, const char *from, const char *to)
+{
+    int res;
+
+    res = set_creds(cred);
+    if(res)
+        return res;
+    res = link(from, to);
+    restore_creds();
+    if(res == -1)
+        return -errno;
+
+    return 0;
+}
+
+static int xmp_chmod(struct fuse_cred *cred, const char *path, mode_t mode)
+{
+    int res;
+
+    res = set_creds(cred);
+    if(res)
+        return res;
+    res = chmod(path, mode);
+    restore_creds();
+    if(res == -1)
+        return -errno;
+    
+    return 0;
+}
+
+static int xmp_chown(struct fuse_cred *cred, const char *path, uid_t uid,
+                     gid_t gid)
+{
+    int res;
+
+    res = set_creds(cred);
+    if(res)
+        return res;
+    res = lchown(path, uid, gid);
+    restore_creds();
+    if(res == -1)
+        return -errno;
+
+    return 0;
+}
+
+static int xmp_truncate(struct fuse_cred *cred, const char *path, off_t size)
+{
+    int res;
+    
+    res = set_creds(cred);
+    if(res)
+        return res;
+    res = truncate(path, size);
+    restore_creds();
+    if(res == -1)
+        return -errno;
+
+    return 0;
+}
+
+static int xmp_utime(struct fuse_cred *cred, const char *path,
+                     struct utimbuf *buf)
+{
+    int res;
+    
+    res = set_creds(cred);
+    if(res)
+        return res;
+    res = utime(path, buf);
+    restore_creds();
+    if(res == -1)
+        return -errno;
+
+    return 0;
+}
+
+
+static int xmp_open(struct fuse_cred *cred, const char *path, int flags)
+{
+    int res;
+
+    res = set_creds(cred);
+    if(res)
+        return res;
+    res = open(path, flags);
+    restore_creds();
+    if(res == -1) 
+        return -errno;
+
+    close(res);
+    return 0;
+}
+
+static int xmp_read(struct fuse_cred *cred, const char *path, char *buf,
+                    size_t size, off_t offset)
+{
+    int fd;
+    int res;
+
+    res = set_creds(cred);
+    if(res)
+        return res;
+    fd = open(path, O_RDONLY);
+    restore_creds();
+    if(fd == -1)
+        return -errno;
+
+    res = pread(fd, buf, size, offset);
+    if(res == -1)
+        res = -errno;
+    
+    close(fd);
+    return res;
+}
+
+static int xmp_write(struct fuse_cred *cred, const char *path, const char *buf,
+                     size_t size, off_t offset)
+{
+    int fd;
+    int res;
+
+    res = set_creds(cred);
+    if(res)
+        return res;
+    fd = open(path, O_WRONLY);
+    restore_creds();
+    if(fd == -1)
+        return -errno;
+
+    res = pwrite(fd, buf, size, offset);
+    if(res == -1)
+        res = -errno;
+    
+    close(fd);
+    return res;
+}
+
+static void exit_handler()
+{
+    exit(0);
+}
+
+static void set_signal_handlers()
+{
+    struct sigaction sa;
+
+    sa.sa_handler = exit_handler;
+    sigemptyset(&(sa.sa_mask));
+    sa.sa_flags = 0;
+
+    if (sigaction(SIGHUP, &sa, NULL) == -1 || 
+       sigaction(SIGINT, &sa, NULL) == -1 || 
+       sigaction(SIGTERM, &sa, NULL) == -1) {
+       
+       perror("Cannot set exit signal handlers");
+        exit(1);
+    }
+
+    sa.sa_handler = SIG_IGN;
+    
+    if(sigaction(SIGPIPE, &sa, NULL) == -1) {
+       perror("Cannot set ignored signals");
+        exit(1);
+    }
+}
+
+static void cleanup()
+{
+    fuse_unmount(xmp_fuse);
+    fuse_destroy(xmp_fuse);
+}
+
+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,
+};
+
+int main(int argc, char *argv[])
+{
+    int res;
+    if(argc != 2) {
+        fprintf(stderr, "usage: %s mount_dir\n", argv[0]);
+        exit(1);
+    }
+
+    set_signal_handlers();
+    atexit(cleanup);
+    setgroups(0, NULL);
+
+    xmp_fuse = fuse_new(0,0);
+    res = fuse_mount(xmp_fuse, argv[1]);
+    if(res == -1)
+        exit(1);
+        
+    fuse_set_operations(xmp_fuse, &xmp_oper);
+
+    fuse_loop(xmp_fuse);
+
+    return 0;
+}
diff --git a/fusexmp.c b/fusexmp.c
deleted file mode 100644 (file)
index b00039d..0000000
--- a/fusexmp.c
+++ /dev/null
@@ -1,410 +0,0 @@
-#ifdef linux
-/* For pread()/pwrite() */
-#define _XOPEN_SOURCE 500
-#endif
-
-/* For setgroups() */
-#define _BSD_SOURCE
-
-#include <fuse.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <dirent.h>
-#include <errno.h>
-#include <signal.h>
-#include <utime.h>
-#include <fcntl.h>
-#include <grp.h>
-#include <sys/fsuid.h>
-
-static struct fuse *xmp_fuse;
-
-static int set_creds(struct fuse_cred *cred)
-{
-    int res;
-
-    res = setfsuid(cred->uid);
-    if(res == -1)
-        return -errno;
-
-    res = setfsgid(cred->gid);
-    if(res == -1)
-        return -errno;
-
-    return 0;
-}
-
-static void restore_creds()
-{
-    setfsuid(getuid());
-    setfsgid(getgid());
-}
-
-static int xmp_getattr(struct fuse_cred *cred, const char *path,
-                       struct stat *stbuf)
-{
-    int res;
-
-    res = set_creds(cred);
-    if(res)
-        return res;
-    res = lstat(path, stbuf);
-    restore_creds();
-    if(res == -1)
-        return -errno;
-
-    return 0;
-}
-
-static int xmp_readlink(struct fuse_cred *cred, const char *path, char *buf,
-                        size_t size)
-{
-    int res;
-
-    res = set_creds(cred);
-    if(res)
-        return res;
-    res = readlink(path, buf, size - 1);
-    restore_creds();
-    if(res == -1)
-        return -errno;
-
-    buf[res] = '\0';
-    return 0;
-}
-
-
-static int xmp_getdir(struct fuse_cred *cred, const char *path, fuse_dirh_t h,
-                      fuse_dirfil_t filler)
-{
-    DIR *dp;
-    struct dirent *de;
-    int res;
-
-    res = set_creds(cred);
-    if(res)
-        return res;
-    dp = opendir(path);
-    restore_creds();
-    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(struct fuse_cred *cred, const char *path, mode_t mode,
-                     dev_t rdev)
-{
-    int res;
-
-    res = set_creds(cred);
-    if(res)
-        return res;
-    res = mknod(path, mode, rdev);
-    restore_creds();
-    if(res == -1)
-        return -errno;
-
-    return 0;
-}
-
-static int xmp_mkdir(struct fuse_cred *cred, const char *path, mode_t mode)
-{
-    int res;
-
-    res = set_creds(cred);
-    if(res)
-        return res;
-    res = mkdir(path, mode);
-    restore_creds();
-    if(res == -1)
-        return -errno;
-
-    return 0;
-}
-
-static int xmp_unlink(struct fuse_cred *cred, const char *path)
-{
-    int res;
-
-    res = set_creds(cred);
-    if(res)
-        return res;
-    res = unlink(path);
-    restore_creds();
-    if(res == -1)
-        return -errno;
-
-    return 0;
-}
-
-static int xmp_rmdir(struct fuse_cred *cred, const char *path)
-{
-    int res;
-
-    res = set_creds(cred);
-    if(res)
-        return res;
-    res = rmdir(path);
-    restore_creds();
-    if(res == -1)
-        return -errno;
-
-    return 0;
-}
-
-static int xmp_symlink(struct fuse_cred *cred, const char *from,
-                       const char *to)
-{
-    int res;
-
-    res = set_creds(cred);
-    if(res)
-        return res;
-    res = symlink(from, to);
-    restore_creds();
-    if(res == -1)
-        return -errno;
-
-    return 0;
-}
-
-static int xmp_rename(struct fuse_cred *cred, const char *from, const char *to)
-{
-    int res;
-
-    res = set_creds(cred);
-    if(res)
-        return res;
-    res = rename(from, to);
-    restore_creds();
-    if(res == -1)
-        return -errno;
-
-    return 0;
-}
-
-static int xmp_link(struct fuse_cred *cred, const char *from, const char *to)
-{
-    int res;
-
-    res = set_creds(cred);
-    if(res)
-        return res;
-    res = link(from, to);
-    restore_creds();
-    if(res == -1)
-        return -errno;
-
-    return 0;
-}
-
-static int xmp_chmod(struct fuse_cred *cred, const char *path, mode_t mode)
-{
-    int res;
-
-    res = set_creds(cred);
-    if(res)
-        return res;
-    res = chmod(path, mode);
-    restore_creds();
-    if(res == -1)
-        return -errno;
-    
-    return 0;
-}
-
-static int xmp_chown(struct fuse_cred *cred, const char *path, uid_t uid,
-                     gid_t gid)
-{
-    int res;
-
-    res = set_creds(cred);
-    if(res)
-        return res;
-    res = lchown(path, uid, gid);
-    restore_creds();
-    if(res == -1)
-        return -errno;
-
-    return 0;
-}
-
-static int xmp_truncate(struct fuse_cred *cred, const char *path, off_t size)
-{
-    int res;
-    
-    res = set_creds(cred);
-    if(res)
-        return res;
-    res = truncate(path, size);
-    restore_creds();
-    if(res == -1)
-        return -errno;
-
-    return 0;
-}
-
-static int xmp_utime(struct fuse_cred *cred, const char *path,
-                     struct utimbuf *buf)
-{
-    int res;
-    
-    res = set_creds(cred);
-    if(res)
-        return res;
-    res = utime(path, buf);
-    restore_creds();
-    if(res == -1)
-        return -errno;
-
-    return 0;
-}
-
-
-static int xmp_open(struct fuse_cred *cred, const char *path, int flags)
-{
-    int res;
-
-    res = set_creds(cred);
-    if(res)
-        return res;
-    res = open(path, flags);
-    restore_creds();
-    if(res == -1) 
-        return -errno;
-
-    close(res);
-    return 0;
-}
-
-static int xmp_read(struct fuse_cred *cred, const char *path, char *buf,
-                    size_t size, off_t offset)
-{
-    int fd;
-    int res;
-
-    res = set_creds(cred);
-    if(res)
-        return res;
-    fd = open(path, O_RDONLY);
-    restore_creds();
-    if(fd == -1)
-        return -errno;
-
-    res = pread(fd, buf, size, offset);
-    if(res == -1)
-        res = -errno;
-    
-    close(fd);
-    return res;
-}
-
-static int xmp_write(struct fuse_cred *cred, const char *path, const char *buf,
-                     size_t size, off_t offset)
-{
-    int fd;
-    int res;
-
-    res = set_creds(cred);
-    if(res)
-        return res;
-    fd = open(path, O_WRONLY);
-    restore_creds();
-    if(fd == -1)
-        return -errno;
-
-    res = pwrite(fd, buf, size, offset);
-    if(res == -1)
-        res = -errno;
-    
-    close(fd);
-    return res;
-}
-
-static void exit_handler()
-{
-    exit(0);
-}
-
-static void set_signal_handlers()
-{
-    struct sigaction sa;
-
-    sa.sa_handler = exit_handler;
-    sigemptyset(&(sa.sa_mask));
-    sa.sa_flags = 0;
-
-    if (sigaction(SIGHUP, &sa, NULL) == -1 || 
-       sigaction(SIGINT, &sa, NULL) == -1 || 
-       sigaction(SIGTERM, &sa, NULL) == -1) {
-       
-       perror("Cannot set exit signal handlers");
-        exit(1);
-    }
-
-    sa.sa_handler = SIG_IGN;
-    
-    if(sigaction(SIGPIPE, &sa, NULL) == -1) {
-       perror("Cannot set ignored signals");
-        exit(1);
-    }
-}
-
-static void cleanup()
-{
-    fuse_unmount(xmp_fuse);
-    fuse_destroy(xmp_fuse);
-}
-
-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,
-};
-
-int main(int argc, char *argv[])
-{
-    int res;
-    if(argc != 2) {
-        fprintf(stderr, "usage: %s mount_dir\n", argv[0]);
-        exit(1);
-    }
-
-    set_signal_handlers();
-    atexit(cleanup);
-    setgroups(0, NULL);
-
-    xmp_fuse = fuse_new(0,0);
-    res = fuse_mount(xmp_fuse, argv[1]);
-    if(res == -1)
-        exit(1);
-        
-    fuse_set_operations(xmp_fuse, &xmp_oper);
-
-    fuse_loop(xmp_fuse);
-
-    return 0;
-}
diff --git a/include/.cvsignore b/include/.cvsignore
new file mode 100644 (file)
index 0000000..0513d7d
--- /dev/null
@@ -0,0 +1,3 @@
+config.h.in
+stamp-h.in
+stamp-h
diff --git a/kernel/.cvsignore b/kernel/.cvsignore
new file mode 100644 (file)
index 0000000..e440faf
--- /dev/null
@@ -0,0 +1,3 @@
+Makefile.in
+Makefile
+.deps
diff --git a/kernel/Makefile b/kernel/Makefile
deleted file mode 100644 (file)
index 4646162..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-CC = gcc
-CFLAGS = -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -pipe
-CPPFLAGS = -I /lib/modules/`uname -r`/build/include/ -D__KERNEL__ -DMODULE -D_LOOSE_KERNEL_NAMES -I../include
-
-
-all: fuse.o
-
-fuse_objs = dev.o inode.o dir.o file.o util.o
-
-fuse.o: $(fuse_objs)
-       ld -r -o fuse.o $(fuse_objs)
-
-
-clean:
-       rm -f *.o
-       rm -f *~
diff --git a/kernel/Makefile.am b/kernel/Makefile.am
new file mode 100644 (file)
index 0000000..cefcf63
--- /dev/null
@@ -0,0 +1,21 @@
+## Process this file with automake to produce Makefile.in
+
+EXTRA_DIST = dev.c dir.c file.c inode.c util.c fuse_i.h
+
+all-local: fuse.o
+
+clean-local:
+       rm -f *.o *.s
+
+CFLAGS = -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -pipe
+CPPFAGS = -I@KERNINCLUDE@ -I../include -D__KERNEL__ -DMODULE -D_LOOSE_KERNEL_NAMES
+
+SUFFIXES = .c .o .s
+
+.c.o:
+       $(CC) $(CFLAGS) $(CPPFAGS) -c $<
+
+fuse_objs = dev.o dir.o file.o inode.o util.o
+
+fuse.o: $(fuse_objs)
+       ld -r -o fuse.o $(fuse_objs)
index 8fdb37f192949dc687f23a1b9bd24bde7dae0dc8..1ff634252e9e30a17919ee4d84f0c368a80991bd 100644 (file)
@@ -8,8 +8,6 @@
 
 #include "fuse_i.h"
 
-#include <linux/module.h>
-#include <linux/kernel.h>
 #include <linux/poll.h>
 #include <linux/proc_fs.h>
 #include <linux/file.h>
index f506816132a05c22f73fe5413227485407ea5a63..a4018ca1e672615e34533075a0a58e41ee3f1e69 100644 (file)
@@ -8,8 +8,6 @@
 
 #include "fuse_i.h"
 
-#include <linux/module.h>
-#include <linux/kernel.h>
 #include <linux/slab.h>
 #include <linux/file.h>
 
@@ -21,6 +19,8 @@ static struct file_operations fuse_dir_operations;
 
 static struct dentry_operations fuse_dentry_opertations;
 
+#define FUSE_REVALIDATE_TIME (HZ / 100)
+
 static void change_attributes(struct inode *inode, struct fuse_attr *attr)
 {
        if(S_ISREG(inode->i_mode) && inode->i_size != attr->size)
@@ -314,7 +314,7 @@ static int fuse_revalidate(struct dentry *entry)
        struct fuse_getattr_out arg;
        
        if(inode->i_ino != FUSE_ROOT_INO && 
-          time_before_eq(jiffies, entry->d_time + HZ / 100))
+          time_before_eq(jiffies, entry->d_time + FUSE_REVALIDATE_TIME))
                return 0;
 
        in.h.opcode = FUSE_GETATTR;
@@ -540,7 +540,10 @@ static int fuse_setattr(struct dentry *entry, struct iattr *attr)
 
 static int fuse_dentry_revalidate(struct dentry *entry, int flags)
 {
-       if(!entry->d_inode || !(flags & LOOKUP_CONTINUE))
+       if(!entry->d_inode)
+               return 0;
+       else if(!(flags & LOOKUP_CONTINUE) && 
+               time_after(jiffies, entry->d_time + FUSE_REVALIDATE_TIME))
                return 0;
        else
                return 1;
index a677d4c1460ec5b10da24bc20f1e0aa2e5f97c0b..a67bdcd117a68ba6621c88f566def61226c8a1db 100644 (file)
@@ -7,8 +7,6 @@
 */
 #include "fuse_i.h"
 
-#include <linux/module.h>
-#include <linux/kernel.h>
 #include <linux/pagemap.h>
 #include <linux/slab.h>
 
index b3f3a9cd77d2314e4eaa531df6cfcae254843a84..9bb48b02b1c798e426367dc2cc3ea30b47907cd0 100644 (file)
@@ -7,6 +7,10 @@
 */
 
 #include <linux/fuse.h>
+
+#include <linux/modversions.h>
+#include <linux/module.h>
+#include <linux/kernel.h>
 #include <linux/fs.h>
 #include <linux/list.h>
 #include <linux/spinlock.h>
index 5fb4a667ee06af9ead9d57bfa0823ab1c51677d1..d4d573aba06c7bb6184f3669b92edf7054c82b0c 100644 (file)
@@ -8,8 +8,6 @@
 
 #include "fuse_i.h"
 
-#include <linux/module.h>
-#include <linux/kernel.h>
 #include <linux/sched.h>
 #include <linux/slab.h>
 #include <linux/file.h>
index 9b7bec173d7ef17663dbcd93b1e1e18c8df8ef75..3e8253dcaba80a8cf300b15b8ae5f67106e9c4aa 100644 (file)
@@ -8,8 +8,6 @@
 
 #include "fuse_i.h"
 
-#include <linux/module.h>
-#include <linux/kernel.h>
 #include <linux/slab.h>
 
 spinlock_t fuse_lock = SPIN_LOCK_UNLOCKED;
diff --git a/lib/.cvsignore b/lib/.cvsignore
new file mode 100644 (file)
index 0000000..e440faf
--- /dev/null
@@ -0,0 +1,3 @@
+Makefile.in
+Makefile
+.deps
diff --git a/lib/Makefile b/lib/Makefile
deleted file mode 100644 (file)
index 88b087a..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-CC = gcc
-CFLAGS = -Wall -W -g `glib-config --cflags` -fPIC
-LDFLAGS = `glib-config --libs`
-CPPFLAGS = -I../include
-
-all: libfuse.a libfuse.so
-
-libfuse_objs = mount.o fuse.o
-
-libfuse.a: $(libfuse_objs)
-       ar cr libfuse.a $(libfuse_objs)
-
-libfuse.so: $(libfuse_objs)
-       gcc -shared -o libfuse.so $(libfuse_objs)
-
-clean:
-       rm -f *.o *.a
-       rm -f *~
diff --git a/lib/Makefile.am b/lib/Makefile.am
new file mode 100644 (file)
index 0000000..98bfedc
--- /dev/null
@@ -0,0 +1,8 @@
+## Process this file with automake to produce Makefile.in
+
+lib_LIBRARIES = libfuse.a
+
+libfuse_a_SOURCES =    \
+       fuse.c          \
+       mount.c         \
+       fuse_i.h
index b12c58d2334fb25d90e2d4efbbcaf783176c5a9c..2776adc4c7cf170ded762738ac60d5b8b24f0ade 100644 (file)
 #include "fuse_i.h"
 #include <linux/fuse.h>
 
-
 #include <string.h>
+#include <stdlib.h>
 #include <unistd.h>
+#include <limits.h>
 #include <errno.h>
-#include <assert.h>
 
+#define FUSE_MAX_PATH 4096
 
-static inline struct node *get_node(fino_t ino)
+static struct node *__get_node(struct fuse *f, fino_t ino)
 {
-    return (struct node *) ((ino << 3) + 0x8000000);
+    size_t hash = ino % f->ino_table_size;
+    struct node *node;
+
+    for(node = f->ino_table[hash]; node != NULL; node = node->ino_next)
+        if(node->ino == ino)
+            return node;
+    
+    return NULL;
 }
 
-static inline fino_t get_ino(struct node *node)
+static struct node *get_node(struct fuse *f, fino_t ino)
 {
-    return (((fino_t) node) - 0x8000000) >> 3;
+    struct node *node = __get_node(f, ino);
+    if(node != NULL)
+        return node;
+    
+    fprintf(stderr, "fuse internal error: inode %lu not found\n", ino);
+    abort();
 }
 
-static guint name_hash(const struct node *node)
+static void hash_ino(struct fuse *f, struct node *node, fino_t ino)
 {
-    return g_str_hash(node->name) ^ node->parent;
+    size_t hash = ino % f->ino_table_size;
+    node->ino = ino;
+    
+    node->ino_next = f->ino_table[hash];
+    f->ino_table[hash] = node;    
 }
 
-static gint name_compare(const struct node *node1, const struct node *node2)
+static void unhash_ino(struct fuse *f, struct node *node)
 {
-    return
-        node1->parent == node2->parent &&
-        strcmp(node1->name, node2->name) == 0;
+    size_t hash = node->ino % f->ino_table_size;
+    struct node **nodep = &f->ino_table[hash];
+
+    for(; *nodep != NULL; nodep = &(*nodep)->ino_next) 
+        if(*nodep == node) {
+            *nodep = node->ino_next;
+            return;
+        }
 }
 
-static int free_node(struct node *node)
+static fino_t get_ino(struct node *node)
 {
-    g_free(node->name);
-    g_free(node);
-    return 1;
+    return node->ino;
+}
+
+static fino_t next_ino(struct fuse *f)
+{
+    while(f->ctr == 0 || __get_node(f, f->ctr) != NULL)
+        f->ctr++;
+    
+    return f->ctr;
+}
+
+static void free_node(struct node *node)
+{
+    free(node->name);
+    free(node);
+}
+
+static unsigned int name_hash(struct fuse *f, fino_t parent, const char *name)
+{
+    unsigned int hash = *name;
+
+    if(hash)
+        for(name += 1; *name != '\0'; name++)
+            hash = (hash << 5) - hash + *name;
+
+    return (hash + parent) % f->name_table_size;
 }
 
 static struct node *lookup_node(struct fuse *f, fino_t parent,
                                 const char *name)
 {
-    struct node tmp;
+    size_t hash = name_hash(f, parent, name);
+    struct node *node;
 
-    tmp.name = (char *) name;
-    tmp.parent = parent;
+    for(node = f->name_table[hash]; node != NULL; node = node->name_next)
+        if(node->parent == parent && strcmp(node->name, name) == 0)
+            return node;
 
-    return g_hash_table_lookup(f->nametab, &tmp);
+    return NULL;
 }
 
-static void hash_node(struct fuse *f, struct node *node, fino_t parent,
+static void hash_name(struct fuse *f, struct node *node, fino_t parent,
                       const char *name)
 {
-    node->name = g_strdup(name);
+    size_t hash = name_hash(f, parent, name);
     node->parent = parent;
-    g_hash_table_insert(f->nametab, node, node);
+    node->name = strdup(name);
+    node->name_next = f->name_table[hash];
+    f->name_table[hash] = node;    
 }
 
-static void unhash_node(struct fuse *f, struct node *node)
+static void unhash_name(struct fuse *f, struct node *node)
 {
     if(node->name != NULL) {
-        g_hash_table_remove(f->nametab, node);
-        g_free(node->name);
-        node->parent = 0;
-        node->name = NULL;
+        size_t hash = name_hash(f, node->parent, node->name);
+        struct node **nodep = &f->name_table[hash];
+        
+        for(; *nodep != NULL; nodep = &(*nodep)->name_next)
+            if(*nodep == node) {
+                *nodep = node->name_next;
+                node->name_next = NULL;
+                free(node->name);
+                node->name = NULL;
+                node->parent = 0;
+                return;
+            }
+        fprintf(stderr, "fuse internal error: unable to unhash node: %lu\n",
+                node->ino);
+        abort();
     }
 }
 
@@ -90,13 +150,14 @@ static fino_t find_node(struct fuse *f, fino_t parent, char *name,
         if(node->mode == mode && node->rdev == rdev)
             goto out;
         
-        unhash_node(f, node);
+        unhash_name(f, node);
     }
 
-    node = g_new0(struct node, 1);
+    node = (struct node *) calloc(1, sizeof(struct node));
     node->mode = mode;
-    node->rdev = rdev;    
-    hash_node(f, node, parent, name);
+    node->rdev = rdev;
+    hash_ino(f, node, next_ino(f));
+    hash_name(f, node, parent, name);
 
   out:
     node->version = version;
@@ -118,52 +179,60 @@ static fino_t find_node_dir(struct fuse *f, fino_t parent, char *name)
         return (fino_t) -1;
 }
 
-static char *get_path(struct fuse *f, fino_t ino)
+static char *add_name(char *buf, char *s, const char *name)
 {
-    GString *s;
-    char *ss;
-
-    s = g_string_new("");
-    if(ino == FUSE_ROOT_INO)
-        g_string_prepend_c(s, '/');
-    else {
-        struct node *node;
-        pthread_mutex_lock(&f->lock);
-        for(; ino != FUSE_ROOT_INO; ino = node->parent) {
-            node = get_node(ino);
-            if(node->name == NULL) {
-                pthread_mutex_unlock(&f->lock);
-                g_string_free(s, TRUE);
-                return NULL;
-            }
-            g_string_prepend(s, node->name);
-            g_string_prepend_c(s, '/');
-        }
-        pthread_mutex_unlock(&f->lock);
+    size_t len = strlen(name);
+    s -= len;
+    if(s <= buf) {
+        fprintf(stderr, "fuse: path too long: ...%s\n", s + len);
+        return NULL;
     }
+    strncpy(s, name, len);
+    s--;
+    *s = '/';
 
-    ss = s->str;
-    g_string_free(s, FALSE);
-    
-    return ss;
+    return s;
 }
 
 static char *get_path_name(struct fuse *f, fino_t ino, const char *name)
 {
-    char *path2;
-    char *path;
+    char buf[FUSE_MAX_PATH];
+    char *s = buf + FUSE_MAX_PATH - 1;
+    struct node *node;
     
-    if(ino == FUSE_ROOT_INO)
-        return g_strconcat("/", name, NULL);
+    *s = '\0';
+
+    if(name != NULL) {
+        s = add_name(buf, s, name);
+        if(s == NULL)
+            return NULL;
+    }
 
-    path = get_path(f, ino);
-    if(path == NULL)
+    pthread_mutex_lock(&f->lock);
+    for(node = get_node(f, ino); node->ino != FUSE_ROOT_INO;
+        node = get_node(f, node->parent)) {
+        if(node->name == NULL) {
+            s = NULL;
+            break;
+        }
+        
+        s = add_name(buf, s, node->name);
+        if(s == NULL)
+            break;
+    }
+    pthread_mutex_unlock(&f->lock);
+
+    if(s == NULL) 
         return NULL;
-    
-    path2 = g_strconcat(path, "/", name, NULL);
-    g_free(path);
+    else if(*s == '\0')
+        return strdup("/");
+    else
+        return strdup(s);
+}
 
-    return path2;
+static char *get_path(struct fuse *f, fino_t ino)
+{
+    return get_path_name(f, ino, NULL);
 }
 
 static void destroy_node(struct fuse *f, fino_t ino, int version)
@@ -171,9 +240,10 @@ static void destroy_node(struct fuse *f, fino_t ino, int version)
     struct node *node;
 
     pthread_mutex_lock(&f->lock);
-    node = get_node(ino);
+    node = get_node(f, ino);
     if(node->version == version) {
-        unhash_node(f, node);
+        unhash_name(f, node);
+        unhash_ino(f, node);
         free_node(node);
     }
     pthread_mutex_unlock(&f->lock);
@@ -186,8 +256,12 @@ static void remove_node(struct fuse *f, fino_t dir, const char *name)
 
     pthread_mutex_lock(&f->lock);
     node = lookup_node(f, dir, name);
-    assert(node != NULL);
-    unhash_node(f, node);
+    if(node == NULL) {
+        fprintf(stderr, "fuse internal error: unable to remove node %lu/%s\n",
+                dir, name);
+        abort();
+    }
+    unhash_name(f, node);
     pthread_mutex_unlock(&f->lock);
 }
 
@@ -200,13 +274,17 @@ static void rename_node(struct fuse *f, fino_t olddir, const char *oldname,
     pthread_mutex_lock(&f->lock);
     node  = lookup_node(f, olddir, oldname);
     newnode  = lookup_node(f, newdir, newname);
-    assert(node != NULL);
+    if(node == NULL) {
+        fprintf(stderr, "fuse internal error: unable to rename node %lu/%s\n",
+                olddir, oldname);
+        abort();
+    }
 
     if(newnode != NULL)
-        unhash_node(f, newnode);
+        unhash_name(f, newnode);
         
-    unhash_node(f, node);
-    hash_node(f, node, newdir, newname);
+    unhash_name(f, node);
+    hash_name(f, node, newdir, newname);
     pthread_mutex_unlock(&f->lock);
 }
 
@@ -262,7 +340,7 @@ static void send_reply(struct fuse *f, struct fuse_in_header *in, int error,
         argsize = 0;
 
     outsize = sizeof(struct fuse_out_header) + argsize;
-    outbuf = (char *) g_malloc(outsize);
+    outbuf = (char *) malloc(outsize);
     out = (struct fuse_out_header *) outbuf;
     out->unique = in->unique;
     out->error = error;
@@ -277,7 +355,7 @@ static void send_reply(struct fuse *f, struct fuse_in_header *in, int error,
     if(res == -1)
         perror("writing fuse device");
 
-    g_free(outbuf);
+    free(outbuf);
 }
 
 static void fill_cred(struct fuse_in_header *in, struct fuse_cred *cred)
@@ -301,7 +379,7 @@ static void do_lookup(struct fuse *f, struct fuse_in_header *in, char *name)
         res = -ENOSYS;
         if(f->op.getattr)
             res = f->op.getattr(&cred, path, &buf);
-        g_free(path);
+        free(path);
     }
     if(res == 0) {
         convert_stat(&buf, &arg.attr);
@@ -331,7 +409,7 @@ static void do_getattr(struct fuse *f, struct fuse_in_header *in)
         res = -ENOSYS;
         if(f->op.getattr)
             res = f->op.getattr(&cred, path, &buf);
-        g_free(path);
+        free(path);
     }
     if(res == 0) 
         convert_stat(&buf, &arg.attr);
@@ -386,7 +464,7 @@ static void do_setattr(struct fuse *f, struct fuse_in_header *in,
             if(f->op.utime)
                 res = f->op.utime(&cred, path, &buf);
         }
-        g_free(path);
+        free(path);
     }
     send_reply(f, in, res, &outarg, sizeof(outarg));
 }
@@ -405,7 +483,7 @@ static void do_readlink(struct fuse *f, struct fuse_in_header *in)
         res = -ENOSYS;
         if(f->op.readlink)
             res = f->op.readlink(&cred, path, link, sizeof(link));
-        g_free(path);
+        free(path);
     }
     link[PATH_MAX] = '\0';
     send_reply(f, in, res, link, !res ? strlen(link) : 0);
@@ -429,7 +507,7 @@ static void do_getdir(struct fuse *f, struct fuse_in_header *in)
         res = -ENOSYS;
         if(f->op.getdir)
             res = f->op.getdir(&cred, path, &dh, (fuse_dirfil_t) fill_dir);
-        g_free(path);
+        free(path);
     }
     fflush(dh.fp);
     arg.fd = fileno(dh.fp);
@@ -456,7 +534,7 @@ static void do_mknod(struct fuse *f, struct fuse_in_header *in,
             if(res == 0)
                 res = f->op.getattr(&cred, path, &buf);
         }
-        g_free(path);
+        free(path);
     }
     if(res == 0) {
         convert_stat(&buf, &outarg.attr);
@@ -481,7 +559,7 @@ static void do_mkdir(struct fuse *f, struct fuse_in_header *in,
         res = -ENOSYS;
         if(f->op.mkdir)
             res = f->op.mkdir(&cred, path, inarg->mode);
-        g_free(path);
+        free(path);
     }
     send_reply(f, in, res, NULL, 0);
 }
@@ -505,7 +583,7 @@ static void do_remove(struct fuse *f, struct fuse_in_header *in, char *name)
             if(f->op.rmdir)
                 res = f->op.rmdir(&cred, path);
         }
-        g_free(path);
+        free(path);
     }
     if(res == 0)
         remove_node(f, in->ino, name);
@@ -526,7 +604,7 @@ static void do_symlink(struct fuse *f, struct fuse_in_header *in, char *name,
         res = -ENOSYS;
         if(f->op.symlink)
             res = f->op.symlink(&cred, link, path);
-        g_free(path);
+        free(path);
     }
     send_reply(f, in, res, NULL, 0);
 }
@@ -554,9 +632,9 @@ static void do_rename(struct fuse *f, struct fuse_in_header *in,
                 res = f->op.rename(&cred, oldpath, newpath);
             if(res == 0)
                 rename_node(f, olddir, oldname, newdir, newname);
-            g_free(newpath);
+            free(newpath);
         }
-        g_free(oldpath);
+        free(oldpath);
     }
     send_reply(f, in, res, NULL, 0);   
 }
@@ -578,9 +656,9 @@ static void do_link(struct fuse *f, struct fuse_in_header *in,
             res = -ENOSYS;
             if(f->op.link)
                 res = f->op.link(&cred, oldpath, newpath);
-            g_free(newpath);
+            free(newpath);
         }
-        g_free(oldpath);
+        free(oldpath);
     }
     send_reply(f, in, res, NULL, 0);   
 }
@@ -599,7 +677,7 @@ static void do_open(struct fuse *f, struct fuse_in_header *in,
         res = -ENOSYS;
         if(f->op.open)
             res = f->op.open(&cred, path, arg->flags);
-        g_free(path);
+        free(path);
     }
     send_reply(f, in, res, NULL, 0);
 }
@@ -609,17 +687,18 @@ static void do_read(struct fuse *f, struct fuse_in_header *in,
 {
     int res;
     char *path;
-    char *buf = g_malloc(arg->size);
+    char *buf = (char *) malloc(arg->size);
     size_t size;
     struct fuse_cred cred;
 
     fill_cred(in, &cred);
+    res = -ENOENT;
     path = get_path(f, in->ino);
     if(path != NULL) {
         res = -ENOSYS;
         if(f->op.read)
             res = f->op.read(&cred, path, buf, arg->size, arg->offset);
-        g_free(path);
+        free(path);
     }
     
     size = 0;
@@ -629,7 +708,7 @@ static void do_read(struct fuse *f, struct fuse_in_header *in,
     }
 
     send_reply(f, in, res, buf, size);
-    g_free(buf);
+    free(buf);
 }
 
 static void do_write(struct fuse *f, struct fuse_in_header *in,
@@ -640,12 +719,13 @@ static void do_write(struct fuse *f, struct fuse_in_header *in,
     struct fuse_cred cred;
 
     fill_cred(in, &cred);
+    res = -ENOENT;
     path = get_path(f, in->ino);
     if(path != NULL) {
         res = -ENOSYS;
         if(f->op.write)
             res = f->op.write(&cred, path, arg->buf, arg->size, arg->offset);
-        g_free(path);
+        free(path);
     }
     
     if(res > 0) {
@@ -751,8 +831,8 @@ static void *do_command(void *data)
             send_reply(f, in, -ENOSYS, NULL, 0);
     }
 
-    g_free(cmd->buf);
-    g_free(cmd);
+    free(cmd->buf);
+    free(cmd);
 
     return NULL;
 }
@@ -791,10 +871,10 @@ void fuse_loop(struct fuse *f)
             continue;
         }
 
-        cmd = g_new0(struct cmd, 1);
+        cmd = (struct cmd *) malloc(sizeof(struct cmd));
         cmd->f = f;
         cmd->buflen = res;
-        cmd->buf = g_malloc(cmd->buflen);
+        cmd->buf = (char *) malloc(cmd->buflen);
         memcpy(cmd->buf, inbuf, cmd->buflen);
         
         if(f->flags & FUSE_MULTITHREAD) {
@@ -811,27 +891,42 @@ void fuse_loop(struct fuse *f)
     }
 }
 
-struct fuse *fuse_new(int flags, mode_t root)
+struct fuse *fuse_new(int flags, mode_t rootmode)
 {
-    struct fuse *f = g_new0(struct fuse, 1);
+    struct fuse *f;
+    struct node *root;
 
-    if(!root)
-        root = S_IFDIR;
+    f = (struct fuse *) calloc(1, sizeof(struct fuse));
 
-    if(!S_ISDIR(root) && !S_ISREG(root)) {
-        fprintf(stderr, "Invalid mode for root: 0%o\n", root);
-        root = S_IFDIR;
+    if(!rootmode)
+        rootmode = S_IFDIR;
+
+    if(!S_ISDIR(rootmode) && !S_ISREG(rootmode)) {
+        fprintf(stderr, "Invalid mode for root: 0%o\n", rootmode);
+        rootmode = S_IFDIR;
     }
-    root &= S_IFMT;
+    rootmode &= S_IFMT;
 
     f->flags = flags;
-    f->rootmode = root;
+    f->rootmode = rootmode;
     f->fd = -1;
     f->mnt = NULL;
-    f->nametab = g_hash_table_new((GHashFunc) name_hash,
-                                  (GCompareFunc) name_compare);
+    f->ctr = 0;
+    f->name_table_size = 14057;
+    f->name_table = (struct node **)
+        calloc(1, sizeof(struct node *) * f->name_table_size);
+    f->ino_table_size = 14057;
+    f->ino_table = (struct node **)
+        calloc(1, sizeof(struct node *) * f->ino_table_size);
     pthread_mutex_init(&f->lock, NULL);
 
+    root = (struct node *) calloc(1, sizeof(struct node));
+    root->mode = rootmode;
+    root->rdev = 0;
+    root->name = strdup("/");
+    root->parent = 0;
+    hash_ino(f, root, FUSE_ROOT_INO);
+
     return f;
 }
 
@@ -842,9 +937,18 @@ void fuse_set_operations(struct fuse *f, const struct fuse_operations *op)
 
 void fuse_destroy(struct fuse *f)
 {
+    size_t i;
     close(f->fd);
-    g_hash_table_foreach_remove(f->nametab, (GHRFunc) free_node, NULL);
-    g_hash_table_destroy(f->nametab);
+    for(i = 0; i < f->ino_table_size; i++) {
+        struct node *node;
+        struct node *next;
+        for(node = f->ino_table[i]; node != NULL; node = next) {
+            next = node->ino_next;
+            free_node(node);
+        }
+    }
+    free(f->ino_table);
+    free(f->name_table);
     pthread_mutex_destroy(&f->lock);
-    g_free(f);
+    free(f);
 }
index 6f363d8123a1e492f8a74bfcabfdc385368dc796..263ebe25383f011796c0049054715a20d8e0b1b9 100644 (file)
@@ -7,7 +7,6 @@
 */
 
 #include "fuse.h"
-#include <glib.h>
 #include <stdio.h>
 #include <pthread.h>
 
 typedef unsigned long fino_t;
 
 struct node {
-    char *name;
+    struct node *name_next;
+    struct node *ino_next;
+    fino_t ino;
     fino_t parent;
+    char *name;
     int mode;
     int rdev;
     int version;
@@ -29,7 +31,11 @@ struct fuse {
     mode_t rootmode;
     int fd;
     struct fuse_operations op;
-    GHashTable *nametab;
+    struct node **name_table;
+    size_t name_table_size;
+    struct node **ino_table;
+    size_t ino_table_size;
+    fino_t ctr;
     pthread_mutex_t lock;
 };
 
index 98d9e591fd65c7a15cda2ca2c751e50198a79037..d191a7d0f5a0b5cf0841172e319f148da57354a9 100644 (file)
@@ -10,6 +10,7 @@
 #include <linux/fuse.h>
 
 #include <stdio.h>
+#include <stdlib.h>
 #include <unistd.h>
 #include <string.h>
 #include <fcntl.h>
@@ -116,7 +117,7 @@ int fuse_mount(struct fuse *f, const char *dir)
         return -1;
 
     add_mntent(dev, dir, type);
-    f->mnt = g_strdup(dir);
+    f->mnt = strdup(dir);
     
     return 0;
 }
@@ -137,7 +138,7 @@ int fuse_unmount(struct fuse *f)
     else
         remove_mntent(f->mnt);
 
-    g_free(f->mnt);
+    free(f->mnt);
     f->mnt = NULL;
 
     return res;
diff --git a/makeconf.sh b/makeconf.sh
new file mode 100755 (executable)
index 0000000..4a19b27
--- /dev/null
@@ -0,0 +1,7 @@
+#! /bin/sh
+
+aclocal
+autoheader
+autoconf
+automake -a -c
+./configure
diff --git a/usermux.c b/usermux.c
deleted file mode 100644 (file)
index f2f11f3..0000000
--- a/usermux.c
+++ /dev/null
@@ -1,252 +0,0 @@
-#include <fuse.h>
-
-#include <pthread.h>
-#include <glib.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-#include <signal.h>
-#include <wait.h>
-#include <errno.h>
-#include <pwd.h>
-#include <grp.h>
-
-#define MOUNTDIR "/mnt/avfs"
-
-static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
-
-static struct fuse *um_fuse;
-static const char *um_dir;
-
-#define MAX_USERS 100
-static uid_t users[MAX_USERS];
-static size_t numusers = 0;
-
-void avfs_main(struct fuse *fuse);
-
-static void reset_signal_handlers()
-{
-    struct sigaction sa;
-       
-    sa.sa_handler = SIG_DFL;
-    sigemptyset(&(sa.sa_mask));
-    sa.sa_flags = 0;
-       
-    sigaction(SIGCHLD, &sa, NULL);
-}
-
-
-static void start_avfs(uid_t uid)
-{
-    int res;
-    char *userdir;
-    struct fuse *user_fuse;
-    struct passwd pw_buf;
-    struct passwd *pw;
-    char buf[1024];
-
-    res = getpwuid_r(uid, &pw_buf, buf, sizeof(buf), &pw);
-    if(pw == NULL)
-        return;
-
-    user_fuse = fuse_new(FUSE_MULTITHREAD, 0);
-    
-    userdir = g_strdup_printf("%s/%010u", MOUNTDIR, uid);
-    mkdir(userdir, 0755);
-    chown(userdir, pw->pw_uid, pw->pw_gid);
-    res = fuse_mount(user_fuse, userdir);
-    g_free(userdir);
-
-    if(res == -1)
-        return;
-
-    res = fork();
-    if(res == 0) {
-        reset_signal_handlers();
-
-        initgroups(pw->pw_name, pw->pw_gid);
-        setgid(pw->pw_gid);
-        setuid(pw->pw_uid);
-        
-        avfs_main(user_fuse);
-        exit(0);
-    }
-
-    fuse_destroy(user_fuse);
-}
-
-
-static int find_user(const char *userstr, uid_t *uid)
-{
-    size_t i;
-    char *end;
-    
-    *uid = strtol(userstr, &end, 10);
-    if(*end != '\0')
-        return 0;
-
-    pthread_mutex_lock(&lock);
-    for(i = 0; i < numusers; i++) {
-        if(users[i] == *uid) {
-            pthread_mutex_unlock(&lock);
-            return 1;
-        }
-    }
-    if(numusers == MAX_USERS) {
-        memmove(users, users + sizeof(users[0]),
-                (MAX_USERS - 1) * sizeof(users[0]));
-        numusers --;
-    }
-
-    users[numusers++] = *uid;
-    pthread_mutex_unlock(&lock);
-
-    start_avfs(*uid);
-
-    return 1;
-}
-
-static void root_attr(struct stat *stbuf)
-{
-    stbuf->st_mode = S_IFDIR | 0555;
-    stbuf->st_nlink = 2 + numusers;
-    stbuf->st_size = MAX_USERS;
-    stbuf->st_blksize = 1024;
-}
-
-static int um_getattr(struct fuse_cred *cred, const char *path,
-                      struct stat *stbuf)
-{
-    uid_t uid;
-    memset(stbuf, 0, sizeof(*stbuf));
-
-    if(strcmp(path, "/") == 0) {
-        root_attr(stbuf);
-        return 0;
-    }
-
-    if(!find_user(path+1, &uid))
-        return -ENOENT;
-
-    stbuf->st_mode = S_IFLNK | 0777;
-    stbuf->st_nlink = 1;
-    stbuf->st_size = strlen(MOUNTDIR) + 1 + 10;
-    stbuf->st_blksize = 1024;
-    stbuf->st_uid = uid;
-
-    return 0;
-}
-
-static int um_readlink(struct fuse_cred *cred, const char *path, char *buf,
-                       size_t size)
-{
-    uid_t uid;
-
-    if(!find_user(path+1, &uid))
-        return -ENOENT;
-
-    snprintf(buf, size, "%s/%010u", MOUNTDIR, uid);
-    return 0;
-}
-
-static int um_getdir(struct fuse_cred *cred, const char *path, fuse_dirh_t h,
-                     fuse_dirfil_t filler)
-{
-    size_t i;
-
-    if(strcmp(path, "/") != 0)
-        return 0;
-    
-    filler(h, ".", 0);
-    filler(h, "..", 0);
-
-    pthread_mutex_lock(&lock);
-    for(i = 0; i < numusers; i++) {
-        char buf[32];
-
-        sprintf(buf, "%u", users[i]);
-        filler(h, buf, 0);
-    }
-    pthread_mutex_unlock(&lock);
-
-    return 0;
-}
-
-
-static void exit_handler()
-{
-    exit(0);
-}
-
-static void child_handler()
-{
-    int status;
-    wait(&status);
-}
-
-static void set_signal_handlers()
-{
-    struct sigaction sa;
-
-    sa.sa_handler = exit_handler;
-    sigemptyset(&(sa.sa_mask));
-    sa.sa_flags = 0;
-
-    if (sigaction(SIGHUP, &sa, NULL) == -1 || 
-       sigaction(SIGINT, &sa, NULL) == -1 || 
-       sigaction(SIGTERM, &sa, NULL) == -1) {
-       
-       perror("Cannot set exit signal handlers");
-        exit(1);
-    }
-
-    sa.sa_handler = SIG_IGN;
-    
-    if(sigaction(SIGPIPE, &sa, NULL) == -1) {
-       perror("Cannot set ignored signals");
-        exit(1);
-    }
-
-    sa.sa_handler = child_handler;
-    if(sigaction(SIGCHLD, &sa, NULL) == -1) {
-       perror("Cannot set child signal handler");
-        exit(1);
-    }
-}
-
-static void cleanup()
-{
-    fuse_unmount(um_fuse);
-    fuse_destroy(um_fuse);
-}
-
-static struct fuse_operations um_oper = {
-    getattr:   um_getattr,
-    getdir:     um_getdir,
-    readlink:  um_readlink,
-};
-
-int main(int argc, char *argv[])
-{
-    int res;
-    if(argc != 2) {
-        fprintf(stderr, "usage: %s mount_dir\n", argv[0]);
-        exit(1);
-    }
-    
-    um_dir = argv[1];
-
-    set_signal_handlers();
-    atexit(cleanup);
-
-    um_fuse = fuse_new(FUSE_MULTITHREAD, 0);
-    res = fuse_mount(um_fuse, um_dir);
-    if(res == -1)
-        exit(1);
-        
-    fuse_set_operations(um_fuse, &um_oper);
-    fuse_loop(um_fuse);
-
-    return 0;
-}