Commit Graph

89 Commits

Author SHA1 Message Date
pooka 6596e0c995 adapt: **newnode etc. pointers -> struct puffs_newinfo 2007-07-01 18:40:15 +00:00
pooka fe7bbdec69 adapt: pid -> const struct puffs_cid * 2007-07-01 17:23:44 +00:00
pooka 1776bc7796 adapt: pcn->pcn_cred is now a pointer 2007-07-01 15:32:02 +00:00
pooka 53a4105885 Actually, keep PUFFS_KFLAG_NOCACHE and -o cache around as shorthand
to neither page- nor namecache.
2007-06-24 22:25:49 +00:00
pooka 5662e7f720 PUFFS_KFLAG_NOCACHE became two, so introduce the command line options
-o nonamecache and -o nopagecache and adapt file systems where necessary.
2007-06-24 22:18:38 +00:00
agc 8ff3509ad4 Use pthread_[gs]etspecific to store a pointer to the fuse_context
information, enabled if MULTITHREADED_REFUSE is defined at build
time. This is not enabled by default since libpuffs is not
threadsafe yet.

librefuse is still not threadsafe, but this gets rid of a whole lot of
problems in the meantime.
2007-06-12 18:57:05 +00:00
agc 8dda7dd1f3 Minor cleanup - change uses of malloc, memset to calloc.
Use EXIT_FAILURE in preference to the less informational 1.
2007-06-12 18:54:36 +00:00
agc e19f0cc8f0 Re-work the way the SET_FUSE_CONTEXT* macros are done, following
feedback from Antti.
2007-06-12 18:53:29 +00:00
agc e9dcd39bdb # use puffs_cred_getuid(3) and puffs_cred_getgid(3)
for i in `jot 100 1`; do
	echo "I must respect the abstractions which pooka put in puffs_cred(3)"
done
2007-06-11 20:54:33 +00:00
agc 2f101ca796 Set the uid, gid and pid wherever possible (i.e. where known). This gets
us far enough along that fuse-loggedfs now works with the correct command,
uid and gid being displayed.
2007-06-11 20:10:00 +00:00
wiz cd4aa9ff37 Make Nm match Dt. This makes it easier to guess what the man page is
called when you find it with man -k.
2007-06-09 10:16:25 +00:00
tls 4147a3c54a Add new Makefile knob, USE_FORT, which extends USE_SSP by turning on the
FORTIFY_SOURCE feature of libssp, thus checking the size of arguments to
various string and memory copy and set functions (as well as a few system
calls and other miscellany) where known at function entry.  RedHat has
evidently built all "core system packages" with this option for some time.

This option should be used at the top of Makefiles (or Makefile.inc where
this is used for subdirectories) but after any setting of LIB.

This is only useful for userland code, and cannot be used in libc or in
any code which includes the libc internals, because it overrides certain
libc functions with macros.  Some effort has been made to make USE_FORT=yes
work correctly for a full-system build by having the bsd.sys.mk logic
disable the feature where it should not be used (libc, libssp iteself,
the kernel) but no attempt has been made to build the entire system with
USE_FORT and doing so will doubtless expose numerous bugs and misfeatures.

Adjust the system build so that all programs and libraries that are setuid,
directly handle network data (including serial comm data), perform
authentication, or appear likely to have (or have a history of having)
data-driven bugs (e.g. file(1)) are built with USE_FORT=yes by default,
with the exception of libc, which cannot use USE_FORT and thus uses
only USE_SSP by default.  Tested on i386 with no ill results; USE_FORT=no
per-directory or in a system build will disable if desired.
2007-05-28 12:06:17 +00:00
agc 9cdcc01daf After we've malloc'd an area of storage, zero out this storage, "just in
case".
2007-05-24 00:55:57 +00:00
pooka 6a3281d2da Calling puffs_exit() in fuse_{exit,unmount}() is wrong, as those
shouldn't release resources.  As a quick hack to prevent double
frees etc, introduce "dead" variable into fuse channel to signal
if the backing puffs resource was already freed.  XXX: the check
is only in exit/unmount currently.

Proper fix really depends on some puffs features I still haven't
gotten around to doing.
2007-05-17 21:28:12 +00:00
pooka a367d901e0 create hash for the root path object 2007-05-17 21:00:32 +00:00
pooka d2228f155e initialize refusenode contents to 0
(don't change malloc to calloc and expect things not to break)
2007-05-17 16:41:18 +00:00
pooka c8b0a89198 reflect changes in fs mount: use puffs_mount() instead of
puffs_domount() & puffs_start()
2007-05-17 14:13:04 +00:00
christos 19468d62cc More fixes:
- make sure that the args array is NULL terminated.
- make sure argc is initialized and argv is set to NULL after freeing.
- make the deep copy function an opt interface function.
2007-05-17 01:55:43 +00:00
xtraeme b18c74c93e Add the $NetBSD$ tag, it's easier to know what revision you have. 2007-05-16 22:17:52 +00:00
christos c0df99a133 - Always check strdup return. For now we are lazy and bail instead of cleaning
up.
- Use malloc and free instead of macros, delete macros.
- Merge the two copies of deep copy and free args that were slightly buggy
  into one and use that one.

XXX: Lots of ints should be size_t.
XXX: Bailing on error is not a good thing for a library.
XXX: Defs.h should be eliminated completely. Not all files need all the headers.
2007-05-16 21:39:08 +00:00
agc 9ceda06dfa The FUSE_USE_VERSION is the definition which the user sets, and which
determines the API.

Provide a default for FUSE_USE_VERSION if it's not set, and use this
value to determine the number of arguments given to fuse_main().
2007-05-16 21:37:18 +00:00
pooka 71bc398720 Enable puffs_fakecc. FUSE file systems don't use continuations anyway,
and now file servers linked against libpthread won't crash when they
attempt to malloc something.
2007-05-16 10:53:41 +00:00
agc dcd3457a33 When parsing arguments for the directory to mount, search backwards from
the end of the argument vector for an argument that doesn't begin with '-',
and use it - this improves upon the previous naive approach of using the
last argument, which could have been placed there by one of the argument
appending functions.

Be consistent with the mount name processing, and always do the
puffs:refuse:filesystem substitution once and once only.

% priv mount.ntfs-3g ntfs-refuse.img /mnt
% df /mnt
Filesystem           1K-blocks      Used     Avail Capacity  Mounted on
puffs:refuse:ntfs-3g   1000943     66309    934634     6%    /mnt
% priv umount /mnt
% priv /usr/src/share/examples/refuse/id3fs/id3fs /mnt &
% df /mnt
Filesystem         1K-blocks      Used     Avail Capacity  Mounted on
puffs:refuse:id3fs         0         0         0   100%    /mnt
% priv umount /mnt
%
2007-05-15 22:56:16 +00:00
agc 01b98414eb Fuse version 2.6 (and above) has a 4 argument version of fuse_main(),
whereas previous versions had a 3 argument one. Accept both.
2007-05-15 22:47:35 +00:00
agc a6521ab14a When puffs_mount fails, display the name of the directory which wasn't
able to be mounted.
2007-05-15 22:46:06 +00:00
agc 76c020111a ...and include fuse_opt.h in the correct place. 2007-05-03 21:13:25 +00:00
agc 363bf2c052 Implement fuse_setup(), and fuse_teardown() - necessary for the python
bindings for refuse.
2007-05-03 21:02:54 +00:00
agc a2b7c5e9b3 FUSE includes fuse_opt.h from fuse.h, albeit indirectly, via fuse_common.h.
Refuse doessn't have a fuse_common.h, so include fuse_opt.h explicitly
from fuse.h.  To avoid circular dependencies, don't include fuse.h
from fuse_opt.h.

This means that we no longer have to modify packages which use the argument
and option parsing routines to include fuse_opt.h.
2007-05-03 20:58:22 +00:00
pooka 80dbf44035 In case a fuse fs hands an stbuf with an inode number 0 to the
readdir filler, fake the inode number.  Our readdir() doesn't show
entries with inode number 0.

per discussion with Stephen Borrill
2007-05-02 18:05:54 +00:00
pooka f5ef068cda use PUFFS_FLAG_HASHPATH 2007-05-01 15:58:25 +00:00
agc 1e1fbd91da The error return code from fuse_opt_add_arg() and fuse_opt_insert_arg() is
actually -1, not 1. Fix the broken sewing machine, and make it sew.
2007-04-17 06:34:48 +00:00
xtraeme 2a9a16f24b Forgot to move the prototype in a comment to the correct place. 2007-04-17 00:25:21 +00:00
xtraeme 5ebefbd7c9 Sync comments with reality. 2007-04-17 00:23:23 +00:00
xtraeme b1f8749808 Wrap long lines. 2007-04-17 00:20:52 +00:00
agc 426de30578 Flesh out the args management a bit more:
+ put some meat into the add_arg and insert_arg functions
+ implement the free_args function
+ use 0 and 1 return values, instead of EXIT_SUCCESS and EXIT_FAILURE, in
  internal functions (they bear no relation to shell exit values)
+ deep copy argument structures in refuse.c - we need to do this because
  some FUSE file systems attempt to obliterate^Wcloak the argument vector
  "for security reasons"
+ a side benefit of this is that we get the specific refuse file system
  name back again:

[10:48:43] agc@inspiron1300 ...src/lib/librefuse 38 > df
Filesystem         1K-blocks      Used     Avail Capacity  Mounted on
/dev/dk0            28101396  19318530   7377798    72%    /
kernfs                     1         1         0   100%    /kern
procfs                     4         4         0   100%    /proc
ptyfs                      1         1         0   100%    /dev/pts
puffs:refuse:id3fs         0         0         0   100%    /mnt
[10:48:51] agc@inspiron1300 ...src/lib/librefuse 39 >
2007-04-16 09:55:51 +00:00
pooka 37dd7942fc Instead of keeping on adding parameters to puffs_mount(), make it
only take the bare essentials, which currently means removing
"maxreqlen" from the argument list (all current callers I'm aware
of set it as 0 anyway).  Introduce puffs_init(), which provides a
context for setting various parameters and puffs_domount(), which
can be used to mount the file system.  Keep puffs_mount() as a
shortcut for the above two for simple file systems.

Bump development ABI version to 13.  After all, it's Friday the 13th.
Watch out!  Bad things can happen on Friday the 13th. --No carrier--
2007-04-13 13:35:46 +00:00
pooka 95a18d20b9 Hide struct puffs_usermount from the rest of the world and provide
accessors for interesting data in it.  Namely, you can now get
pu->pu_privdata with puffs_getspecific(), pu->pu_pn_root with
puffs_set/getroot() and pu->pu_maxreqlen with puffs_getmaxreqlen().
2007-04-12 15:09:00 +00:00
pooka 7ed53cb9ec adapt to new readdir signature. no functional change 2007-04-11 21:10:49 +00:00
pooka 9aca91baa1 use puffs_addvtype2mode() in puffs_fuse_node_mknod() 2007-03-16 08:17:36 +00:00
agc 950c7ae274 Revert the most recent changes I made - they weren't ready for primetime. 2007-03-13 22:47:03 +00:00
agc a43c9c728d Fix a thinko - if we're going to do a deep copy, let's do it properly.
With  thanks to xtraeme for the viirtual PR.
2007-03-13 22:25:32 +00:00
agc e7d3032061 + Only use EXIT_SUCCESS and EXIT_FAILURE for the return code to the
shell in the fuse_opt functions

+ add new debugging functions:
	+ __fuse_debug(), which is used to set and retrieve the
	debugging level, so that debugging information can be turned
	on and off from the user-level filesystem, and
	+ __fuse_pargs(), which prints out an argv vector

+ put the comment about pu_privdata back with the code it references

+ put the code to place the refuse name back into the fuse_new()
function - we have access to all the arguments there.

+ specifically include <fuse_opt.h> in <fuse.h> - this would seem to
be what FUSE itself does, judging by the number of fuse-based
filesystems I've patched to include <fuse_opt.h> specifically

+ do away with the forward reference to struct fuse_args in fuse.h,
since it is defined just after the forward reference without being
referenced in between

+ fill in the missing refuse_opt args functionality - add an arg to the
args structure in fuse_opt_add_arg() and fuse_opt_insert_arg(), and
free allocated memory in fuse_opt_free_args().

+ get rid of spurious forward declarations and prototypes.

+ if REFUSE_INHERIT_FS_CHARACTERISTICS is defined when refuse is built,
file systems inherit the vfs characteristics of their mountpoints. The
default value is NOT to inherit the vfs characteristics.

+ perform a deep copy of the fuse_args structure in fuse_mount() -
this is so that existing FUSE filesystems still DTRT when arguments
are zeroed out.
2007-03-13 20:50:47 +00:00
agc bffaa1dff1 Minor cosmetic changes to clean up some lint. 2007-02-28 21:48:46 +00:00
xtraeme 942dafa618 Add missing NetBSD RCS id. 2007-02-28 16:28:25 +00:00
xtraeme c7b91b596f * Move fuse_opt* defs and prototypes into fuse_opt.h.
* Move fuse_opt* funcs from refuse.c into refuse_opt.c.

Implement fuse_opt_parse() and fuse_opt_match(). And make the other
functions just dummy, always returning 0 (I added debugging printfs
to see what the application is trying to do).

For now there are two things that do not work in fuse_opt:

	* options accepting arguments, i.e -otimeout=%u or -ofile=%s.
	* options without arguments are not enabled, just parsed.

At least now curlftpfs works, even with verbose mode! :-)

Ok'ed by pooka.
2007-02-28 16:23:00 +00:00
agc 803c0cb0e3 For just now, just use "puffs:refuse" as the file system name - this will
be revisited when thee fuse_args parsing is revisited.
2007-02-26 22:28:11 +00:00
pooka 03c5e15dc2 Refactor a few interfaces a bit to look more like fuse. fuse_args
is implemented as a very dummy version (i.e. totally unimplemented),
so some effort is still needed there.

After this change it is possible to compile and run ntfs-3g.  It
works read/write for ntfs images and shows no faults at least with
superficial testing.  I did not test it against a block device,
only an image.

Thanks to Tracy and Jason for help with the test image.
2007-02-26 15:57:33 +00:00
pooka 819ea01282 convert FREAD/FWRITE to O_RDWR-stuff in open 2007-02-26 15:09:19 +00:00
pooka 1b5f35a8e4 Implement readdir properly, or at least as close to possible to how
fuse does it: read directory completely into refuse buffers if starting
from read offset 0 and for later calls trickle results from the buffers
to the kernel without consulting the fuse file system.
2007-02-26 13:52:16 +00:00
pooka a058b5a8e7 revert 1.34, as discussed with agc. It creates more problems than
it solves, namely breaks ~all fuse file systems.  Proper fix is known
but not yet implemented.
2007-02-26 00:25:40 +00:00