History log of /netbsd-current/lib/libpuffs/puffs.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.129 19-Apr-2022 rillig

lib: remove CONSTCOND comment

Since 2021-01-31, lint doesn't need it anymore for the common pattern of
'do ... while (0)'.


# 1.128 22-Jan-2022 pho

Allow calling puffs_mount(3) before puffs_daemon(3)

puffs_daemon(3) creates a pipe before forking, and the parent process
waits for the child to either complete puffs_mount(3) or fail. If a
user calls puffs_daemon(3) after puffs_mount(3), the function
deadlocks. While this error-reporting functionality is really a nice
thing to have, deadlocking is not great. If the filesystem has already
been mounted, puffs_mount(3) should just daemonize the process and
return.

This became an issue because fuse_daemonize(3) in FUSE API had no such
requirement and some FUSE filesystems in the wild suffered deadlocks.


# 1.127 03-Dec-2021 pho

Use size_t in place of voff_t in puffs_setrootinfo(3)

Chuck Silvers pointed out that voff_t was also supposed to be
kernel-only. The correct type to use in userland would be off_t, but
since changing vsize_t to either voff_t or off_t is an ABI change on
32-bit platforms, we use size_t knowing that it is technically
incorrect.


# 1.126 03-Dec-2021 pho

Avoid using register_t or vsize_t in <puffs.h>

<puffs.h> is a user-space header, and should not use any of
kernel-only types. It's not reasonable to require user-land
filesystems to #define _KERNTYPES.


# 1.125 30-Oct-2021 nia

puffs(3): Replace realloc(x * y) with reallocarr


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 netbsd-9-2-RELEASE cjep_staticlib_x-base netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728
# 1.124 30-Jun-2018 christos

use a switch.


Revision tags: phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.123 08-Feb-2018 dholland

branches: 1.123.2; 1.123.4;
Typos.


# 1.122 05-Nov-2017 christos

fix error messages (use __func__, quotes)
also differentiate between canonical and non-relative.


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base
# 1.121 31-May-2017 christos

Adjust to prototype.


Revision tags: prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.120 17-Jun-2015 christos

fix error messages


# 1.119 22-Dec-2014 manu

Do not warn about relative path because of trailing slash

libpuffs calls realpath() to obtain an absolute path to use for mounting.
If the obtained path is different from the one given by the caller, a
warning is issued. This included the situation where the path passed by
the caller just have trailing slashes, a situation where we just want them
to be striped without a warning.


# 1.118 31-Oct-2014 manu

libpuffs support for fallocate and fdiscard operations


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-7-base yamt-pagecache-base9 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 agc-symver-base netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 tls-maxphys-base matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base
# 1.117 14-Nov-2011 chs

branches: 1.117.18;
fix crashes caused by using the results of getcontext()
after the caller returns.


Revision tags: yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base cherry-xenmp-base
# 1.116 03-May-2011 manu

branches: 1.116.4;
Call advlock method if supplied


Revision tags: bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231
# 1.115 06-Dec-2010 pooka

Remove PUFFS_WITH_THREADS ifdef garbage, just use libc weak symbols.


# 1.114 06-Jul-2010 pooka

unwhine lint


# 1.113 06-Jul-2010 pooka

stat mount target path only if we're actually goint to use it.
This avoids errors from the comfd case when the mount target does
not exist in our local namespace.


# 1.112 06-Jul-2010 pooka

set time_t compat where necessary


# 1.111 06-Jul-2010 pooka

When using the top secret PUFFS_COMFD model, write out size of the
puffs kernel args before the contents. This allows parties which
have no clue about the contents to proxy the protocol easily.


# 1.110 07-Jun-2010 pooka

Reenable pathconf now that the retval argument is register_t.


# 1.109 06-Jun-2010 pooka

Actually, disable pathconf for a while longer: the retval needs a
little finetuning (not that everyone is jumping right to using it,
but fixing will have to wait until tomorrow, and who knows what
i'll forget during the night and how long it will eventually take).


# 1.108 06-Jun-2010 pooka

signal pathconf in the vector of supported ops


# 1.107 21-May-2010 pooka

* support extended attributes
* bump major due to structure growth
* add some spare space
* remove ABI sillyness


# 1.106 19-May-2010 pooka

remove three years out-of-date comment


# 1.105 12-Jan-2010 pooka

Add convenience routine puffs_unmountonsignal(), which does exactly that.


# 1.104 07-Jan-2010 pooka

Use typecast instead of ULL for a less whiny lint on LP64.


# 1.103 07-Jan-2010 pooka

Rewrite puffs_exit() in terms of the PUFFSOP_UNMOUNT kernel request.
Now server exit is a lot quite cleaner than previously.


# 1.102 07-Jan-2010 pooka

Set high bit on server->kernel requests to better differentiate
between the direction of the request.


Revision tags: matt-premerge-20091211
# 1.101 05-Dec-2009 pooka

Add an error handler which syslogs but does not abort() and make it
the default. Most servers just shovel bits from their backend to
the kernel without checking the contents and dumping core in case
the backend gives garbage is a bit harsh.


# 1.100 18-Oct-2009 pooka

Make it possible to supply parameters to puffs_init() later (but
before puffs_mount()).


# 1.99 17-Oct-2009 pooka

Dispatch puffs_node_abortop().

Note: We use the storage of puffs_cache_write from puffs_ops for
this purpose. It's not issued by the kernel and hence currently
unused, and this saves us from the trouble of bumping the lib major
version.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.98 08-Jan-2009 lukem

fix some sign comparison warnings


# 1.97 13-Dec-2008 dsl

Actually we need 'long int' to avoif a stupid 'truncating long to int'
warning.


# 1.96 13-Dec-2008 dsl

Change type of 'n' to 'int' so that it can be printed with %d.
The domain of the value is [-1..sizeof (int)] so a type of 'int' is fine.


# 1.95 12-Dec-2008 pooka

Close write-end of daemonpipe in reader to get EOF if the writer
goes awol.


# 1.94 12-Dec-2008 pooka

Add puffs_cancel(), which allows to back down after puffs_init()
and before puffs_mount().
(this should actually be integrated with puffs_exit(), but that
routine is currently so non-sensible that I didn't bother now)


# 1.93 12-Dec-2008 pooka

add:
puffs_setspecific(pu, private)
Can be used to set the specific data after the call to
puffs_init().


Revision tags: netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.92 12-Aug-2008 pooka

branches: 1.92.4; 1.92.8;
Replace void * by puffs_cookie_t where appropriate. No functional change.


# 1.91 11-Aug-2008 pooka

clear cached puffs_cc's in puffs_exit()


# 1.90 11-Aug-2008 pooka

* make sure we come out of mainloop in the main context. otherwise in
certain cases the server would jump to hyperspace when unmounted
* sprinkle some debug prints


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base keiichi-mipv6-base matt-armv6-nbase hpcarm-cleanup-base
# 1.89 28-Jan-2008 pooka

branches: 1.89.6;
Implement lazy contexts for file systems using puffs_mainloop().
Previously each request was executed on its own callcontext and
switched to every time the request was being processed. Now requests
borrow the mainloop context and switch only if/when they yield.
This takes two context switches away from a file system request
bringing down the typical amounts 2->0 (e.g. dtfs) and 4->2 (e.g.
psshfs).

The interfaces for manually executing requests changed a bit:
puffs_dispatch_create() and puffs_dispatch_exec() must now be used.
They are not tested, as nothing in-tree wants them and I doubt
anyone else is really interested in them either.

Also do some misc code cleanup related to execution contexts. The
"work-in-progress checkpoint" committed over a year ago was starting
to look slightly weed-infested.


# 1.88 16-Jan-2008 pooka

Cache a number of execution contexts instead of re-initializing
them every time. Speeds up pure in-memory file systems such as
sysctlfs or dtfs quite a bit. For actual I/O-workhorses the result
is of course less tasty.


# 1.87 16-Jan-2008 pooka

Use PROT_NONE page to protect bottom of stack from overrun


# 1.86 14-Jan-2008 pooka

Introduce PUFFS_STACKSIZE_MIN to avoid overloading 0 and getting
a warning from the library when really wanting to say "just the
minimum, please".


Revision tags: matt-armv6-base
# 1.85 08-Jan-2008 pooka

liberate gas-huffin crack-puffin' assert


# 1.84 02-Jan-2008 pooka

fix pasto


# 1.83 02-Jan-2008 pooka

Also pass fromname in the "distributed" case.


# 1.82 02-Jan-2008 pooka

Provide some transparent "support" for "distributed" file systems.
If the env variable PUFFS_COMFD is set, the descriptor value
contained in it is used for communication instead of opening
/dev/puffs and doing mount(2).

This feature is obviously very undocumented and should not be used
without adult supervision.


# 1.81 25-Dec-2007 pooka

Add a public interface for setting a cookie mapper.


Revision tags: cube-autoconf-base
# 1.80 05-Dec-2007 pooka

Send a response message for flush operations from the kernel instead
of abusing the return value of write(2).


# 1.79 04-Dec-2007 pooka

Part 3/n of extensive changes to message handling:

Get rid of the original puffs_req(3) framework and use puffs_framebuf(3)
instead for file system requests. It has the advantage of being
suitable for transporting a distributed message passing protocol
and therefore us being able to run the file system server on any
host.

Ok, puffs is not quite here yet: libpuffs needs to grow request
routing support and the message contents need to be munged into a
host independent format. Saying which format would be telling,
but it might begin with an X, end in an L and have the 13th character
in the middle. Keep an eye out for the sequels: Parts 3+m/n.


# 1.78 29-Nov-2007 pooka

* allocate pcc as a slice from the stack instead of allocating it
separately
* provide puffs_cc_getcc()

This is in preparation for the removal of you-should-guess-what as
an argument to routines here and there and everywhere.


# 1.77 26-Nov-2007 pooka

print more info when receiving an abort


# 1.76 17-Nov-2007 pooka

puffs_mount():
* initialize values better
* always go through "fail" to see if puffs_daemon() needs to be
woken up
* open device r/w instead of r/o


# 1.75 16-Nov-2007 pooka

Introduce puffs_daemon(), which works like daemon(3) except that it
also synchronizes with puffs_mount() and does not return (exit) in the
parent process until the file system has been mounted. This makes
it possible to reliably run e.g. mount_foo jippi /kai ; cd /kai/ee


# 1.74 06-Nov-2007 pooka

Open the kernel descriptor as part of mount(), not init(). Then
it doesn't matter if someone fork()s or does other tricks between
init() and mount() (and besides, now it's where it logically should be).


# 1.73 05-Nov-2007 pooka

Pull the daemonizing code out of the library mainloop into the file
servers. Calling daemon() (i.e. fork()ing) inside a library can
cause nice surprises for e.g. threaded programs. As discussed with
Greg Oster & others.


# 1.72 29-Oct-2007 pooka

Sprinkle some hackish locks here and there, just enough to allow
libp2k & rump to run multithreaded.


# 1.71 28-Oct-2007 pooka

Add possibility to set pre- and post callbacks which will be called
for all operations before or after executing the specific callback
(the api is not be final yet, though).


# 1.70 26-Oct-2007 pooka

Add some very initial support for a threading worker model as an
alternative to the (vastly superior ;) continuation model. This
is very preliminary stuff and not compiled by default (which it
even won't do without some other patches I cannot commit yet).

The raison d'commit of the patch is a snippet which ensures proper
in-order dispatching of all operations, including those which don't
require a response. Previously many of them would be dispatched
simultaneosly, e.g. fsync and reclaim on the same node, which
obviously isn't all that nice for correct operation.


# 1.69 26-Oct-2007 pooka

mmap stacks, makes it possible to align them


# 1.68 25-Oct-2007 pooka

Make pu_haskq a flag instead of its own variable.


# 1.67 21-Oct-2007 pooka

Add puffs_cc_schedule() which marks a pcc runnable and will pass
execution to it when in the main loop the next time.


# 1.66 11-Oct-2007 pooka

Part 1/n of some pretty extensive changes to how the kernel module
interacts with the userspace file server:

* since the kernel-user communication is not purely request-response
anymore (hasn't been since 2006), try to rename some "request" to
"message". more similar mangling will take place in the future.

* completely rework how messages are allocated. previously most of
them were borrowed from the stack (originally *all* of them),
but now always allocate dynamically. this makes the structure
of the code much cleaner. also makes it possible to fix a
locking order violation. it enables plenty of future enhancements.

* start generalizing the transport interface to be independent of puffs

* move transport interface to read/write instead of ioctl. the
old one had legacy design problems, and besides, ioctl's suck.
implement a very generic version for now; this will be
worked on later hopefully some day reaching "highly optimized".

* implement libpuffs support behind existing library request
interfaces. this will change eventually (I hate those interfaces)


# 1.65 01-Oct-2007 pooka

Pass reason string to pu_errnotify. Print it in the default
version before aborting.


# 1.64 27-Sep-2007 pooka

silence lint. also noticed by xtraeme


# 1.63 27-Sep-2007 pooka

Add error notifications, which are used to deliver errors from the
kernel to the file server for silly things the file server did,
e.g. attempting to create a file with size VSIZENOTSET. The file
server can handle these as it chooses, but the default action is
for it to throw its hands in the air and sing "goodbye, cruel world,
it's over, walk on by".


# 1.62 11-Aug-2007 pooka

branches: 1.62.2;
run realpath() on the mountpath


Revision tags: matt-mips64-base
# 1.61 20-Jul-2007 pooka

branches: 1.61.4;
Add puffs_framev_enqueue_waitevent, which waits for read/write/error
events from an i/o descriptor. It yields until an event happens
and continues execution when the event loop notices the event has
happened.


# 1.60 19-Jul-2007 pooka

Don't float puffs_kargs needlessly around after mount, saves
a couple k of memory (and there was much rejoycing!)


# 1.59 19-Jul-2007 pooka

Use ioctl(PUFFSREQSIZEOP) instead of mount(MNT_GETARGS) to fetch
the maximum request size after mount. Calling mount(MNT_GETARGS)
from the file server is currently not kosher, as it vrele()s the
root vnode, potentially causing an inactive, which the file server
cannot handle while it itself is inactive in the kernel (deadlock).


# 1.58 17-Jul-2007 pooka

* add mntfromname parameter to puffs_init()
* set it in file servers


# 1.57 14-Jul-2007 dsl

Add new 'data_len' parameter to mount system call.
Add an additional call with MNT_GETARGS to retrieve the modified
information instead of relying on the kernel code abusing the mount
interface during mount.


# 1.56 07-Jul-2007 pooka

Make puffs_framebuf better suited from environments with multiple sources:

* in addition add/remove, allow enable/disable, which can be used
to control events for descriptors without having to remove all the
data associated with them
* add directsend/receive, which can be used to pass the same buffer
from the caller to read/writeframe and back again
* add flags to enqueue functions and allow urgent buffers to be
processed as the next PDU


# 1.55 05-Jul-2007 pooka

* reorder calls to get results processed even if our I/O descriptors
go back to zero
* don't give up on the read-side of an fd if there is still unreceived data


# 1.54 02-Jul-2007 pooka

Get rid of the "int *refs" parameter to inactive: the same can be
accomplished now with puffs_setbacks.


# 1.53 11-Jun-2007 pooka

print a specific warning if /dev/puffs cannot be opened in init


# 1.52 06-Jun-2007 pooka

Move puffs to a two clause license where it already isn't so. And
as agc pointed out, even files with the third clause were already
effectively two clause because of a slight bug in the language...


# 1.51 21-May-2007 pooka

remember to put the results of the final operations (including unmount)
to the kernel in mainloop


# 1.50 18-May-2007 pooka

* stuff results back to kernel before calling kevent - the file server
loop function might generate some results. and this is still "after"
event handling (except for the first call, but I'm not too keen on
optimizing for that)
* don't be such a baby about EINTR from kevent(). if we get it, suck
it up and continue instead of quitting


# 1.49 17-May-2007 pooka

Reflect kernel changes for supplying root node information in mount
instead of puffs_start(). Get completely rid of puffs_start(), as
everything it used to do is now handled by the mount routine.
Introduce an optional pre-mount call puffs_setrootinfo() for setting
non-default root node information. As the old puffs_mount() is
now virtually useless, say byebye to it and rename the old
puffs_domount() to puffs_mount(), but add a root cookie parameter
to compensate for the late puffs_start().


# 1.48 16-May-2007 pooka

switch the arbitrary default errno value for network i/o from
ECONNABORTED to ECONNRESET, which is at least a little bit better


# 1.47 15-May-2007 pooka

memset freshly allocated puffs_usermount to 0


# 1.46 15-May-2007 pooka

Step 3 and currently final step of a more general purpose event loop:
support removal and addition of i/o file descriptors on the fly.

* detect closed file descriptors
* automatically free waiters of a dead file descriptor
* give the file server the possibility to specify a callback which
notifies of a dead file descriptor
* move loop function to be a property of the mainloop instead of
framebuf (doesn't change effective behaviour)
* add the possibility to configure a timespec parameter which
attempts to call the loop function periodically
* move the event loop functions from the puffs_framebuf namespace
to puffs_framev to differential between pure memory management
functions


# 1.45 11-May-2007 pooka

move puffs request dispatching code into it's own module.
no functional change


# 1.44 11-May-2007 pooka

Step 2 of general-purpose eventloop: get rid of puffs_framebuf_eventloop().
puffs_mainloop() now handles that functionality as well.


# 1.43 10-May-2007 pooka

Add some kludges to be able to execute requests on the regular program
stack instead of the continuation stack. This is for lib/36011, where
pthread gets confused since we aren't running on the regular stack.
I'm not really sure which direction to go to with this quite yet, so
make the hack hard to enable on purpose. The whole request dispatch
code needs cleaning anyway.


# 1.42 09-May-2007 pooka

Remove the puffs_usermount argument from puffs_req_handle(). It can
be found from the other arguments and this way puffs_req_handle() is
more symmetric with the other puffs_req() routines.


# 1.41 09-May-2007 pooka

Return 0 from puffs_mainloop() if no error occurs.
pointed out by Phil Nelson


# 1.40 07-May-2007 pooka

Add puffs_setback(), which can be used to set setbacks for nodes before
the call returns to the kernel. Currently it can be called only from
open(), mmap(), remove() and rmdir(). (But that might change)


# 1.39 20-Apr-2007 pooka

assert that the file server doesn't try to return more cookies than
it was supposed to


# 1.38 16-Apr-2007 pooka

alloc to set flags when setting fhsize


# 1.37 16-Apr-2007 pooka

some routines for setting mount parameters


# 1.36 13-Apr-2007 pooka

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--


# 1.35 12-Apr-2007 pooka

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().


# 1.34 11-Apr-2007 pooka

* support nodetofh and fhtonode callbacks
* use new signature of node_readdir


# 1.33 20-Mar-2007 pooka

initial support for cacheops


# 1.32 18-Feb-2007 pooka

Until someone can sort non-priviledged mounts and kauth, force
MNT_NOSUID | MNT_NODEV for mounts with geteuid() != 0. I'm tired
of typing them on the command line every time I test a file system.


# 1.31 18-Feb-2007 pooka

dump return values for operations


# 1.30 15-Feb-2007 pooka

Introduce puffs_path_walkcmp(), which is to be called from nodewalk
and compares the path of the node against the given pathobject.
Also make comparison method take a flag to indicate if it should
check if the second path is a true prefix of the first.

plus some namespace cleanup


# 1.29 15-Feb-2007 pooka

* get rid of the holy kernel-given ISDOTDOT, and instead define a
macro which does strcmp against ".." and (the untranslated)
componentname
* make PUFFS_FLAG_BUILDPATH build paths also if dotdot is the case,
and adapt the regular path objects to this
* make nullfs lookup readable because we can now get rid of dotdot
processing there


# 1.28 26-Jan-2007 pooka

add interfaces for suspending the file system


# 1.27 20-Jan-2007 pooka

Be consistent with the rest of the framework about the argument
order of puffs_docc and puffs_dopreq


# 1.26 20-Jan-2007 pooka

be consistent in naming request handlers


# 1.25 16-Jan-2007 pooka

revoke revoke


# 1.24 15-Jan-2007 pooka

Checkpoint some more work in progress: for the benefit those file
system backends which operate purely based on paths, push out more
path management into the library and make path management more
abstract: enable a file system to define a bunch of path management
callbacks, which are used by the framework. Management of normal
/this/is/a/path type paths is provided by the library.


# 1.23 11-Jan-2007 pooka

For directory renames we need to rename all the child nodes for
the given directory if the file system wants paths (PUFFS_FLAG_BUILDPATH).
Do this by walking the nodelist and adjusting the path prefix of
each matching node.


# 1.22 10-Jan-2007 pooka

* don't chdir in possible daemon() call for the benefit of file systems
which specify a relative path as the root
* if (buildpath), build link source full pathname for the duration of
the operation


# 1.21 06-Jan-2007 pooka

* get rid of the mount callback; it's no great surprise to the
server that it needs to mount the file system backend if it wants
to call mount
* provide some options for getmntopts(), assume that callers will parse
command line (or fstab) args
* reorganize the puffs_cc interface just a bit, preparing for a bigger
revamp later


# 1.20 02-Jan-2007 pooka

* inform kernel of our version
* homegrown lib ABI check (to avoid bumping major a ludicrillion times
before reaching stability)


# 1.19 29-Dec-2006 pooka

checkpoint some experimental work-in-progress, namely:

Add support for having multiple outstanding operations. This is done
by exposing enough interfaces so that it is convenient to have the
main event loop in the implementation itself and by providing a
continuation framework for convinient blocking and rescheduling.

works fine, but will undergo further cleanup & development


# 1.18 14-Dec-2006 alc

CID4360: don't leak `buf' upon return
ok pooka@


# 1.17 07-Dec-2006 pooka

outline & export code for interfacing with kernel GET/PUT requests


# 1.16 07-Dec-2006 pooka

g/c out-of-date comment


# 1.15 07-Dec-2006 pooka

support mmap


# 1.14 07-Dec-2006 pooka

cleanup generated stuff from comments


# 1.13 07-Dec-2006 pooka

rototill the operation callbacks: unify the ops under struct puffs_ops
and namespace them


# 1.12 05-Dec-2006 pooka

adapt to kernel change:
Allow multiple requests to be transferred in each GET/PUTOP


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base netbsd-4-base
# 1.11 01-Dec-2006 pooka

PUFFSFLAG -> PUFFS_FLAG to be consistent with the kernel


# 1.10 01-Dec-2006 pooka

build & send implemented operations list to kernel


# 1.9 30-Nov-2006 pooka

summon daemon(3) in mainloop unless the nodaemon flag is given


# 1.8 18-Nov-2006 pooka

* call statvfs() at mount() time, pass that info along
* start is gone


# 1.7 17-Nov-2006 pooka

shuffle flags a bit


# 1.6 09-Nov-2006 pooka

* catch up with kernel changes
* better error handling when mounting


# 1.5 07-Nov-2006 pooka

* support FAF (Fire-And-Forget) class operations
* adapt to new lookup


# 1.4 26-Oct-2006 pooka

pass rdev for specfs support


# 1.3 25-Oct-2006 pooka

handle PUFFS_VN_INACTIVE


# 1.2 23-Oct-2006 christos

pass lint; fix install.


# 1.1 22-Oct-2006 pooka

add libpuffs - the userspace programming interface for puffs

This work was initially started and completed for Google SoC 2005
and tweaked to work a bit better in the past few weeks. While
being far from complete, it is functional enough to be able and
stable to host a fairly general-purpose in-memory file system in
userspace. Even so, puffs should be considered experimental and
no binary compatibility for interfaces or crash-freedom or zero
security implications should be relied upon just yet.

The GSoC project was mentored by William Studenmund and the final
review for the code was done by Christos.


# 1.128 22-Jan-2022 pho

Allow calling puffs_mount(3) before puffs_daemon(3)

puffs_daemon(3) creates a pipe before forking, and the parent process
waits for the child to either complete puffs_mount(3) or fail. If a
user calls puffs_daemon(3) after puffs_mount(3), the function
deadlocks. While this error-reporting functionality is really a nice
thing to have, deadlocking is not great. If the filesystem has already
been mounted, puffs_mount(3) should just daemonize the process and
return.

This became an issue because fuse_daemonize(3) in FUSE API had no such
requirement and some FUSE filesystems in the wild suffered deadlocks.


# 1.127 03-Dec-2021 pho

Use size_t in place of voff_t in puffs_setrootinfo(3)

Chuck Silvers pointed out that voff_t was also supposed to be
kernel-only. The correct type to use in userland would be off_t, but
since changing vsize_t to either voff_t or off_t is an ABI change on
32-bit platforms, we use size_t knowing that it is technically
incorrect.


# 1.126 03-Dec-2021 pho

Avoid using register_t or vsize_t in <puffs.h>

<puffs.h> is a user-space header, and should not use any of
kernel-only types. It's not reasonable to require user-land
filesystems to #define _KERNTYPES.


# 1.125 30-Oct-2021 nia

puffs(3): Replace realloc(x * y) with reallocarr


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 netbsd-9-2-RELEASE cjep_staticlib_x-base netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728
# 1.124 30-Jun-2018 christos

use a switch.


Revision tags: phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.123 08-Feb-2018 dholland

branches: 1.123.2; 1.123.4;
Typos.


# 1.122 05-Nov-2017 christos

fix error messages (use __func__, quotes)
also differentiate between canonical and non-relative.


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base
# 1.121 31-May-2017 christos

Adjust to prototype.


Revision tags: prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.120 17-Jun-2015 christos

fix error messages


# 1.119 22-Dec-2014 manu

Do not warn about relative path because of trailing slash

libpuffs calls realpath() to obtain an absolute path to use for mounting.
If the obtained path is different from the one given by the caller, a
warning is issued. This included the situation where the path passed by
the caller just have trailing slashes, a situation where we just want them
to be striped without a warning.


# 1.118 31-Oct-2014 manu

libpuffs support for fallocate and fdiscard operations


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-7-base yamt-pagecache-base9 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 agc-symver-base netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 tls-maxphys-base matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base
# 1.117 14-Nov-2011 chs

branches: 1.117.18;
fix crashes caused by using the results of getcontext()
after the caller returns.


Revision tags: yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base cherry-xenmp-base
# 1.116 03-May-2011 manu

branches: 1.116.4;
Call advlock method if supplied


Revision tags: bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231
# 1.115 06-Dec-2010 pooka

Remove PUFFS_WITH_THREADS ifdef garbage, just use libc weak symbols.


# 1.114 06-Jul-2010 pooka

unwhine lint


# 1.113 06-Jul-2010 pooka

stat mount target path only if we're actually goint to use it.
This avoids errors from the comfd case when the mount target does
not exist in our local namespace.


# 1.112 06-Jul-2010 pooka

set time_t compat where necessary


# 1.111 06-Jul-2010 pooka

When using the top secret PUFFS_COMFD model, write out size of the
puffs kernel args before the contents. This allows parties which
have no clue about the contents to proxy the protocol easily.


# 1.110 07-Jun-2010 pooka

Reenable pathconf now that the retval argument is register_t.


# 1.109 06-Jun-2010 pooka

Actually, disable pathconf for a while longer: the retval needs a
little finetuning (not that everyone is jumping right to using it,
but fixing will have to wait until tomorrow, and who knows what
i'll forget during the night and how long it will eventually take).


# 1.108 06-Jun-2010 pooka

signal pathconf in the vector of supported ops


# 1.107 21-May-2010 pooka

* support extended attributes
* bump major due to structure growth
* add some spare space
* remove ABI sillyness


# 1.106 19-May-2010 pooka

remove three years out-of-date comment


# 1.105 12-Jan-2010 pooka

Add convenience routine puffs_unmountonsignal(), which does exactly that.


# 1.104 07-Jan-2010 pooka

Use typecast instead of ULL for a less whiny lint on LP64.


# 1.103 07-Jan-2010 pooka

Rewrite puffs_exit() in terms of the PUFFSOP_UNMOUNT kernel request.
Now server exit is a lot quite cleaner than previously.


# 1.102 07-Jan-2010 pooka

Set high bit on server->kernel requests to better differentiate
between the direction of the request.


Revision tags: matt-premerge-20091211
# 1.101 05-Dec-2009 pooka

Add an error handler which syslogs but does not abort() and make it
the default. Most servers just shovel bits from their backend to
the kernel without checking the contents and dumping core in case
the backend gives garbage is a bit harsh.


# 1.100 18-Oct-2009 pooka

Make it possible to supply parameters to puffs_init() later (but
before puffs_mount()).


# 1.99 17-Oct-2009 pooka

Dispatch puffs_node_abortop().

Note: We use the storage of puffs_cache_write from puffs_ops for
this purpose. It's not issued by the kernel and hence currently
unused, and this saves us from the trouble of bumping the lib major
version.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.98 08-Jan-2009 lukem

fix some sign comparison warnings


# 1.97 13-Dec-2008 dsl

Actually we need 'long int' to avoif a stupid 'truncating long to int'
warning.


# 1.96 13-Dec-2008 dsl

Change type of 'n' to 'int' so that it can be printed with %d.
The domain of the value is [-1..sizeof (int)] so a type of 'int' is fine.


# 1.95 12-Dec-2008 pooka

Close write-end of daemonpipe in reader to get EOF if the writer
goes awol.


# 1.94 12-Dec-2008 pooka

Add puffs_cancel(), which allows to back down after puffs_init()
and before puffs_mount().
(this should actually be integrated with puffs_exit(), but that
routine is currently so non-sensible that I didn't bother now)


# 1.93 12-Dec-2008 pooka

add:
puffs_setspecific(pu, private)
Can be used to set the specific data after the call to
puffs_init().


Revision tags: netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.92 12-Aug-2008 pooka

branches: 1.92.4; 1.92.8;
Replace void * by puffs_cookie_t where appropriate. No functional change.


# 1.91 11-Aug-2008 pooka

clear cached puffs_cc's in puffs_exit()


# 1.90 11-Aug-2008 pooka

* make sure we come out of mainloop in the main context. otherwise in
certain cases the server would jump to hyperspace when unmounted
* sprinkle some debug prints


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base keiichi-mipv6-base matt-armv6-nbase hpcarm-cleanup-base
# 1.89 28-Jan-2008 pooka

branches: 1.89.6;
Implement lazy contexts for file systems using puffs_mainloop().
Previously each request was executed on its own callcontext and
switched to every time the request was being processed. Now requests
borrow the mainloop context and switch only if/when they yield.
This takes two context switches away from a file system request
bringing down the typical amounts 2->0 (e.g. dtfs) and 4->2 (e.g.
psshfs).

The interfaces for manually executing requests changed a bit:
puffs_dispatch_create() and puffs_dispatch_exec() must now be used.
They are not tested, as nothing in-tree wants them and I doubt
anyone else is really interested in them either.

Also do some misc code cleanup related to execution contexts. The
"work-in-progress checkpoint" committed over a year ago was starting
to look slightly weed-infested.


# 1.88 16-Jan-2008 pooka

Cache a number of execution contexts instead of re-initializing
them every time. Speeds up pure in-memory file systems such as
sysctlfs or dtfs quite a bit. For actual I/O-workhorses the result
is of course less tasty.


# 1.87 16-Jan-2008 pooka

Use PROT_NONE page to protect bottom of stack from overrun


# 1.86 14-Jan-2008 pooka

Introduce PUFFS_STACKSIZE_MIN to avoid overloading 0 and getting
a warning from the library when really wanting to say "just the
minimum, please".


Revision tags: matt-armv6-base
# 1.85 08-Jan-2008 pooka

liberate gas-huffin crack-puffin' assert


# 1.84 02-Jan-2008 pooka

fix pasto


# 1.83 02-Jan-2008 pooka

Also pass fromname in the "distributed" case.


# 1.82 02-Jan-2008 pooka

Provide some transparent "support" for "distributed" file systems.
If the env variable PUFFS_COMFD is set, the descriptor value
contained in it is used for communication instead of opening
/dev/puffs and doing mount(2).

This feature is obviously very undocumented and should not be used
without adult supervision.


# 1.81 25-Dec-2007 pooka

Add a public interface for setting a cookie mapper.


Revision tags: cube-autoconf-base
# 1.80 05-Dec-2007 pooka

Send a response message for flush operations from the kernel instead
of abusing the return value of write(2).


# 1.79 04-Dec-2007 pooka

Part 3/n of extensive changes to message handling:

Get rid of the original puffs_req(3) framework and use puffs_framebuf(3)
instead for file system requests. It has the advantage of being
suitable for transporting a distributed message passing protocol
and therefore us being able to run the file system server on any
host.

Ok, puffs is not quite here yet: libpuffs needs to grow request
routing support and the message contents need to be munged into a
host independent format. Saying which format would be telling,
but it might begin with an X, end in an L and have the 13th character
in the middle. Keep an eye out for the sequels: Parts 3+m/n.


# 1.78 29-Nov-2007 pooka

* allocate pcc as a slice from the stack instead of allocating it
separately
* provide puffs_cc_getcc()

This is in preparation for the removal of you-should-guess-what as
an argument to routines here and there and everywhere.


# 1.77 26-Nov-2007 pooka

print more info when receiving an abort


# 1.76 17-Nov-2007 pooka

puffs_mount():
* initialize values better
* always go through "fail" to see if puffs_daemon() needs to be
woken up
* open device r/w instead of r/o


# 1.75 16-Nov-2007 pooka

Introduce puffs_daemon(), which works like daemon(3) except that it
also synchronizes with puffs_mount() and does not return (exit) in the
parent process until the file system has been mounted. This makes
it possible to reliably run e.g. mount_foo jippi /kai ; cd /kai/ee


# 1.74 06-Nov-2007 pooka

Open the kernel descriptor as part of mount(), not init(). Then
it doesn't matter if someone fork()s or does other tricks between
init() and mount() (and besides, now it's where it logically should be).


# 1.73 05-Nov-2007 pooka

Pull the daemonizing code out of the library mainloop into the file
servers. Calling daemon() (i.e. fork()ing) inside a library can
cause nice surprises for e.g. threaded programs. As discussed with
Greg Oster & others.


# 1.72 29-Oct-2007 pooka

Sprinkle some hackish locks here and there, just enough to allow
libp2k & rump to run multithreaded.


# 1.71 28-Oct-2007 pooka

Add possibility to set pre- and post callbacks which will be called
for all operations before or after executing the specific callback
(the api is not be final yet, though).


# 1.70 26-Oct-2007 pooka

Add some very initial support for a threading worker model as an
alternative to the (vastly superior ;) continuation model. This
is very preliminary stuff and not compiled by default (which it
even won't do without some other patches I cannot commit yet).

The raison d'commit of the patch is a snippet which ensures proper
in-order dispatching of all operations, including those which don't
require a response. Previously many of them would be dispatched
simultaneosly, e.g. fsync and reclaim on the same node, which
obviously isn't all that nice for correct operation.


# 1.69 26-Oct-2007 pooka

mmap stacks, makes it possible to align them


# 1.68 25-Oct-2007 pooka

Make pu_haskq a flag instead of its own variable.


# 1.67 21-Oct-2007 pooka

Add puffs_cc_schedule() which marks a pcc runnable and will pass
execution to it when in the main loop the next time.


# 1.66 11-Oct-2007 pooka

Part 1/n of some pretty extensive changes to how the kernel module
interacts with the userspace file server:

* since the kernel-user communication is not purely request-response
anymore (hasn't been since 2006), try to rename some "request" to
"message". more similar mangling will take place in the future.

* completely rework how messages are allocated. previously most of
them were borrowed from the stack (originally *all* of them),
but now always allocate dynamically. this makes the structure
of the code much cleaner. also makes it possible to fix a
locking order violation. it enables plenty of future enhancements.

* start generalizing the transport interface to be independent of puffs

* move transport interface to read/write instead of ioctl. the
old one had legacy design problems, and besides, ioctl's suck.
implement a very generic version for now; this will be
worked on later hopefully some day reaching "highly optimized".

* implement libpuffs support behind existing library request
interfaces. this will change eventually (I hate those interfaces)


# 1.65 01-Oct-2007 pooka

Pass reason string to pu_errnotify. Print it in the default
version before aborting.


# 1.64 27-Sep-2007 pooka

silence lint. also noticed by xtraeme


# 1.63 27-Sep-2007 pooka

Add error notifications, which are used to deliver errors from the
kernel to the file server for silly things the file server did,
e.g. attempting to create a file with size VSIZENOTSET. The file
server can handle these as it chooses, but the default action is
for it to throw its hands in the air and sing "goodbye, cruel world,
it's over, walk on by".


# 1.62 11-Aug-2007 pooka

branches: 1.62.2;
run realpath() on the mountpath


Revision tags: matt-mips64-base
# 1.61 20-Jul-2007 pooka

branches: 1.61.4;
Add puffs_framev_enqueue_waitevent, which waits for read/write/error
events from an i/o descriptor. It yields until an event happens
and continues execution when the event loop notices the event has
happened.


# 1.60 19-Jul-2007 pooka

Don't float puffs_kargs needlessly around after mount, saves
a couple k of memory (and there was much rejoycing!)


# 1.59 19-Jul-2007 pooka

Use ioctl(PUFFSREQSIZEOP) instead of mount(MNT_GETARGS) to fetch
the maximum request size after mount. Calling mount(MNT_GETARGS)
from the file server is currently not kosher, as it vrele()s the
root vnode, potentially causing an inactive, which the file server
cannot handle while it itself is inactive in the kernel (deadlock).


# 1.58 17-Jul-2007 pooka

* add mntfromname parameter to puffs_init()
* set it in file servers


# 1.57 14-Jul-2007 dsl

Add new 'data_len' parameter to mount system call.
Add an additional call with MNT_GETARGS to retrieve the modified
information instead of relying on the kernel code abusing the mount
interface during mount.


# 1.56 07-Jul-2007 pooka

Make puffs_framebuf better suited from environments with multiple sources:

* in addition add/remove, allow enable/disable, which can be used
to control events for descriptors without having to remove all the
data associated with them
* add directsend/receive, which can be used to pass the same buffer
from the caller to read/writeframe and back again
* add flags to enqueue functions and allow urgent buffers to be
processed as the next PDU


# 1.55 05-Jul-2007 pooka

* reorder calls to get results processed even if our I/O descriptors
go back to zero
* don't give up on the read-side of an fd if there is still unreceived data


# 1.54 02-Jul-2007 pooka

Get rid of the "int *refs" parameter to inactive: the same can be
accomplished now with puffs_setbacks.


# 1.53 11-Jun-2007 pooka

print a specific warning if /dev/puffs cannot be opened in init


# 1.52 06-Jun-2007 pooka

Move puffs to a two clause license where it already isn't so. And
as agc pointed out, even files with the third clause were already
effectively two clause because of a slight bug in the language...


# 1.51 21-May-2007 pooka

remember to put the results of the final operations (including unmount)
to the kernel in mainloop


# 1.50 18-May-2007 pooka

* stuff results back to kernel before calling kevent - the file server
loop function might generate some results. and this is still "after"
event handling (except for the first call, but I'm not too keen on
optimizing for that)
* don't be such a baby about EINTR from kevent(). if we get it, suck
it up and continue instead of quitting


# 1.49 17-May-2007 pooka

Reflect kernel changes for supplying root node information in mount
instead of puffs_start(). Get completely rid of puffs_start(), as
everything it used to do is now handled by the mount routine.
Introduce an optional pre-mount call puffs_setrootinfo() for setting
non-default root node information. As the old puffs_mount() is
now virtually useless, say byebye to it and rename the old
puffs_domount() to puffs_mount(), but add a root cookie parameter
to compensate for the late puffs_start().


# 1.48 16-May-2007 pooka

switch the arbitrary default errno value for network i/o from
ECONNABORTED to ECONNRESET, which is at least a little bit better


# 1.47 15-May-2007 pooka

memset freshly allocated puffs_usermount to 0


# 1.46 15-May-2007 pooka

Step 3 and currently final step of a more general purpose event loop:
support removal and addition of i/o file descriptors on the fly.

* detect closed file descriptors
* automatically free waiters of a dead file descriptor
* give the file server the possibility to specify a callback which
notifies of a dead file descriptor
* move loop function to be a property of the mainloop instead of
framebuf (doesn't change effective behaviour)
* add the possibility to configure a timespec parameter which
attempts to call the loop function periodically
* move the event loop functions from the puffs_framebuf namespace
to puffs_framev to differential between pure memory management
functions


# 1.45 11-May-2007 pooka

move puffs request dispatching code into it's own module.
no functional change


# 1.44 11-May-2007 pooka

Step 2 of general-purpose eventloop: get rid of puffs_framebuf_eventloop().
puffs_mainloop() now handles that functionality as well.


# 1.43 10-May-2007 pooka

Add some kludges to be able to execute requests on the regular program
stack instead of the continuation stack. This is for lib/36011, where
pthread gets confused since we aren't running on the regular stack.
I'm not really sure which direction to go to with this quite yet, so
make the hack hard to enable on purpose. The whole request dispatch
code needs cleaning anyway.


# 1.42 09-May-2007 pooka

Remove the puffs_usermount argument from puffs_req_handle(). It can
be found from the other arguments and this way puffs_req_handle() is
more symmetric with the other puffs_req() routines.


# 1.41 09-May-2007 pooka

Return 0 from puffs_mainloop() if no error occurs.
pointed out by Phil Nelson


# 1.40 07-May-2007 pooka

Add puffs_setback(), which can be used to set setbacks for nodes before
the call returns to the kernel. Currently it can be called only from
open(), mmap(), remove() and rmdir(). (But that might change)


# 1.39 20-Apr-2007 pooka

assert that the file server doesn't try to return more cookies than
it was supposed to


# 1.38 16-Apr-2007 pooka

alloc to set flags when setting fhsize


# 1.37 16-Apr-2007 pooka

some routines for setting mount parameters


# 1.36 13-Apr-2007 pooka

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--


# 1.35 12-Apr-2007 pooka

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().


# 1.34 11-Apr-2007 pooka

* support nodetofh and fhtonode callbacks
* use new signature of node_readdir


# 1.33 20-Mar-2007 pooka

initial support for cacheops


# 1.32 18-Feb-2007 pooka

Until someone can sort non-priviledged mounts and kauth, force
MNT_NOSUID | MNT_NODEV for mounts with geteuid() != 0. I'm tired
of typing them on the command line every time I test a file system.


# 1.31 18-Feb-2007 pooka

dump return values for operations


# 1.30 15-Feb-2007 pooka

Introduce puffs_path_walkcmp(), which is to be called from nodewalk
and compares the path of the node against the given pathobject.
Also make comparison method take a flag to indicate if it should
check if the second path is a true prefix of the first.

plus some namespace cleanup


# 1.29 15-Feb-2007 pooka

* get rid of the holy kernel-given ISDOTDOT, and instead define a
macro which does strcmp against ".." and (the untranslated)
componentname
* make PUFFS_FLAG_BUILDPATH build paths also if dotdot is the case,
and adapt the regular path objects to this
* make nullfs lookup readable because we can now get rid of dotdot
processing there


# 1.28 26-Jan-2007 pooka

add interfaces for suspending the file system


# 1.27 20-Jan-2007 pooka

Be consistent with the rest of the framework about the argument
order of puffs_docc and puffs_dopreq


# 1.26 20-Jan-2007 pooka

be consistent in naming request handlers


# 1.25 16-Jan-2007 pooka

revoke revoke


# 1.24 15-Jan-2007 pooka

Checkpoint some more work in progress: for the benefit those file
system backends which operate purely based on paths, push out more
path management into the library and make path management more
abstract: enable a file system to define a bunch of path management
callbacks, which are used by the framework. Management of normal
/this/is/a/path type paths is provided by the library.


# 1.23 11-Jan-2007 pooka

For directory renames we need to rename all the child nodes for
the given directory if the file system wants paths (PUFFS_FLAG_BUILDPATH).
Do this by walking the nodelist and adjusting the path prefix of
each matching node.


# 1.22 10-Jan-2007 pooka

* don't chdir in possible daemon() call for the benefit of file systems
which specify a relative path as the root
* if (buildpath), build link source full pathname for the duration of
the operation


# 1.21 06-Jan-2007 pooka

* get rid of the mount callback; it's no great surprise to the
server that it needs to mount the file system backend if it wants
to call mount
* provide some options for getmntopts(), assume that callers will parse
command line (or fstab) args
* reorganize the puffs_cc interface just a bit, preparing for a bigger
revamp later


# 1.20 02-Jan-2007 pooka

* inform kernel of our version
* homegrown lib ABI check (to avoid bumping major a ludicrillion times
before reaching stability)


# 1.19 29-Dec-2006 pooka

checkpoint some experimental work-in-progress, namely:

Add support for having multiple outstanding operations. This is done
by exposing enough interfaces so that it is convenient to have the
main event loop in the implementation itself and by providing a
continuation framework for convinient blocking and rescheduling.

works fine, but will undergo further cleanup & development


# 1.18 14-Dec-2006 alc

CID4360: don't leak `buf' upon return
ok pooka@


# 1.17 07-Dec-2006 pooka

outline & export code for interfacing with kernel GET/PUT requests


# 1.16 07-Dec-2006 pooka

g/c out-of-date comment


# 1.15 07-Dec-2006 pooka

support mmap


# 1.14 07-Dec-2006 pooka

cleanup generated stuff from comments


# 1.13 07-Dec-2006 pooka

rototill the operation callbacks: unify the ops under struct puffs_ops
and namespace them


# 1.12 05-Dec-2006 pooka

adapt to kernel change:
Allow multiple requests to be transferred in each GET/PUTOP


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base netbsd-4-base
# 1.11 01-Dec-2006 pooka

PUFFSFLAG -> PUFFS_FLAG to be consistent with the kernel


# 1.10 01-Dec-2006 pooka

build & send implemented operations list to kernel


# 1.9 30-Nov-2006 pooka

summon daemon(3) in mainloop unless the nodaemon flag is given


# 1.8 18-Nov-2006 pooka

* call statvfs() at mount() time, pass that info along
* start is gone


# 1.7 17-Nov-2006 pooka

shuffle flags a bit


# 1.6 09-Nov-2006 pooka

* catch up with kernel changes
* better error handling when mounting


# 1.5 07-Nov-2006 pooka

* support FAF (Fire-And-Forget) class operations
* adapt to new lookup


# 1.4 26-Oct-2006 pooka

pass rdev for specfs support


# 1.3 25-Oct-2006 pooka

handle PUFFS_VN_INACTIVE


# 1.2 23-Oct-2006 christos

pass lint; fix install.


# 1.1 22-Oct-2006 pooka

add libpuffs - the userspace programming interface for puffs

This work was initially started and completed for Google SoC 2005
and tweaked to work a bit better in the past few weeks. While
being far from complete, it is functional enough to be able and
stable to host a fairly general-purpose in-memory file system in
userspace. Even so, puffs should be considered experimental and
no binary compatibility for interfaces or crash-freedom or zero
security implications should be relied upon just yet.

The GSoC project was mentored by William Studenmund and the final
review for the code was done by Christos.


# 1.127 03-Dec-2021 pho

Use size_t in place of voff_t in puffs_setrootinfo(3)

Chuck Silvers pointed out that voff_t was also supposed to be
kernel-only. The correct type to use in userland would be off_t, but
since changing vsize_t to either voff_t or off_t is an ABI change on
32-bit platforms, we use size_t knowing that it is technically
incorrect.


# 1.126 03-Dec-2021 pho

Avoid using register_t or vsize_t in <puffs.h>

<puffs.h> is a user-space header, and should not use any of
kernel-only types. It's not reasonable to require user-land
filesystems to #define _KERNTYPES.


# 1.125 30-Oct-2021 nia

puffs(3): Replace realloc(x * y) with reallocarr


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 netbsd-9-2-RELEASE cjep_staticlib_x-base netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728
# 1.124 30-Jun-2018 christos

use a switch.


Revision tags: phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.123 08-Feb-2018 dholland

branches: 1.123.2; 1.123.4;
Typos.


# 1.122 05-Nov-2017 christos

fix error messages (use __func__, quotes)
also differentiate between canonical and non-relative.


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base
# 1.121 31-May-2017 christos

Adjust to prototype.


Revision tags: prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.120 17-Jun-2015 christos

fix error messages


# 1.119 22-Dec-2014 manu

Do not warn about relative path because of trailing slash

libpuffs calls realpath() to obtain an absolute path to use for mounting.
If the obtained path is different from the one given by the caller, a
warning is issued. This included the situation where the path passed by
the caller just have trailing slashes, a situation where we just want them
to be striped without a warning.


# 1.118 31-Oct-2014 manu

libpuffs support for fallocate and fdiscard operations


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-7-base yamt-pagecache-base9 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 agc-symver-base netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 tls-maxphys-base matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base
# 1.117 14-Nov-2011 chs

branches: 1.117.18;
fix crashes caused by using the results of getcontext()
after the caller returns.


Revision tags: yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base cherry-xenmp-base
# 1.116 03-May-2011 manu

branches: 1.116.4;
Call advlock method if supplied


Revision tags: bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231
# 1.115 06-Dec-2010 pooka

Remove PUFFS_WITH_THREADS ifdef garbage, just use libc weak symbols.


# 1.114 06-Jul-2010 pooka

unwhine lint


# 1.113 06-Jul-2010 pooka

stat mount target path only if we're actually goint to use it.
This avoids errors from the comfd case when the mount target does
not exist in our local namespace.


# 1.112 06-Jul-2010 pooka

set time_t compat where necessary


# 1.111 06-Jul-2010 pooka

When using the top secret PUFFS_COMFD model, write out size of the
puffs kernel args before the contents. This allows parties which
have no clue about the contents to proxy the protocol easily.


# 1.110 07-Jun-2010 pooka

Reenable pathconf now that the retval argument is register_t.


# 1.109 06-Jun-2010 pooka

Actually, disable pathconf for a while longer: the retval needs a
little finetuning (not that everyone is jumping right to using it,
but fixing will have to wait until tomorrow, and who knows what
i'll forget during the night and how long it will eventually take).


# 1.108 06-Jun-2010 pooka

signal pathconf in the vector of supported ops


# 1.107 21-May-2010 pooka

* support extended attributes
* bump major due to structure growth
* add some spare space
* remove ABI sillyness


# 1.106 19-May-2010 pooka

remove three years out-of-date comment


# 1.105 12-Jan-2010 pooka

Add convenience routine puffs_unmountonsignal(), which does exactly that.


# 1.104 07-Jan-2010 pooka

Use typecast instead of ULL for a less whiny lint on LP64.


# 1.103 07-Jan-2010 pooka

Rewrite puffs_exit() in terms of the PUFFSOP_UNMOUNT kernel request.
Now server exit is a lot quite cleaner than previously.


# 1.102 07-Jan-2010 pooka

Set high bit on server->kernel requests to better differentiate
between the direction of the request.


Revision tags: matt-premerge-20091211
# 1.101 05-Dec-2009 pooka

Add an error handler which syslogs but does not abort() and make it
the default. Most servers just shovel bits from their backend to
the kernel without checking the contents and dumping core in case
the backend gives garbage is a bit harsh.


# 1.100 18-Oct-2009 pooka

Make it possible to supply parameters to puffs_init() later (but
before puffs_mount()).


# 1.99 17-Oct-2009 pooka

Dispatch puffs_node_abortop().

Note: We use the storage of puffs_cache_write from puffs_ops for
this purpose. It's not issued by the kernel and hence currently
unused, and this saves us from the trouble of bumping the lib major
version.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.98 08-Jan-2009 lukem

fix some sign comparison warnings


# 1.97 13-Dec-2008 dsl

Actually we need 'long int' to avoif a stupid 'truncating long to int'
warning.


# 1.96 13-Dec-2008 dsl

Change type of 'n' to 'int' so that it can be printed with %d.
The domain of the value is [-1..sizeof (int)] so a type of 'int' is fine.


# 1.95 12-Dec-2008 pooka

Close write-end of daemonpipe in reader to get EOF if the writer
goes awol.


# 1.94 12-Dec-2008 pooka

Add puffs_cancel(), which allows to back down after puffs_init()
and before puffs_mount().
(this should actually be integrated with puffs_exit(), but that
routine is currently so non-sensible that I didn't bother now)


# 1.93 12-Dec-2008 pooka

add:
puffs_setspecific(pu, private)
Can be used to set the specific data after the call to
puffs_init().


Revision tags: netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.92 12-Aug-2008 pooka

branches: 1.92.4; 1.92.8;
Replace void * by puffs_cookie_t where appropriate. No functional change.


# 1.91 11-Aug-2008 pooka

clear cached puffs_cc's in puffs_exit()


# 1.90 11-Aug-2008 pooka

* make sure we come out of mainloop in the main context. otherwise in
certain cases the server would jump to hyperspace when unmounted
* sprinkle some debug prints


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base keiichi-mipv6-base matt-armv6-nbase hpcarm-cleanup-base
# 1.89 28-Jan-2008 pooka

branches: 1.89.6;
Implement lazy contexts for file systems using puffs_mainloop().
Previously each request was executed on its own callcontext and
switched to every time the request was being processed. Now requests
borrow the mainloop context and switch only if/when they yield.
This takes two context switches away from a file system request
bringing down the typical amounts 2->0 (e.g. dtfs) and 4->2 (e.g.
psshfs).

The interfaces for manually executing requests changed a bit:
puffs_dispatch_create() and puffs_dispatch_exec() must now be used.
They are not tested, as nothing in-tree wants them and I doubt
anyone else is really interested in them either.

Also do some misc code cleanup related to execution contexts. The
"work-in-progress checkpoint" committed over a year ago was starting
to look slightly weed-infested.


# 1.88 16-Jan-2008 pooka

Cache a number of execution contexts instead of re-initializing
them every time. Speeds up pure in-memory file systems such as
sysctlfs or dtfs quite a bit. For actual I/O-workhorses the result
is of course less tasty.


# 1.87 16-Jan-2008 pooka

Use PROT_NONE page to protect bottom of stack from overrun


# 1.86 14-Jan-2008 pooka

Introduce PUFFS_STACKSIZE_MIN to avoid overloading 0 and getting
a warning from the library when really wanting to say "just the
minimum, please".


Revision tags: matt-armv6-base
# 1.85 08-Jan-2008 pooka

liberate gas-huffin crack-puffin' assert


# 1.84 02-Jan-2008 pooka

fix pasto


# 1.83 02-Jan-2008 pooka

Also pass fromname in the "distributed" case.


# 1.82 02-Jan-2008 pooka

Provide some transparent "support" for "distributed" file systems.
If the env variable PUFFS_COMFD is set, the descriptor value
contained in it is used for communication instead of opening
/dev/puffs and doing mount(2).

This feature is obviously very undocumented and should not be used
without adult supervision.


# 1.81 25-Dec-2007 pooka

Add a public interface for setting a cookie mapper.


Revision tags: cube-autoconf-base
# 1.80 05-Dec-2007 pooka

Send a response message for flush operations from the kernel instead
of abusing the return value of write(2).


# 1.79 04-Dec-2007 pooka

Part 3/n of extensive changes to message handling:

Get rid of the original puffs_req(3) framework and use puffs_framebuf(3)
instead for file system requests. It has the advantage of being
suitable for transporting a distributed message passing protocol
and therefore us being able to run the file system server on any
host.

Ok, puffs is not quite here yet: libpuffs needs to grow request
routing support and the message contents need to be munged into a
host independent format. Saying which format would be telling,
but it might begin with an X, end in an L and have the 13th character
in the middle. Keep an eye out for the sequels: Parts 3+m/n.


# 1.78 29-Nov-2007 pooka

* allocate pcc as a slice from the stack instead of allocating it
separately
* provide puffs_cc_getcc()

This is in preparation for the removal of you-should-guess-what as
an argument to routines here and there and everywhere.


# 1.77 26-Nov-2007 pooka

print more info when receiving an abort


# 1.76 17-Nov-2007 pooka

puffs_mount():
* initialize values better
* always go through "fail" to see if puffs_daemon() needs to be
woken up
* open device r/w instead of r/o


# 1.75 16-Nov-2007 pooka

Introduce puffs_daemon(), which works like daemon(3) except that it
also synchronizes with puffs_mount() and does not return (exit) in the
parent process until the file system has been mounted. This makes
it possible to reliably run e.g. mount_foo jippi /kai ; cd /kai/ee


# 1.74 06-Nov-2007 pooka

Open the kernel descriptor as part of mount(), not init(). Then
it doesn't matter if someone fork()s or does other tricks between
init() and mount() (and besides, now it's where it logically should be).


# 1.73 05-Nov-2007 pooka

Pull the daemonizing code out of the library mainloop into the file
servers. Calling daemon() (i.e. fork()ing) inside a library can
cause nice surprises for e.g. threaded programs. As discussed with
Greg Oster & others.


# 1.72 29-Oct-2007 pooka

Sprinkle some hackish locks here and there, just enough to allow
libp2k & rump to run multithreaded.


# 1.71 28-Oct-2007 pooka

Add possibility to set pre- and post callbacks which will be called
for all operations before or after executing the specific callback
(the api is not be final yet, though).


# 1.70 26-Oct-2007 pooka

Add some very initial support for a threading worker model as an
alternative to the (vastly superior ;) continuation model. This
is very preliminary stuff and not compiled by default (which it
even won't do without some other patches I cannot commit yet).

The raison d'commit of the patch is a snippet which ensures proper
in-order dispatching of all operations, including those which don't
require a response. Previously many of them would be dispatched
simultaneosly, e.g. fsync and reclaim on the same node, which
obviously isn't all that nice for correct operation.


# 1.69 26-Oct-2007 pooka

mmap stacks, makes it possible to align them


# 1.68 25-Oct-2007 pooka

Make pu_haskq a flag instead of its own variable.


# 1.67 21-Oct-2007 pooka

Add puffs_cc_schedule() which marks a pcc runnable and will pass
execution to it when in the main loop the next time.


# 1.66 11-Oct-2007 pooka

Part 1/n of some pretty extensive changes to how the kernel module
interacts with the userspace file server:

* since the kernel-user communication is not purely request-response
anymore (hasn't been since 2006), try to rename some "request" to
"message". more similar mangling will take place in the future.

* completely rework how messages are allocated. previously most of
them were borrowed from the stack (originally *all* of them),
but now always allocate dynamically. this makes the structure
of the code much cleaner. also makes it possible to fix a
locking order violation. it enables plenty of future enhancements.

* start generalizing the transport interface to be independent of puffs

* move transport interface to read/write instead of ioctl. the
old one had legacy design problems, and besides, ioctl's suck.
implement a very generic version for now; this will be
worked on later hopefully some day reaching "highly optimized".

* implement libpuffs support behind existing library request
interfaces. this will change eventually (I hate those interfaces)


# 1.65 01-Oct-2007 pooka

Pass reason string to pu_errnotify. Print it in the default
version before aborting.


# 1.64 27-Sep-2007 pooka

silence lint. also noticed by xtraeme


# 1.63 27-Sep-2007 pooka

Add error notifications, which are used to deliver errors from the
kernel to the file server for silly things the file server did,
e.g. attempting to create a file with size VSIZENOTSET. The file
server can handle these as it chooses, but the default action is
for it to throw its hands in the air and sing "goodbye, cruel world,
it's over, walk on by".


# 1.62 11-Aug-2007 pooka

branches: 1.62.2;
run realpath() on the mountpath


Revision tags: matt-mips64-base
# 1.61 20-Jul-2007 pooka

branches: 1.61.4;
Add puffs_framev_enqueue_waitevent, which waits for read/write/error
events from an i/o descriptor. It yields until an event happens
and continues execution when the event loop notices the event has
happened.


# 1.60 19-Jul-2007 pooka

Don't float puffs_kargs needlessly around after mount, saves
a couple k of memory (and there was much rejoycing!)


# 1.59 19-Jul-2007 pooka

Use ioctl(PUFFSREQSIZEOP) instead of mount(MNT_GETARGS) to fetch
the maximum request size after mount. Calling mount(MNT_GETARGS)
from the file server is currently not kosher, as it vrele()s the
root vnode, potentially causing an inactive, which the file server
cannot handle while it itself is inactive in the kernel (deadlock).


# 1.58 17-Jul-2007 pooka

* add mntfromname parameter to puffs_init()
* set it in file servers


# 1.57 14-Jul-2007 dsl

Add new 'data_len' parameter to mount system call.
Add an additional call with MNT_GETARGS to retrieve the modified
information instead of relying on the kernel code abusing the mount
interface during mount.


# 1.56 07-Jul-2007 pooka

Make puffs_framebuf better suited from environments with multiple sources:

* in addition add/remove, allow enable/disable, which can be used
to control events for descriptors without having to remove all the
data associated with them
* add directsend/receive, which can be used to pass the same buffer
from the caller to read/writeframe and back again
* add flags to enqueue functions and allow urgent buffers to be
processed as the next PDU


# 1.55 05-Jul-2007 pooka

* reorder calls to get results processed even if our I/O descriptors
go back to zero
* don't give up on the read-side of an fd if there is still unreceived data


# 1.54 02-Jul-2007 pooka

Get rid of the "int *refs" parameter to inactive: the same can be
accomplished now with puffs_setbacks.


# 1.53 11-Jun-2007 pooka

print a specific warning if /dev/puffs cannot be opened in init


# 1.52 06-Jun-2007 pooka

Move puffs to a two clause license where it already isn't so. And
as agc pointed out, even files with the third clause were already
effectively two clause because of a slight bug in the language...


# 1.51 21-May-2007 pooka

remember to put the results of the final operations (including unmount)
to the kernel in mainloop


# 1.50 18-May-2007 pooka

* stuff results back to kernel before calling kevent - the file server
loop function might generate some results. and this is still "after"
event handling (except for the first call, but I'm not too keen on
optimizing for that)
* don't be such a baby about EINTR from kevent(). if we get it, suck
it up and continue instead of quitting


# 1.49 17-May-2007 pooka

Reflect kernel changes for supplying root node information in mount
instead of puffs_start(). Get completely rid of puffs_start(), as
everything it used to do is now handled by the mount routine.
Introduce an optional pre-mount call puffs_setrootinfo() for setting
non-default root node information. As the old puffs_mount() is
now virtually useless, say byebye to it and rename the old
puffs_domount() to puffs_mount(), but add a root cookie parameter
to compensate for the late puffs_start().


# 1.48 16-May-2007 pooka

switch the arbitrary default errno value for network i/o from
ECONNABORTED to ECONNRESET, which is at least a little bit better


# 1.47 15-May-2007 pooka

memset freshly allocated puffs_usermount to 0


# 1.46 15-May-2007 pooka

Step 3 and currently final step of a more general purpose event loop:
support removal and addition of i/o file descriptors on the fly.

* detect closed file descriptors
* automatically free waiters of a dead file descriptor
* give the file server the possibility to specify a callback which
notifies of a dead file descriptor
* move loop function to be a property of the mainloop instead of
framebuf (doesn't change effective behaviour)
* add the possibility to configure a timespec parameter which
attempts to call the loop function periodically
* move the event loop functions from the puffs_framebuf namespace
to puffs_framev to differential between pure memory management
functions


# 1.45 11-May-2007 pooka

move puffs request dispatching code into it's own module.
no functional change


# 1.44 11-May-2007 pooka

Step 2 of general-purpose eventloop: get rid of puffs_framebuf_eventloop().
puffs_mainloop() now handles that functionality as well.


# 1.43 10-May-2007 pooka

Add some kludges to be able to execute requests on the regular program
stack instead of the continuation stack. This is for lib/36011, where
pthread gets confused since we aren't running on the regular stack.
I'm not really sure which direction to go to with this quite yet, so
make the hack hard to enable on purpose. The whole request dispatch
code needs cleaning anyway.


# 1.42 09-May-2007 pooka

Remove the puffs_usermount argument from puffs_req_handle(). It can
be found from the other arguments and this way puffs_req_handle() is
more symmetric with the other puffs_req() routines.


# 1.41 09-May-2007 pooka

Return 0 from puffs_mainloop() if no error occurs.
pointed out by Phil Nelson


# 1.40 07-May-2007 pooka

Add puffs_setback(), which can be used to set setbacks for nodes before
the call returns to the kernel. Currently it can be called only from
open(), mmap(), remove() and rmdir(). (But that might change)


# 1.39 20-Apr-2007 pooka

assert that the file server doesn't try to return more cookies than
it was supposed to


# 1.38 16-Apr-2007 pooka

alloc to set flags when setting fhsize


# 1.37 16-Apr-2007 pooka

some routines for setting mount parameters


# 1.36 13-Apr-2007 pooka

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--


# 1.35 12-Apr-2007 pooka

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().


# 1.34 11-Apr-2007 pooka

* support nodetofh and fhtonode callbacks
* use new signature of node_readdir


# 1.33 20-Mar-2007 pooka

initial support for cacheops


# 1.32 18-Feb-2007 pooka

Until someone can sort non-priviledged mounts and kauth, force
MNT_NOSUID | MNT_NODEV for mounts with geteuid() != 0. I'm tired
of typing them on the command line every time I test a file system.


# 1.31 18-Feb-2007 pooka

dump return values for operations


# 1.30 15-Feb-2007 pooka

Introduce puffs_path_walkcmp(), which is to be called from nodewalk
and compares the path of the node against the given pathobject.
Also make comparison method take a flag to indicate if it should
check if the second path is a true prefix of the first.

plus some namespace cleanup


# 1.29 15-Feb-2007 pooka

* get rid of the holy kernel-given ISDOTDOT, and instead define a
macro which does strcmp against ".." and (the untranslated)
componentname
* make PUFFS_FLAG_BUILDPATH build paths also if dotdot is the case,
and adapt the regular path objects to this
* make nullfs lookup readable because we can now get rid of dotdot
processing there


# 1.28 26-Jan-2007 pooka

add interfaces for suspending the file system


# 1.27 20-Jan-2007 pooka

Be consistent with the rest of the framework about the argument
order of puffs_docc and puffs_dopreq


# 1.26 20-Jan-2007 pooka

be consistent in naming request handlers


# 1.25 16-Jan-2007 pooka

revoke revoke


# 1.24 15-Jan-2007 pooka

Checkpoint some more work in progress: for the benefit those file
system backends which operate purely based on paths, push out more
path management into the library and make path management more
abstract: enable a file system to define a bunch of path management
callbacks, which are used by the framework. Management of normal
/this/is/a/path type paths is provided by the library.


# 1.23 11-Jan-2007 pooka

For directory renames we need to rename all the child nodes for
the given directory if the file system wants paths (PUFFS_FLAG_BUILDPATH).
Do this by walking the nodelist and adjusting the path prefix of
each matching node.


# 1.22 10-Jan-2007 pooka

* don't chdir in possible daemon() call for the benefit of file systems
which specify a relative path as the root
* if (buildpath), build link source full pathname for the duration of
the operation


# 1.21 06-Jan-2007 pooka

* get rid of the mount callback; it's no great surprise to the
server that it needs to mount the file system backend if it wants
to call mount
* provide some options for getmntopts(), assume that callers will parse
command line (or fstab) args
* reorganize the puffs_cc interface just a bit, preparing for a bigger
revamp later


# 1.20 02-Jan-2007 pooka

* inform kernel of our version
* homegrown lib ABI check (to avoid bumping major a ludicrillion times
before reaching stability)


# 1.19 29-Dec-2006 pooka

checkpoint some experimental work-in-progress, namely:

Add support for having multiple outstanding operations. This is done
by exposing enough interfaces so that it is convenient to have the
main event loop in the implementation itself and by providing a
continuation framework for convinient blocking and rescheduling.

works fine, but will undergo further cleanup & development


# 1.18 14-Dec-2006 alc

CID4360: don't leak `buf' upon return
ok pooka@


# 1.17 07-Dec-2006 pooka

outline & export code for interfacing with kernel GET/PUT requests


# 1.16 07-Dec-2006 pooka

g/c out-of-date comment


# 1.15 07-Dec-2006 pooka

support mmap


# 1.14 07-Dec-2006 pooka

cleanup generated stuff from comments


# 1.13 07-Dec-2006 pooka

rototill the operation callbacks: unify the ops under struct puffs_ops
and namespace them


# 1.12 05-Dec-2006 pooka

adapt to kernel change:
Allow multiple requests to be transferred in each GET/PUTOP


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base netbsd-4-base
# 1.11 01-Dec-2006 pooka

PUFFSFLAG -> PUFFS_FLAG to be consistent with the kernel


# 1.10 01-Dec-2006 pooka

build & send implemented operations list to kernel


# 1.9 30-Nov-2006 pooka

summon daemon(3) in mainloop unless the nodaemon flag is given


# 1.8 18-Nov-2006 pooka

* call statvfs() at mount() time, pass that info along
* start is gone


# 1.7 17-Nov-2006 pooka

shuffle flags a bit


# 1.6 09-Nov-2006 pooka

* catch up with kernel changes
* better error handling when mounting


# 1.5 07-Nov-2006 pooka

* support FAF (Fire-And-Forget) class operations
* adapt to new lookup


# 1.4 26-Oct-2006 pooka

pass rdev for specfs support


# 1.3 25-Oct-2006 pooka

handle PUFFS_VN_INACTIVE


# 1.2 23-Oct-2006 christos

pass lint; fix install.


# 1.1 22-Oct-2006 pooka

add libpuffs - the userspace programming interface for puffs

This work was initially started and completed for Google SoC 2005
and tweaked to work a bit better in the past few weeks. While
being far from complete, it is functional enough to be able and
stable to host a fairly general-purpose in-memory file system in
userspace. Even so, puffs should be considered experimental and
no binary compatibility for interfaces or crash-freedom or zero
security implications should be relied upon just yet.

The GSoC project was mentored by William Studenmund and the final
review for the code was done by Christos.


# 1.125 30-Oct-2021 nia

puffs(3): Replace realloc(x * y) with reallocarr


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 netbsd-9-2-RELEASE cjep_staticlib_x-base netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728
# 1.124 30-Jun-2018 christos

use a switch.


Revision tags: phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.123 08-Feb-2018 dholland

branches: 1.123.2; 1.123.4;
Typos.


# 1.122 05-Nov-2017 christos

fix error messages (use __func__, quotes)
also differentiate between canonical and non-relative.


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base
# 1.121 31-May-2017 christos

Adjust to prototype.


Revision tags: prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.120 17-Jun-2015 christos

fix error messages


# 1.119 22-Dec-2014 manu

Do not warn about relative path because of trailing slash

libpuffs calls realpath() to obtain an absolute path to use for mounting.
If the obtained path is different from the one given by the caller, a
warning is issued. This included the situation where the path passed by
the caller just have trailing slashes, a situation where we just want them
to be striped without a warning.


# 1.118 31-Oct-2014 manu

libpuffs support for fallocate and fdiscard operations


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-7-base yamt-pagecache-base9 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 agc-symver-base netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 tls-maxphys-base matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base
# 1.117 14-Nov-2011 chs

branches: 1.117.18;
fix crashes caused by using the results of getcontext()
after the caller returns.


Revision tags: yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base cherry-xenmp-base
# 1.116 03-May-2011 manu

branches: 1.116.4;
Call advlock method if supplied


Revision tags: bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231
# 1.115 06-Dec-2010 pooka

Remove PUFFS_WITH_THREADS ifdef garbage, just use libc weak symbols.


# 1.114 06-Jul-2010 pooka

unwhine lint


# 1.113 06-Jul-2010 pooka

stat mount target path only if we're actually goint to use it.
This avoids errors from the comfd case when the mount target does
not exist in our local namespace.


# 1.112 06-Jul-2010 pooka

set time_t compat where necessary


# 1.111 06-Jul-2010 pooka

When using the top secret PUFFS_COMFD model, write out size of the
puffs kernel args before the contents. This allows parties which
have no clue about the contents to proxy the protocol easily.


# 1.110 07-Jun-2010 pooka

Reenable pathconf now that the retval argument is register_t.


# 1.109 06-Jun-2010 pooka

Actually, disable pathconf for a while longer: the retval needs a
little finetuning (not that everyone is jumping right to using it,
but fixing will have to wait until tomorrow, and who knows what
i'll forget during the night and how long it will eventually take).


# 1.108 06-Jun-2010 pooka

signal pathconf in the vector of supported ops


# 1.107 21-May-2010 pooka

* support extended attributes
* bump major due to structure growth
* add some spare space
* remove ABI sillyness


# 1.106 19-May-2010 pooka

remove three years out-of-date comment


# 1.105 12-Jan-2010 pooka

Add convenience routine puffs_unmountonsignal(), which does exactly that.


# 1.104 07-Jan-2010 pooka

Use typecast instead of ULL for a less whiny lint on LP64.


# 1.103 07-Jan-2010 pooka

Rewrite puffs_exit() in terms of the PUFFSOP_UNMOUNT kernel request.
Now server exit is a lot quite cleaner than previously.


# 1.102 07-Jan-2010 pooka

Set high bit on server->kernel requests to better differentiate
between the direction of the request.


Revision tags: matt-premerge-20091211
# 1.101 05-Dec-2009 pooka

Add an error handler which syslogs but does not abort() and make it
the default. Most servers just shovel bits from their backend to
the kernel without checking the contents and dumping core in case
the backend gives garbage is a bit harsh.


# 1.100 18-Oct-2009 pooka

Make it possible to supply parameters to puffs_init() later (but
before puffs_mount()).


# 1.99 17-Oct-2009 pooka

Dispatch puffs_node_abortop().

Note: We use the storage of puffs_cache_write from puffs_ops for
this purpose. It's not issued by the kernel and hence currently
unused, and this saves us from the trouble of bumping the lib major
version.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.98 08-Jan-2009 lukem

fix some sign comparison warnings


# 1.97 13-Dec-2008 dsl

Actually we need 'long int' to avoif a stupid 'truncating long to int'
warning.


# 1.96 13-Dec-2008 dsl

Change type of 'n' to 'int' so that it can be printed with %d.
The domain of the value is [-1..sizeof (int)] so a type of 'int' is fine.


# 1.95 12-Dec-2008 pooka

Close write-end of daemonpipe in reader to get EOF if the writer
goes awol.


# 1.94 12-Dec-2008 pooka

Add puffs_cancel(), which allows to back down after puffs_init()
and before puffs_mount().
(this should actually be integrated with puffs_exit(), but that
routine is currently so non-sensible that I didn't bother now)


# 1.93 12-Dec-2008 pooka

add:
puffs_setspecific(pu, private)
Can be used to set the specific data after the call to
puffs_init().


Revision tags: netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.92 12-Aug-2008 pooka

branches: 1.92.4; 1.92.8;
Replace void * by puffs_cookie_t where appropriate. No functional change.


# 1.91 11-Aug-2008 pooka

clear cached puffs_cc's in puffs_exit()


# 1.90 11-Aug-2008 pooka

* make sure we come out of mainloop in the main context. otherwise in
certain cases the server would jump to hyperspace when unmounted
* sprinkle some debug prints


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base keiichi-mipv6-base matt-armv6-nbase hpcarm-cleanup-base
# 1.89 28-Jan-2008 pooka

branches: 1.89.6;
Implement lazy contexts for file systems using puffs_mainloop().
Previously each request was executed on its own callcontext and
switched to every time the request was being processed. Now requests
borrow the mainloop context and switch only if/when they yield.
This takes two context switches away from a file system request
bringing down the typical amounts 2->0 (e.g. dtfs) and 4->2 (e.g.
psshfs).

The interfaces for manually executing requests changed a bit:
puffs_dispatch_create() and puffs_dispatch_exec() must now be used.
They are not tested, as nothing in-tree wants them and I doubt
anyone else is really interested in them either.

Also do some misc code cleanup related to execution contexts. The
"work-in-progress checkpoint" committed over a year ago was starting
to look slightly weed-infested.


# 1.88 16-Jan-2008 pooka

Cache a number of execution contexts instead of re-initializing
them every time. Speeds up pure in-memory file systems such as
sysctlfs or dtfs quite a bit. For actual I/O-workhorses the result
is of course less tasty.


# 1.87 16-Jan-2008 pooka

Use PROT_NONE page to protect bottom of stack from overrun


# 1.86 14-Jan-2008 pooka

Introduce PUFFS_STACKSIZE_MIN to avoid overloading 0 and getting
a warning from the library when really wanting to say "just the
minimum, please".


Revision tags: matt-armv6-base
# 1.85 08-Jan-2008 pooka

liberate gas-huffin crack-puffin' assert


# 1.84 02-Jan-2008 pooka

fix pasto


# 1.83 02-Jan-2008 pooka

Also pass fromname in the "distributed" case.


# 1.82 02-Jan-2008 pooka

Provide some transparent "support" for "distributed" file systems.
If the env variable PUFFS_COMFD is set, the descriptor value
contained in it is used for communication instead of opening
/dev/puffs and doing mount(2).

This feature is obviously very undocumented and should not be used
without adult supervision.


# 1.81 25-Dec-2007 pooka

Add a public interface for setting a cookie mapper.


Revision tags: cube-autoconf-base
# 1.80 05-Dec-2007 pooka

Send a response message for flush operations from the kernel instead
of abusing the return value of write(2).


# 1.79 04-Dec-2007 pooka

Part 3/n of extensive changes to message handling:

Get rid of the original puffs_req(3) framework and use puffs_framebuf(3)
instead for file system requests. It has the advantage of being
suitable for transporting a distributed message passing protocol
and therefore us being able to run the file system server on any
host.

Ok, puffs is not quite here yet: libpuffs needs to grow request
routing support and the message contents need to be munged into a
host independent format. Saying which format would be telling,
but it might begin with an X, end in an L and have the 13th character
in the middle. Keep an eye out for the sequels: Parts 3+m/n.


# 1.78 29-Nov-2007 pooka

* allocate pcc as a slice from the stack instead of allocating it
separately
* provide puffs_cc_getcc()

This is in preparation for the removal of you-should-guess-what as
an argument to routines here and there and everywhere.


# 1.77 26-Nov-2007 pooka

print more info when receiving an abort


# 1.76 17-Nov-2007 pooka

puffs_mount():
* initialize values better
* always go through "fail" to see if puffs_daemon() needs to be
woken up
* open device r/w instead of r/o


# 1.75 16-Nov-2007 pooka

Introduce puffs_daemon(), which works like daemon(3) except that it
also synchronizes with puffs_mount() and does not return (exit) in the
parent process until the file system has been mounted. This makes
it possible to reliably run e.g. mount_foo jippi /kai ; cd /kai/ee


# 1.74 06-Nov-2007 pooka

Open the kernel descriptor as part of mount(), not init(). Then
it doesn't matter if someone fork()s or does other tricks between
init() and mount() (and besides, now it's where it logically should be).


# 1.73 05-Nov-2007 pooka

Pull the daemonizing code out of the library mainloop into the file
servers. Calling daemon() (i.e. fork()ing) inside a library can
cause nice surprises for e.g. threaded programs. As discussed with
Greg Oster & others.


# 1.72 29-Oct-2007 pooka

Sprinkle some hackish locks here and there, just enough to allow
libp2k & rump to run multithreaded.


# 1.71 28-Oct-2007 pooka

Add possibility to set pre- and post callbacks which will be called
for all operations before or after executing the specific callback
(the api is not be final yet, though).


# 1.70 26-Oct-2007 pooka

Add some very initial support for a threading worker model as an
alternative to the (vastly superior ;) continuation model. This
is very preliminary stuff and not compiled by default (which it
even won't do without some other patches I cannot commit yet).

The raison d'commit of the patch is a snippet which ensures proper
in-order dispatching of all operations, including those which don't
require a response. Previously many of them would be dispatched
simultaneosly, e.g. fsync and reclaim on the same node, which
obviously isn't all that nice for correct operation.


# 1.69 26-Oct-2007 pooka

mmap stacks, makes it possible to align them


# 1.68 25-Oct-2007 pooka

Make pu_haskq a flag instead of its own variable.


# 1.67 21-Oct-2007 pooka

Add puffs_cc_schedule() which marks a pcc runnable and will pass
execution to it when in the main loop the next time.


# 1.66 11-Oct-2007 pooka

Part 1/n of some pretty extensive changes to how the kernel module
interacts with the userspace file server:

* since the kernel-user communication is not purely request-response
anymore (hasn't been since 2006), try to rename some "request" to
"message". more similar mangling will take place in the future.

* completely rework how messages are allocated. previously most of
them were borrowed from the stack (originally *all* of them),
but now always allocate dynamically. this makes the structure
of the code much cleaner. also makes it possible to fix a
locking order violation. it enables plenty of future enhancements.

* start generalizing the transport interface to be independent of puffs

* move transport interface to read/write instead of ioctl. the
old one had legacy design problems, and besides, ioctl's suck.
implement a very generic version for now; this will be
worked on later hopefully some day reaching "highly optimized".

* implement libpuffs support behind existing library request
interfaces. this will change eventually (I hate those interfaces)


# 1.65 01-Oct-2007 pooka

Pass reason string to pu_errnotify. Print it in the default
version before aborting.


# 1.64 27-Sep-2007 pooka

silence lint. also noticed by xtraeme


# 1.63 27-Sep-2007 pooka

Add error notifications, which are used to deliver errors from the
kernel to the file server for silly things the file server did,
e.g. attempting to create a file with size VSIZENOTSET. The file
server can handle these as it chooses, but the default action is
for it to throw its hands in the air and sing "goodbye, cruel world,
it's over, walk on by".


# 1.62 11-Aug-2007 pooka

branches: 1.62.2;
run realpath() on the mountpath


Revision tags: matt-mips64-base
# 1.61 20-Jul-2007 pooka

branches: 1.61.4;
Add puffs_framev_enqueue_waitevent, which waits for read/write/error
events from an i/o descriptor. It yields until an event happens
and continues execution when the event loop notices the event has
happened.


# 1.60 19-Jul-2007 pooka

Don't float puffs_kargs needlessly around after mount, saves
a couple k of memory (and there was much rejoycing!)


# 1.59 19-Jul-2007 pooka

Use ioctl(PUFFSREQSIZEOP) instead of mount(MNT_GETARGS) to fetch
the maximum request size after mount. Calling mount(MNT_GETARGS)
from the file server is currently not kosher, as it vrele()s the
root vnode, potentially causing an inactive, which the file server
cannot handle while it itself is inactive in the kernel (deadlock).


# 1.58 17-Jul-2007 pooka

* add mntfromname parameter to puffs_init()
* set it in file servers


# 1.57 14-Jul-2007 dsl

Add new 'data_len' parameter to mount system call.
Add an additional call with MNT_GETARGS to retrieve the modified
information instead of relying on the kernel code abusing the mount
interface during mount.


# 1.56 07-Jul-2007 pooka

Make puffs_framebuf better suited from environments with multiple sources:

* in addition add/remove, allow enable/disable, which can be used
to control events for descriptors without having to remove all the
data associated with them
* add directsend/receive, which can be used to pass the same buffer
from the caller to read/writeframe and back again
* add flags to enqueue functions and allow urgent buffers to be
processed as the next PDU


# 1.55 05-Jul-2007 pooka

* reorder calls to get results processed even if our I/O descriptors
go back to zero
* don't give up on the read-side of an fd if there is still unreceived data


# 1.54 02-Jul-2007 pooka

Get rid of the "int *refs" parameter to inactive: the same can be
accomplished now with puffs_setbacks.


# 1.53 11-Jun-2007 pooka

print a specific warning if /dev/puffs cannot be opened in init


# 1.52 06-Jun-2007 pooka

Move puffs to a two clause license where it already isn't so. And
as agc pointed out, even files with the third clause were already
effectively two clause because of a slight bug in the language...


# 1.51 21-May-2007 pooka

remember to put the results of the final operations (including unmount)
to the kernel in mainloop


# 1.50 18-May-2007 pooka

* stuff results back to kernel before calling kevent - the file server
loop function might generate some results. and this is still "after"
event handling (except for the first call, but I'm not too keen on
optimizing for that)
* don't be such a baby about EINTR from kevent(). if we get it, suck
it up and continue instead of quitting


# 1.49 17-May-2007 pooka

Reflect kernel changes for supplying root node information in mount
instead of puffs_start(). Get completely rid of puffs_start(), as
everything it used to do is now handled by the mount routine.
Introduce an optional pre-mount call puffs_setrootinfo() for setting
non-default root node information. As the old puffs_mount() is
now virtually useless, say byebye to it and rename the old
puffs_domount() to puffs_mount(), but add a root cookie parameter
to compensate for the late puffs_start().


# 1.48 16-May-2007 pooka

switch the arbitrary default errno value for network i/o from
ECONNABORTED to ECONNRESET, which is at least a little bit better


# 1.47 15-May-2007 pooka

memset freshly allocated puffs_usermount to 0


# 1.46 15-May-2007 pooka

Step 3 and currently final step of a more general purpose event loop:
support removal and addition of i/o file descriptors on the fly.

* detect closed file descriptors
* automatically free waiters of a dead file descriptor
* give the file server the possibility to specify a callback which
notifies of a dead file descriptor
* move loop function to be a property of the mainloop instead of
framebuf (doesn't change effective behaviour)
* add the possibility to configure a timespec parameter which
attempts to call the loop function periodically
* move the event loop functions from the puffs_framebuf namespace
to puffs_framev to differential between pure memory management
functions


# 1.45 11-May-2007 pooka

move puffs request dispatching code into it's own module.
no functional change


# 1.44 11-May-2007 pooka

Step 2 of general-purpose eventloop: get rid of puffs_framebuf_eventloop().
puffs_mainloop() now handles that functionality as well.


# 1.43 10-May-2007 pooka

Add some kludges to be able to execute requests on the regular program
stack instead of the continuation stack. This is for lib/36011, where
pthread gets confused since we aren't running on the regular stack.
I'm not really sure which direction to go to with this quite yet, so
make the hack hard to enable on purpose. The whole request dispatch
code needs cleaning anyway.


# 1.42 09-May-2007 pooka

Remove the puffs_usermount argument from puffs_req_handle(). It can
be found from the other arguments and this way puffs_req_handle() is
more symmetric with the other puffs_req() routines.


# 1.41 09-May-2007 pooka

Return 0 from puffs_mainloop() if no error occurs.
pointed out by Phil Nelson


# 1.40 07-May-2007 pooka

Add puffs_setback(), which can be used to set setbacks for nodes before
the call returns to the kernel. Currently it can be called only from
open(), mmap(), remove() and rmdir(). (But that might change)


# 1.39 20-Apr-2007 pooka

assert that the file server doesn't try to return more cookies than
it was supposed to


# 1.38 16-Apr-2007 pooka

alloc to set flags when setting fhsize


# 1.37 16-Apr-2007 pooka

some routines for setting mount parameters


# 1.36 13-Apr-2007 pooka

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--


# 1.35 12-Apr-2007 pooka

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().


# 1.34 11-Apr-2007 pooka

* support nodetofh and fhtonode callbacks
* use new signature of node_readdir


# 1.33 20-Mar-2007 pooka

initial support for cacheops


# 1.32 18-Feb-2007 pooka

Until someone can sort non-priviledged mounts and kauth, force
MNT_NOSUID | MNT_NODEV for mounts with geteuid() != 0. I'm tired
of typing them on the command line every time I test a file system.


# 1.31 18-Feb-2007 pooka

dump return values for operations


# 1.30 15-Feb-2007 pooka

Introduce puffs_path_walkcmp(), which is to be called from nodewalk
and compares the path of the node against the given pathobject.
Also make comparison method take a flag to indicate if it should
check if the second path is a true prefix of the first.

plus some namespace cleanup


# 1.29 15-Feb-2007 pooka

* get rid of the holy kernel-given ISDOTDOT, and instead define a
macro which does strcmp against ".." and (the untranslated)
componentname
* make PUFFS_FLAG_BUILDPATH build paths also if dotdot is the case,
and adapt the regular path objects to this
* make nullfs lookup readable because we can now get rid of dotdot
processing there


# 1.28 26-Jan-2007 pooka

add interfaces for suspending the file system


# 1.27 20-Jan-2007 pooka

Be consistent with the rest of the framework about the argument
order of puffs_docc and puffs_dopreq


# 1.26 20-Jan-2007 pooka

be consistent in naming request handlers


# 1.25 16-Jan-2007 pooka

revoke revoke


# 1.24 15-Jan-2007 pooka

Checkpoint some more work in progress: for the benefit those file
system backends which operate purely based on paths, push out more
path management into the library and make path management more
abstract: enable a file system to define a bunch of path management
callbacks, which are used by the framework. Management of normal
/this/is/a/path type paths is provided by the library.


# 1.23 11-Jan-2007 pooka

For directory renames we need to rename all the child nodes for
the given directory if the file system wants paths (PUFFS_FLAG_BUILDPATH).
Do this by walking the nodelist and adjusting the path prefix of
each matching node.


# 1.22 10-Jan-2007 pooka

* don't chdir in possible daemon() call for the benefit of file systems
which specify a relative path as the root
* if (buildpath), build link source full pathname for the duration of
the operation


# 1.21 06-Jan-2007 pooka

* get rid of the mount callback; it's no great surprise to the
server that it needs to mount the file system backend if it wants
to call mount
* provide some options for getmntopts(), assume that callers will parse
command line (or fstab) args
* reorganize the puffs_cc interface just a bit, preparing for a bigger
revamp later


# 1.20 02-Jan-2007 pooka

* inform kernel of our version
* homegrown lib ABI check (to avoid bumping major a ludicrillion times
before reaching stability)


# 1.19 29-Dec-2006 pooka

checkpoint some experimental work-in-progress, namely:

Add support for having multiple outstanding operations. This is done
by exposing enough interfaces so that it is convenient to have the
main event loop in the implementation itself and by providing a
continuation framework for convinient blocking and rescheduling.

works fine, but will undergo further cleanup & development


# 1.18 14-Dec-2006 alc

CID4360: don't leak `buf' upon return
ok pooka@


# 1.17 07-Dec-2006 pooka

outline & export code for interfacing with kernel GET/PUT requests


# 1.16 07-Dec-2006 pooka

g/c out-of-date comment


# 1.15 07-Dec-2006 pooka

support mmap


# 1.14 07-Dec-2006 pooka

cleanup generated stuff from comments


# 1.13 07-Dec-2006 pooka

rototill the operation callbacks: unify the ops under struct puffs_ops
and namespace them


# 1.12 05-Dec-2006 pooka

adapt to kernel change:
Allow multiple requests to be transferred in each GET/PUTOP


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base netbsd-4-base
# 1.11 01-Dec-2006 pooka

PUFFSFLAG -> PUFFS_FLAG to be consistent with the kernel


# 1.10 01-Dec-2006 pooka

build & send implemented operations list to kernel


# 1.9 30-Nov-2006 pooka

summon daemon(3) in mainloop unless the nodaemon flag is given


# 1.8 18-Nov-2006 pooka

* call statvfs() at mount() time, pass that info along
* start is gone


# 1.7 17-Nov-2006 pooka

shuffle flags a bit


# 1.6 09-Nov-2006 pooka

* catch up with kernel changes
* better error handling when mounting


# 1.5 07-Nov-2006 pooka

* support FAF (Fire-And-Forget) class operations
* adapt to new lookup


# 1.4 26-Oct-2006 pooka

pass rdev for specfs support


# 1.3 25-Oct-2006 pooka

handle PUFFS_VN_INACTIVE


# 1.2 23-Oct-2006 christos

pass lint; fix install.


# 1.1 22-Oct-2006 pooka

add libpuffs - the userspace programming interface for puffs

This work was initially started and completed for Google SoC 2005
and tweaked to work a bit better in the past few weeks. While
being far from complete, it is functional enough to be able and
stable to host a fairly general-purpose in-memory file system in
userspace. Even so, puffs should be considered experimental and
no binary compatibility for interfaces or crash-freedom or zero
security implications should be relied upon just yet.

The GSoC project was mentored by William Studenmund and the final
review for the code was done by Christos.


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728
# 1.124 30-Jun-2018 christos

use a switch.


Revision tags: phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.123 08-Feb-2018 dholland

branches: 1.123.2;
Typos.


# 1.122 05-Nov-2017 christos

fix error messages (use __func__, quotes)
also differentiate between canonical and non-relative.


Revision tags: netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base
# 1.121 31-May-2017 christos

Adjust to prototype.


Revision tags: prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.120 17-Jun-2015 christos

fix error messages


# 1.119 22-Dec-2014 manu

Do not warn about relative path because of trailing slash

libpuffs calls realpath() to obtain an absolute path to use for mounting.
If the obtained path is different from the one given by the caller, a
warning is issued. This included the situation where the path passed by
the caller just have trailing slashes, a situation where we just want them
to be striped without a warning.


# 1.118 31-Oct-2014 manu

libpuffs support for fallocate and fdiscard operations


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-7-base yamt-pagecache-base9 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 agc-symver-base netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 tls-maxphys-base matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base
# 1.117 14-Nov-2011 chs

branches: 1.117.18;
fix crashes caused by using the results of getcontext()
after the caller returns.


Revision tags: yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base cherry-xenmp-base
# 1.116 03-May-2011 manu

branches: 1.116.4;
Call advlock method if supplied


Revision tags: bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231
# 1.115 06-Dec-2010 pooka

Remove PUFFS_WITH_THREADS ifdef garbage, just use libc weak symbols.


# 1.114 06-Jul-2010 pooka

unwhine lint


# 1.113 06-Jul-2010 pooka

stat mount target path only if we're actually goint to use it.
This avoids errors from the comfd case when the mount target does
not exist in our local namespace.


# 1.112 06-Jul-2010 pooka

set time_t compat where necessary


# 1.111 06-Jul-2010 pooka

When using the top secret PUFFS_COMFD model, write out size of the
puffs kernel args before the contents. This allows parties which
have no clue about the contents to proxy the protocol easily.


# 1.110 07-Jun-2010 pooka

Reenable pathconf now that the retval argument is register_t.


# 1.109 06-Jun-2010 pooka

Actually, disable pathconf for a while longer: the retval needs a
little finetuning (not that everyone is jumping right to using it,
but fixing will have to wait until tomorrow, and who knows what
i'll forget during the night and how long it will eventually take).


# 1.108 06-Jun-2010 pooka

signal pathconf in the vector of supported ops


# 1.107 21-May-2010 pooka

* support extended attributes
* bump major due to structure growth
* add some spare space
* remove ABI sillyness


# 1.106 19-May-2010 pooka

remove three years out-of-date comment


# 1.105 12-Jan-2010 pooka

Add convenience routine puffs_unmountonsignal(), which does exactly that.


# 1.104 07-Jan-2010 pooka

Use typecast instead of ULL for a less whiny lint on LP64.


# 1.103 07-Jan-2010 pooka

Rewrite puffs_exit() in terms of the PUFFSOP_UNMOUNT kernel request.
Now server exit is a lot quite cleaner than previously.


# 1.102 07-Jan-2010 pooka

Set high bit on server->kernel requests to better differentiate
between the direction of the request.


Revision tags: matt-premerge-20091211
# 1.101 05-Dec-2009 pooka

Add an error handler which syslogs but does not abort() and make it
the default. Most servers just shovel bits from their backend to
the kernel without checking the contents and dumping core in case
the backend gives garbage is a bit harsh.


# 1.100 18-Oct-2009 pooka

Make it possible to supply parameters to puffs_init() later (but
before puffs_mount()).


# 1.99 17-Oct-2009 pooka

Dispatch puffs_node_abortop().

Note: We use the storage of puffs_cache_write from puffs_ops for
this purpose. It's not issued by the kernel and hence currently
unused, and this saves us from the trouble of bumping the lib major
version.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.98 08-Jan-2009 lukem

fix some sign comparison warnings


# 1.97 13-Dec-2008 dsl

Actually we need 'long int' to avoif a stupid 'truncating long to int'
warning.


# 1.96 13-Dec-2008 dsl

Change type of 'n' to 'int' so that it can be printed with %d.
The domain of the value is [-1..sizeof (int)] so a type of 'int' is fine.


# 1.95 12-Dec-2008 pooka

Close write-end of daemonpipe in reader to get EOF if the writer
goes awol.


# 1.94 12-Dec-2008 pooka

Add puffs_cancel(), which allows to back down after puffs_init()
and before puffs_mount().
(this should actually be integrated with puffs_exit(), but that
routine is currently so non-sensible that I didn't bother now)


# 1.93 12-Dec-2008 pooka

add:
puffs_setspecific(pu, private)
Can be used to set the specific data after the call to
puffs_init().


Revision tags: netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.92 12-Aug-2008 pooka

branches: 1.92.4; 1.92.8;
Replace void * by puffs_cookie_t where appropriate. No functional change.


# 1.91 11-Aug-2008 pooka

clear cached puffs_cc's in puffs_exit()


# 1.90 11-Aug-2008 pooka

* make sure we come out of mainloop in the main context. otherwise in
certain cases the server would jump to hyperspace when unmounted
* sprinkle some debug prints


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base keiichi-mipv6-base matt-armv6-nbase hpcarm-cleanup-base
# 1.89 28-Jan-2008 pooka

branches: 1.89.6;
Implement lazy contexts for file systems using puffs_mainloop().
Previously each request was executed on its own callcontext and
switched to every time the request was being processed. Now requests
borrow the mainloop context and switch only if/when they yield.
This takes two context switches away from a file system request
bringing down the typical amounts 2->0 (e.g. dtfs) and 4->2 (e.g.
psshfs).

The interfaces for manually executing requests changed a bit:
puffs_dispatch_create() and puffs_dispatch_exec() must now be used.
They are not tested, as nothing in-tree wants them and I doubt
anyone else is really interested in them either.

Also do some misc code cleanup related to execution contexts. The
"work-in-progress checkpoint" committed over a year ago was starting
to look slightly weed-infested.


# 1.88 16-Jan-2008 pooka

Cache a number of execution contexts instead of re-initializing
them every time. Speeds up pure in-memory file systems such as
sysctlfs or dtfs quite a bit. For actual I/O-workhorses the result
is of course less tasty.


# 1.87 16-Jan-2008 pooka

Use PROT_NONE page to protect bottom of stack from overrun


# 1.86 14-Jan-2008 pooka

Introduce PUFFS_STACKSIZE_MIN to avoid overloading 0 and getting
a warning from the library when really wanting to say "just the
minimum, please".


Revision tags: matt-armv6-base
# 1.85 08-Jan-2008 pooka

liberate gas-huffin crack-puffin' assert


# 1.84 02-Jan-2008 pooka

fix pasto


# 1.83 02-Jan-2008 pooka

Also pass fromname in the "distributed" case.


# 1.82 02-Jan-2008 pooka

Provide some transparent "support" for "distributed" file systems.
If the env variable PUFFS_COMFD is set, the descriptor value
contained in it is used for communication instead of opening
/dev/puffs and doing mount(2).

This feature is obviously very undocumented and should not be used
without adult supervision.


# 1.81 25-Dec-2007 pooka

Add a public interface for setting a cookie mapper.


Revision tags: cube-autoconf-base
# 1.80 05-Dec-2007 pooka

Send a response message for flush operations from the kernel instead
of abusing the return value of write(2).


# 1.79 04-Dec-2007 pooka

Part 3/n of extensive changes to message handling:

Get rid of the original puffs_req(3) framework and use puffs_framebuf(3)
instead for file system requests. It has the advantage of being
suitable for transporting a distributed message passing protocol
and therefore us being able to run the file system server on any
host.

Ok, puffs is not quite here yet: libpuffs needs to grow request
routing support and the message contents need to be munged into a
host independent format. Saying which format would be telling,
but it might begin with an X, end in an L and have the 13th character
in the middle. Keep an eye out for the sequels: Parts 3+m/n.


# 1.78 29-Nov-2007 pooka

* allocate pcc as a slice from the stack instead of allocating it
separately
* provide puffs_cc_getcc()

This is in preparation for the removal of you-should-guess-what as
an argument to routines here and there and everywhere.


# 1.77 26-Nov-2007 pooka

print more info when receiving an abort


# 1.76 17-Nov-2007 pooka

puffs_mount():
* initialize values better
* always go through "fail" to see if puffs_daemon() needs to be
woken up
* open device r/w instead of r/o


# 1.75 16-Nov-2007 pooka

Introduce puffs_daemon(), which works like daemon(3) except that it
also synchronizes with puffs_mount() and does not return (exit) in the
parent process until the file system has been mounted. This makes
it possible to reliably run e.g. mount_foo jippi /kai ; cd /kai/ee


# 1.74 06-Nov-2007 pooka

Open the kernel descriptor as part of mount(), not init(). Then
it doesn't matter if someone fork()s or does other tricks between
init() and mount() (and besides, now it's where it logically should be).


# 1.73 05-Nov-2007 pooka

Pull the daemonizing code out of the library mainloop into the file
servers. Calling daemon() (i.e. fork()ing) inside a library can
cause nice surprises for e.g. threaded programs. As discussed with
Greg Oster & others.


# 1.72 29-Oct-2007 pooka

Sprinkle some hackish locks here and there, just enough to allow
libp2k & rump to run multithreaded.


# 1.71 28-Oct-2007 pooka

Add possibility to set pre- and post callbacks which will be called
for all operations before or after executing the specific callback
(the api is not be final yet, though).


# 1.70 26-Oct-2007 pooka

Add some very initial support for a threading worker model as an
alternative to the (vastly superior ;) continuation model. This
is very preliminary stuff and not compiled by default (which it
even won't do without some other patches I cannot commit yet).

The raison d'commit of the patch is a snippet which ensures proper
in-order dispatching of all operations, including those which don't
require a response. Previously many of them would be dispatched
simultaneosly, e.g. fsync and reclaim on the same node, which
obviously isn't all that nice for correct operation.


# 1.69 26-Oct-2007 pooka

mmap stacks, makes it possible to align them


# 1.68 25-Oct-2007 pooka

Make pu_haskq a flag instead of its own variable.


# 1.67 21-Oct-2007 pooka

Add puffs_cc_schedule() which marks a pcc runnable and will pass
execution to it when in the main loop the next time.


# 1.66 11-Oct-2007 pooka

Part 1/n of some pretty extensive changes to how the kernel module
interacts with the userspace file server:

* since the kernel-user communication is not purely request-response
anymore (hasn't been since 2006), try to rename some "request" to
"message". more similar mangling will take place in the future.

* completely rework how messages are allocated. previously most of
them were borrowed from the stack (originally *all* of them),
but now always allocate dynamically. this makes the structure
of the code much cleaner. also makes it possible to fix a
locking order violation. it enables plenty of future enhancements.

* start generalizing the transport interface to be independent of puffs

* move transport interface to read/write instead of ioctl. the
old one had legacy design problems, and besides, ioctl's suck.
implement a very generic version for now; this will be
worked on later hopefully some day reaching "highly optimized".

* implement libpuffs support behind existing library request
interfaces. this will change eventually (I hate those interfaces)


# 1.65 01-Oct-2007 pooka

Pass reason string to pu_errnotify. Print it in the default
version before aborting.


# 1.64 27-Sep-2007 pooka

silence lint. also noticed by xtraeme


# 1.63 27-Sep-2007 pooka

Add error notifications, which are used to deliver errors from the
kernel to the file server for silly things the file server did,
e.g. attempting to create a file with size VSIZENOTSET. The file
server can handle these as it chooses, but the default action is
for it to throw its hands in the air and sing "goodbye, cruel world,
it's over, walk on by".


# 1.62 11-Aug-2007 pooka

branches: 1.62.2;
run realpath() on the mountpath


Revision tags: matt-mips64-base
# 1.61 20-Jul-2007 pooka

branches: 1.61.4;
Add puffs_framev_enqueue_waitevent, which waits for read/write/error
events from an i/o descriptor. It yields until an event happens
and continues execution when the event loop notices the event has
happened.


# 1.60 19-Jul-2007 pooka

Don't float puffs_kargs needlessly around after mount, saves
a couple k of memory (and there was much rejoycing!)


# 1.59 19-Jul-2007 pooka

Use ioctl(PUFFSREQSIZEOP) instead of mount(MNT_GETARGS) to fetch
the maximum request size after mount. Calling mount(MNT_GETARGS)
from the file server is currently not kosher, as it vrele()s the
root vnode, potentially causing an inactive, which the file server
cannot handle while it itself is inactive in the kernel (deadlock).


# 1.58 17-Jul-2007 pooka

* add mntfromname parameter to puffs_init()
* set it in file servers


# 1.57 14-Jul-2007 dsl

Add new 'data_len' parameter to mount system call.
Add an additional call with MNT_GETARGS to retrieve the modified
information instead of relying on the kernel code abusing the mount
interface during mount.


# 1.56 07-Jul-2007 pooka

Make puffs_framebuf better suited from environments with multiple sources:

* in addition add/remove, allow enable/disable, which can be used
to control events for descriptors without having to remove all the
data associated with them
* add directsend/receive, which can be used to pass the same buffer
from the caller to read/writeframe and back again
* add flags to enqueue functions and allow urgent buffers to be
processed as the next PDU


# 1.55 05-Jul-2007 pooka

* reorder calls to get results processed even if our I/O descriptors
go back to zero
* don't give up on the read-side of an fd if there is still unreceived data


# 1.54 02-Jul-2007 pooka

Get rid of the "int *refs" parameter to inactive: the same can be
accomplished now with puffs_setbacks.


# 1.53 11-Jun-2007 pooka

print a specific warning if /dev/puffs cannot be opened in init


# 1.52 06-Jun-2007 pooka

Move puffs to a two clause license where it already isn't so. And
as agc pointed out, even files with the third clause were already
effectively two clause because of a slight bug in the language...


# 1.51 21-May-2007 pooka

remember to put the results of the final operations (including unmount)
to the kernel in mainloop


# 1.50 18-May-2007 pooka

* stuff results back to kernel before calling kevent - the file server
loop function might generate some results. and this is still "after"
event handling (except for the first call, but I'm not too keen on
optimizing for that)
* don't be such a baby about EINTR from kevent(). if we get it, suck
it up and continue instead of quitting


# 1.49 17-May-2007 pooka

Reflect kernel changes for supplying root node information in mount
instead of puffs_start(). Get completely rid of puffs_start(), as
everything it used to do is now handled by the mount routine.
Introduce an optional pre-mount call puffs_setrootinfo() for setting
non-default root node information. As the old puffs_mount() is
now virtually useless, say byebye to it and rename the old
puffs_domount() to puffs_mount(), but add a root cookie parameter
to compensate for the late puffs_start().


# 1.48 16-May-2007 pooka

switch the arbitrary default errno value for network i/o from
ECONNABORTED to ECONNRESET, which is at least a little bit better


# 1.47 15-May-2007 pooka

memset freshly allocated puffs_usermount to 0


# 1.46 15-May-2007 pooka

Step 3 and currently final step of a more general purpose event loop:
support removal and addition of i/o file descriptors on the fly.

* detect closed file descriptors
* automatically free waiters of a dead file descriptor
* give the file server the possibility to specify a callback which
notifies of a dead file descriptor
* move loop function to be a property of the mainloop instead of
framebuf (doesn't change effective behaviour)
* add the possibility to configure a timespec parameter which
attempts to call the loop function periodically
* move the event loop functions from the puffs_framebuf namespace
to puffs_framev to differential between pure memory management
functions


# 1.45 11-May-2007 pooka

move puffs request dispatching code into it's own module.
no functional change


# 1.44 11-May-2007 pooka

Step 2 of general-purpose eventloop: get rid of puffs_framebuf_eventloop().
puffs_mainloop() now handles that functionality as well.


# 1.43 10-May-2007 pooka

Add some kludges to be able to execute requests on the regular program
stack instead of the continuation stack. This is for lib/36011, where
pthread gets confused since we aren't running on the regular stack.
I'm not really sure which direction to go to with this quite yet, so
make the hack hard to enable on purpose. The whole request dispatch
code needs cleaning anyway.


# 1.42 09-May-2007 pooka

Remove the puffs_usermount argument from puffs_req_handle(). It can
be found from the other arguments and this way puffs_req_handle() is
more symmetric with the other puffs_req() routines.


# 1.41 09-May-2007 pooka

Return 0 from puffs_mainloop() if no error occurs.
pointed out by Phil Nelson


# 1.40 07-May-2007 pooka

Add puffs_setback(), which can be used to set setbacks for nodes before
the call returns to the kernel. Currently it can be called only from
open(), mmap(), remove() and rmdir(). (But that might change)


# 1.39 20-Apr-2007 pooka

assert that the file server doesn't try to return more cookies than
it was supposed to


# 1.38 16-Apr-2007 pooka

alloc to set flags when setting fhsize


# 1.37 16-Apr-2007 pooka

some routines for setting mount parameters


# 1.36 13-Apr-2007 pooka

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--


# 1.35 12-Apr-2007 pooka

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().


# 1.34 11-Apr-2007 pooka

* support nodetofh and fhtonode callbacks
* use new signature of node_readdir


# 1.33 20-Mar-2007 pooka

initial support for cacheops


# 1.32 18-Feb-2007 pooka

Until someone can sort non-priviledged mounts and kauth, force
MNT_NOSUID | MNT_NODEV for mounts with geteuid() != 0. I'm tired
of typing them on the command line every time I test a file system.


# 1.31 18-Feb-2007 pooka

dump return values for operations


# 1.30 15-Feb-2007 pooka

Introduce puffs_path_walkcmp(), which is to be called from nodewalk
and compares the path of the node against the given pathobject.
Also make comparison method take a flag to indicate if it should
check if the second path is a true prefix of the first.

plus some namespace cleanup


# 1.29 15-Feb-2007 pooka

* get rid of the holy kernel-given ISDOTDOT, and instead define a
macro which does strcmp against ".." and (the untranslated)
componentname
* make PUFFS_FLAG_BUILDPATH build paths also if dotdot is the case,
and adapt the regular path objects to this
* make nullfs lookup readable because we can now get rid of dotdot
processing there


# 1.28 26-Jan-2007 pooka

add interfaces for suspending the file system


# 1.27 20-Jan-2007 pooka

Be consistent with the rest of the framework about the argument
order of puffs_docc and puffs_dopreq


# 1.26 20-Jan-2007 pooka

be consistent in naming request handlers


# 1.25 16-Jan-2007 pooka

revoke revoke


# 1.24 15-Jan-2007 pooka

Checkpoint some more work in progress: for the benefit those file
system backends which operate purely based on paths, push out more
path management into the library and make path management more
abstract: enable a file system to define a bunch of path management
callbacks, which are used by the framework. Management of normal
/this/is/a/path type paths is provided by the library.


# 1.23 11-Jan-2007 pooka

For directory renames we need to rename all the child nodes for
the given directory if the file system wants paths (PUFFS_FLAG_BUILDPATH).
Do this by walking the nodelist and adjusting the path prefix of
each matching node.


# 1.22 10-Jan-2007 pooka

* don't chdir in possible daemon() call for the benefit of file systems
which specify a relative path as the root
* if (buildpath), build link source full pathname for the duration of
the operation


# 1.21 06-Jan-2007 pooka

* get rid of the mount callback; it's no great surprise to the
server that it needs to mount the file system backend if it wants
to call mount
* provide some options for getmntopts(), assume that callers will parse
command line (or fstab) args
* reorganize the puffs_cc interface just a bit, preparing for a bigger
revamp later


# 1.20 02-Jan-2007 pooka

* inform kernel of our version
* homegrown lib ABI check (to avoid bumping major a ludicrillion times
before reaching stability)


# 1.19 29-Dec-2006 pooka

checkpoint some experimental work-in-progress, namely:

Add support for having multiple outstanding operations. This is done
by exposing enough interfaces so that it is convenient to have the
main event loop in the implementation itself and by providing a
continuation framework for convinient blocking and rescheduling.

works fine, but will undergo further cleanup & development


# 1.18 14-Dec-2006 alc

CID4360: don't leak `buf' upon return
ok pooka@


# 1.17 07-Dec-2006 pooka

outline & export code for interfacing with kernel GET/PUT requests


# 1.16 07-Dec-2006 pooka

g/c out-of-date comment


# 1.15 07-Dec-2006 pooka

support mmap


# 1.14 07-Dec-2006 pooka

cleanup generated stuff from comments


# 1.13 07-Dec-2006 pooka

rototill the operation callbacks: unify the ops under struct puffs_ops
and namespace them


# 1.12 05-Dec-2006 pooka

adapt to kernel change:
Allow multiple requests to be transferred in each GET/PUTOP


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base netbsd-4-base
# 1.11 01-Dec-2006 pooka

PUFFSFLAG -> PUFFS_FLAG to be consistent with the kernel


# 1.10 01-Dec-2006 pooka

build & send implemented operations list to kernel


# 1.9 30-Nov-2006 pooka

summon daemon(3) in mainloop unless the nodaemon flag is given


# 1.8 18-Nov-2006 pooka

* call statvfs() at mount() time, pass that info along
* start is gone


# 1.7 17-Nov-2006 pooka

shuffle flags a bit


# 1.6 09-Nov-2006 pooka

* catch up with kernel changes
* better error handling when mounting


# 1.5 07-Nov-2006 pooka

* support FAF (Fire-And-Forget) class operations
* adapt to new lookup


# 1.4 26-Oct-2006 pooka

pass rdev for specfs support


# 1.3 25-Oct-2006 pooka

handle PUFFS_VN_INACTIVE


# 1.2 23-Oct-2006 christos

pass lint; fix install.


# 1.1 22-Oct-2006 pooka

add libpuffs - the userspace programming interface for puffs

This work was initially started and completed for Google SoC 2005
and tweaked to work a bit better in the past few weeks. While
being far from complete, it is functional enough to be able and
stable to host a fairly general-purpose in-memory file system in
userspace. Even so, puffs should be considered experimental and
no binary compatibility for interfaces or crash-freedom or zero
security implications should be relied upon just yet.

The GSoC project was mentored by William Studenmund and the final
review for the code was done by Christos.


# 1.123 08-Feb-2018 dholland

Typos.


# 1.122 05-Nov-2017 christos

fix error messages (use __func__, quotes)
also differentiate between canonical and non-relative.


Revision tags: matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base
# 1.121 31-May-2017 christos

Adjust to prototype.


Revision tags: prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.120 17-Jun-2015 christos

fix error messages


# 1.119 22-Dec-2014 manu

Do not warn about relative path because of trailing slash

libpuffs calls realpath() to obtain an absolute path to use for mounting.
If the obtained path is different from the one given by the caller, a
warning is issued. This included the situation where the path passed by
the caller just have trailing slashes, a situation where we just want them
to be striped without a warning.


# 1.118 31-Oct-2014 manu

libpuffs support for fallocate and fdiscard operations


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-7-base yamt-pagecache-base9 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 agc-symver-base netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 tls-maxphys-base matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base
# 1.117 14-Nov-2011 chs

branches: 1.117.18;
fix crashes caused by using the results of getcontext()
after the caller returns.


Revision tags: yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base cherry-xenmp-base
# 1.116 03-May-2011 manu

branches: 1.116.4;
Call advlock method if supplied


Revision tags: bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231
# 1.115 06-Dec-2010 pooka

Remove PUFFS_WITH_THREADS ifdef garbage, just use libc weak symbols.


# 1.114 06-Jul-2010 pooka

unwhine lint


# 1.113 06-Jul-2010 pooka

stat mount target path only if we're actually goint to use it.
This avoids errors from the comfd case when the mount target does
not exist in our local namespace.


# 1.112 06-Jul-2010 pooka

set time_t compat where necessary


# 1.111 06-Jul-2010 pooka

When using the top secret PUFFS_COMFD model, write out size of the
puffs kernel args before the contents. This allows parties which
have no clue about the contents to proxy the protocol easily.


# 1.110 07-Jun-2010 pooka

Reenable pathconf now that the retval argument is register_t.


# 1.109 06-Jun-2010 pooka

Actually, disable pathconf for a while longer: the retval needs a
little finetuning (not that everyone is jumping right to using it,
but fixing will have to wait until tomorrow, and who knows what
i'll forget during the night and how long it will eventually take).


# 1.108 06-Jun-2010 pooka

signal pathconf in the vector of supported ops


# 1.107 21-May-2010 pooka

* support extended attributes
* bump major due to structure growth
* add some spare space
* remove ABI sillyness


# 1.106 19-May-2010 pooka

remove three years out-of-date comment


# 1.105 12-Jan-2010 pooka

Add convenience routine puffs_unmountonsignal(), which does exactly that.


# 1.104 07-Jan-2010 pooka

Use typecast instead of ULL for a less whiny lint on LP64.


# 1.103 07-Jan-2010 pooka

Rewrite puffs_exit() in terms of the PUFFSOP_UNMOUNT kernel request.
Now server exit is a lot quite cleaner than previously.


# 1.102 07-Jan-2010 pooka

Set high bit on server->kernel requests to better differentiate
between the direction of the request.


Revision tags: matt-premerge-20091211
# 1.101 05-Dec-2009 pooka

Add an error handler which syslogs but does not abort() and make it
the default. Most servers just shovel bits from their backend to
the kernel without checking the contents and dumping core in case
the backend gives garbage is a bit harsh.


# 1.100 18-Oct-2009 pooka

Make it possible to supply parameters to puffs_init() later (but
before puffs_mount()).


# 1.99 17-Oct-2009 pooka

Dispatch puffs_node_abortop().

Note: We use the storage of puffs_cache_write from puffs_ops for
this purpose. It's not issued by the kernel and hence currently
unused, and this saves us from the trouble of bumping the lib major
version.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.98 08-Jan-2009 lukem

fix some sign comparison warnings


# 1.97 13-Dec-2008 dsl

Actually we need 'long int' to avoif a stupid 'truncating long to int'
warning.


# 1.96 13-Dec-2008 dsl

Change type of 'n' to 'int' so that it can be printed with %d.
The domain of the value is [-1..sizeof (int)] so a type of 'int' is fine.


# 1.95 12-Dec-2008 pooka

Close write-end of daemonpipe in reader to get EOF if the writer
goes awol.


# 1.94 12-Dec-2008 pooka

Add puffs_cancel(), which allows to back down after puffs_init()
and before puffs_mount().
(this should actually be integrated with puffs_exit(), but that
routine is currently so non-sensible that I didn't bother now)


# 1.93 12-Dec-2008 pooka

add:
puffs_setspecific(pu, private)
Can be used to set the specific data after the call to
puffs_init().


Revision tags: netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.92 12-Aug-2008 pooka

branches: 1.92.4; 1.92.8;
Replace void * by puffs_cookie_t where appropriate. No functional change.


# 1.91 11-Aug-2008 pooka

clear cached puffs_cc's in puffs_exit()


# 1.90 11-Aug-2008 pooka

* make sure we come out of mainloop in the main context. otherwise in
certain cases the server would jump to hyperspace when unmounted
* sprinkle some debug prints


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base keiichi-mipv6-base matt-armv6-nbase hpcarm-cleanup-base
# 1.89 28-Jan-2008 pooka

branches: 1.89.6;
Implement lazy contexts for file systems using puffs_mainloop().
Previously each request was executed on its own callcontext and
switched to every time the request was being processed. Now requests
borrow the mainloop context and switch only if/when they yield.
This takes two context switches away from a file system request
bringing down the typical amounts 2->0 (e.g. dtfs) and 4->2 (e.g.
psshfs).

The interfaces for manually executing requests changed a bit:
puffs_dispatch_create() and puffs_dispatch_exec() must now be used.
They are not tested, as nothing in-tree wants them and I doubt
anyone else is really interested in them either.

Also do some misc code cleanup related to execution contexts. The
"work-in-progress checkpoint" committed over a year ago was starting
to look slightly weed-infested.


# 1.88 16-Jan-2008 pooka

Cache a number of execution contexts instead of re-initializing
them every time. Speeds up pure in-memory file systems such as
sysctlfs or dtfs quite a bit. For actual I/O-workhorses the result
is of course less tasty.


# 1.87 16-Jan-2008 pooka

Use PROT_NONE page to protect bottom of stack from overrun


# 1.86 14-Jan-2008 pooka

Introduce PUFFS_STACKSIZE_MIN to avoid overloading 0 and getting
a warning from the library when really wanting to say "just the
minimum, please".


Revision tags: matt-armv6-base
# 1.85 08-Jan-2008 pooka

liberate gas-huffin crack-puffin' assert


# 1.84 02-Jan-2008 pooka

fix pasto


# 1.83 02-Jan-2008 pooka

Also pass fromname in the "distributed" case.


# 1.82 02-Jan-2008 pooka

Provide some transparent "support" for "distributed" file systems.
If the env variable PUFFS_COMFD is set, the descriptor value
contained in it is used for communication instead of opening
/dev/puffs and doing mount(2).

This feature is obviously very undocumented and should not be used
without adult supervision.


# 1.81 25-Dec-2007 pooka

Add a public interface for setting a cookie mapper.


Revision tags: cube-autoconf-base
# 1.80 05-Dec-2007 pooka

Send a response message for flush operations from the kernel instead
of abusing the return value of write(2).


# 1.79 04-Dec-2007 pooka

Part 3/n of extensive changes to message handling:

Get rid of the original puffs_req(3) framework and use puffs_framebuf(3)
instead for file system requests. It has the advantage of being
suitable for transporting a distributed message passing protocol
and therefore us being able to run the file system server on any
host.

Ok, puffs is not quite here yet: libpuffs needs to grow request
routing support and the message contents need to be munged into a
host independent format. Saying which format would be telling,
but it might begin with an X, end in an L and have the 13th character
in the middle. Keep an eye out for the sequels: Parts 3+m/n.


# 1.78 29-Nov-2007 pooka

* allocate pcc as a slice from the stack instead of allocating it
separately
* provide puffs_cc_getcc()

This is in preparation for the removal of you-should-guess-what as
an argument to routines here and there and everywhere.


# 1.77 26-Nov-2007 pooka

print more info when receiving an abort


# 1.76 17-Nov-2007 pooka

puffs_mount():
* initialize values better
* always go through "fail" to see if puffs_daemon() needs to be
woken up
* open device r/w instead of r/o


# 1.75 16-Nov-2007 pooka

Introduce puffs_daemon(), which works like daemon(3) except that it
also synchronizes with puffs_mount() and does not return (exit) in the
parent process until the file system has been mounted. This makes
it possible to reliably run e.g. mount_foo jippi /kai ; cd /kai/ee


# 1.74 06-Nov-2007 pooka

Open the kernel descriptor as part of mount(), not init(). Then
it doesn't matter if someone fork()s or does other tricks between
init() and mount() (and besides, now it's where it logically should be).


# 1.73 05-Nov-2007 pooka

Pull the daemonizing code out of the library mainloop into the file
servers. Calling daemon() (i.e. fork()ing) inside a library can
cause nice surprises for e.g. threaded programs. As discussed with
Greg Oster & others.


# 1.72 29-Oct-2007 pooka

Sprinkle some hackish locks here and there, just enough to allow
libp2k & rump to run multithreaded.


# 1.71 28-Oct-2007 pooka

Add possibility to set pre- and post callbacks which will be called
for all operations before or after executing the specific callback
(the api is not be final yet, though).


# 1.70 26-Oct-2007 pooka

Add some very initial support for a threading worker model as an
alternative to the (vastly superior ;) continuation model. This
is very preliminary stuff and not compiled by default (which it
even won't do without some other patches I cannot commit yet).

The raison d'commit of the patch is a snippet which ensures proper
in-order dispatching of all operations, including those which don't
require a response. Previously many of them would be dispatched
simultaneosly, e.g. fsync and reclaim on the same node, which
obviously isn't all that nice for correct operation.


# 1.69 26-Oct-2007 pooka

mmap stacks, makes it possible to align them


# 1.68 25-Oct-2007 pooka

Make pu_haskq a flag instead of its own variable.


# 1.67 21-Oct-2007 pooka

Add puffs_cc_schedule() which marks a pcc runnable and will pass
execution to it when in the main loop the next time.


# 1.66 11-Oct-2007 pooka

Part 1/n of some pretty extensive changes to how the kernel module
interacts with the userspace file server:

* since the kernel-user communication is not purely request-response
anymore (hasn't been since 2006), try to rename some "request" to
"message". more similar mangling will take place in the future.

* completely rework how messages are allocated. previously most of
them were borrowed from the stack (originally *all* of them),
but now always allocate dynamically. this makes the structure
of the code much cleaner. also makes it possible to fix a
locking order violation. it enables plenty of future enhancements.

* start generalizing the transport interface to be independent of puffs

* move transport interface to read/write instead of ioctl. the
old one had legacy design problems, and besides, ioctl's suck.
implement a very generic version for now; this will be
worked on later hopefully some day reaching "highly optimized".

* implement libpuffs support behind existing library request
interfaces. this will change eventually (I hate those interfaces)


# 1.65 01-Oct-2007 pooka

Pass reason string to pu_errnotify. Print it in the default
version before aborting.


# 1.64 27-Sep-2007 pooka

silence lint. also noticed by xtraeme


# 1.63 27-Sep-2007 pooka

Add error notifications, which are used to deliver errors from the
kernel to the file server for silly things the file server did,
e.g. attempting to create a file with size VSIZENOTSET. The file
server can handle these as it chooses, but the default action is
for it to throw its hands in the air and sing "goodbye, cruel world,
it's over, walk on by".


# 1.62 11-Aug-2007 pooka

branches: 1.62.2;
run realpath() on the mountpath


Revision tags: matt-mips64-base
# 1.61 20-Jul-2007 pooka

branches: 1.61.4;
Add puffs_framev_enqueue_waitevent, which waits for read/write/error
events from an i/o descriptor. It yields until an event happens
and continues execution when the event loop notices the event has
happened.


# 1.60 19-Jul-2007 pooka

Don't float puffs_kargs needlessly around after mount, saves
a couple k of memory (and there was much rejoycing!)


# 1.59 19-Jul-2007 pooka

Use ioctl(PUFFSREQSIZEOP) instead of mount(MNT_GETARGS) to fetch
the maximum request size after mount. Calling mount(MNT_GETARGS)
from the file server is currently not kosher, as it vrele()s the
root vnode, potentially causing an inactive, which the file server
cannot handle while it itself is inactive in the kernel (deadlock).


# 1.58 17-Jul-2007 pooka

* add mntfromname parameter to puffs_init()
* set it in file servers


# 1.57 14-Jul-2007 dsl

Add new 'data_len' parameter to mount system call.
Add an additional call with MNT_GETARGS to retrieve the modified
information instead of relying on the kernel code abusing the mount
interface during mount.


# 1.56 07-Jul-2007 pooka

Make puffs_framebuf better suited from environments with multiple sources:

* in addition add/remove, allow enable/disable, which can be used
to control events for descriptors without having to remove all the
data associated with them
* add directsend/receive, which can be used to pass the same buffer
from the caller to read/writeframe and back again
* add flags to enqueue functions and allow urgent buffers to be
processed as the next PDU


# 1.55 05-Jul-2007 pooka

* reorder calls to get results processed even if our I/O descriptors
go back to zero
* don't give up on the read-side of an fd if there is still unreceived data


# 1.54 02-Jul-2007 pooka

Get rid of the "int *refs" parameter to inactive: the same can be
accomplished now with puffs_setbacks.


# 1.53 11-Jun-2007 pooka

print a specific warning if /dev/puffs cannot be opened in init


# 1.52 06-Jun-2007 pooka

Move puffs to a two clause license where it already isn't so. And
as agc pointed out, even files with the third clause were already
effectively two clause because of a slight bug in the language...


# 1.51 21-May-2007 pooka

remember to put the results of the final operations (including unmount)
to the kernel in mainloop


# 1.50 18-May-2007 pooka

* stuff results back to kernel before calling kevent - the file server
loop function might generate some results. and this is still "after"
event handling (except for the first call, but I'm not too keen on
optimizing for that)
* don't be such a baby about EINTR from kevent(). if we get it, suck
it up and continue instead of quitting


# 1.49 17-May-2007 pooka

Reflect kernel changes for supplying root node information in mount
instead of puffs_start(). Get completely rid of puffs_start(), as
everything it used to do is now handled by the mount routine.
Introduce an optional pre-mount call puffs_setrootinfo() for setting
non-default root node information. As the old puffs_mount() is
now virtually useless, say byebye to it and rename the old
puffs_domount() to puffs_mount(), but add a root cookie parameter
to compensate for the late puffs_start().


# 1.48 16-May-2007 pooka

switch the arbitrary default errno value for network i/o from
ECONNABORTED to ECONNRESET, which is at least a little bit better


# 1.47 15-May-2007 pooka

memset freshly allocated puffs_usermount to 0


# 1.46 15-May-2007 pooka

Step 3 and currently final step of a more general purpose event loop:
support removal and addition of i/o file descriptors on the fly.

* detect closed file descriptors
* automatically free waiters of a dead file descriptor
* give the file server the possibility to specify a callback which
notifies of a dead file descriptor
* move loop function to be a property of the mainloop instead of
framebuf (doesn't change effective behaviour)
* add the possibility to configure a timespec parameter which
attempts to call the loop function periodically
* move the event loop functions from the puffs_framebuf namespace
to puffs_framev to differential between pure memory management
functions


# 1.45 11-May-2007 pooka

move puffs request dispatching code into it's own module.
no functional change


# 1.44 11-May-2007 pooka

Step 2 of general-purpose eventloop: get rid of puffs_framebuf_eventloop().
puffs_mainloop() now handles that functionality as well.


# 1.43 10-May-2007 pooka

Add some kludges to be able to execute requests on the regular program
stack instead of the continuation stack. This is for lib/36011, where
pthread gets confused since we aren't running on the regular stack.
I'm not really sure which direction to go to with this quite yet, so
make the hack hard to enable on purpose. The whole request dispatch
code needs cleaning anyway.


# 1.42 09-May-2007 pooka

Remove the puffs_usermount argument from puffs_req_handle(). It can
be found from the other arguments and this way puffs_req_handle() is
more symmetric with the other puffs_req() routines.


# 1.41 09-May-2007 pooka

Return 0 from puffs_mainloop() if no error occurs.
pointed out by Phil Nelson


# 1.40 07-May-2007 pooka

Add puffs_setback(), which can be used to set setbacks for nodes before
the call returns to the kernel. Currently it can be called only from
open(), mmap(), remove() and rmdir(). (But that might change)


# 1.39 20-Apr-2007 pooka

assert that the file server doesn't try to return more cookies than
it was supposed to


# 1.38 16-Apr-2007 pooka

alloc to set flags when setting fhsize


# 1.37 16-Apr-2007 pooka

some routines for setting mount parameters


# 1.36 13-Apr-2007 pooka

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--


# 1.35 12-Apr-2007 pooka

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().


# 1.34 11-Apr-2007 pooka

* support nodetofh and fhtonode callbacks
* use new signature of node_readdir


# 1.33 20-Mar-2007 pooka

initial support for cacheops


# 1.32 18-Feb-2007 pooka

Until someone can sort non-priviledged mounts and kauth, force
MNT_NOSUID | MNT_NODEV for mounts with geteuid() != 0. I'm tired
of typing them on the command line every time I test a file system.


# 1.31 18-Feb-2007 pooka

dump return values for operations


# 1.30 15-Feb-2007 pooka

Introduce puffs_path_walkcmp(), which is to be called from nodewalk
and compares the path of the node against the given pathobject.
Also make comparison method take a flag to indicate if it should
check if the second path is a true prefix of the first.

plus some namespace cleanup


# 1.29 15-Feb-2007 pooka

* get rid of the holy kernel-given ISDOTDOT, and instead define a
macro which does strcmp against ".." and (the untranslated)
componentname
* make PUFFS_FLAG_BUILDPATH build paths also if dotdot is the case,
and adapt the regular path objects to this
* make nullfs lookup readable because we can now get rid of dotdot
processing there


# 1.28 26-Jan-2007 pooka

add interfaces for suspending the file system


# 1.27 20-Jan-2007 pooka

Be consistent with the rest of the framework about the argument
order of puffs_docc and puffs_dopreq


# 1.26 20-Jan-2007 pooka

be consistent in naming request handlers


# 1.25 16-Jan-2007 pooka

revoke revoke


# 1.24 15-Jan-2007 pooka

Checkpoint some more work in progress: for the benefit those file
system backends which operate purely based on paths, push out more
path management into the library and make path management more
abstract: enable a file system to define a bunch of path management
callbacks, which are used by the framework. Management of normal
/this/is/a/path type paths is provided by the library.


# 1.23 11-Jan-2007 pooka

For directory renames we need to rename all the child nodes for
the given directory if the file system wants paths (PUFFS_FLAG_BUILDPATH).
Do this by walking the nodelist and adjusting the path prefix of
each matching node.


# 1.22 10-Jan-2007 pooka

* don't chdir in possible daemon() call for the benefit of file systems
which specify a relative path as the root
* if (buildpath), build link source full pathname for the duration of
the operation


# 1.21 06-Jan-2007 pooka

* get rid of the mount callback; it's no great surprise to the
server that it needs to mount the file system backend if it wants
to call mount
* provide some options for getmntopts(), assume that callers will parse
command line (or fstab) args
* reorganize the puffs_cc interface just a bit, preparing for a bigger
revamp later


# 1.20 02-Jan-2007 pooka

* inform kernel of our version
* homegrown lib ABI check (to avoid bumping major a ludicrillion times
before reaching stability)


# 1.19 29-Dec-2006 pooka

checkpoint some experimental work-in-progress, namely:

Add support for having multiple outstanding operations. This is done
by exposing enough interfaces so that it is convenient to have the
main event loop in the implementation itself and by providing a
continuation framework for convinient blocking and rescheduling.

works fine, but will undergo further cleanup & development


# 1.18 14-Dec-2006 alc

CID4360: don't leak `buf' upon return
ok pooka@


# 1.17 07-Dec-2006 pooka

outline & export code for interfacing with kernel GET/PUT requests


# 1.16 07-Dec-2006 pooka

g/c out-of-date comment


# 1.15 07-Dec-2006 pooka

support mmap


# 1.14 07-Dec-2006 pooka

cleanup generated stuff from comments


# 1.13 07-Dec-2006 pooka

rototill the operation callbacks: unify the ops under struct puffs_ops
and namespace them


# 1.12 05-Dec-2006 pooka

adapt to kernel change:
Allow multiple requests to be transferred in each GET/PUTOP


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base netbsd-4-base
# 1.11 01-Dec-2006 pooka

PUFFSFLAG -> PUFFS_FLAG to be consistent with the kernel


# 1.10 01-Dec-2006 pooka

build & send implemented operations list to kernel


# 1.9 30-Nov-2006 pooka

summon daemon(3) in mainloop unless the nodaemon flag is given


# 1.8 18-Nov-2006 pooka

* call statvfs() at mount() time, pass that info along
* start is gone


# 1.7 17-Nov-2006 pooka

shuffle flags a bit


# 1.6 09-Nov-2006 pooka

* catch up with kernel changes
* better error handling when mounting


# 1.5 07-Nov-2006 pooka

* support FAF (Fire-And-Forget) class operations
* adapt to new lookup


# 1.4 26-Oct-2006 pooka

pass rdev for specfs support


# 1.3 25-Oct-2006 pooka

handle PUFFS_VN_INACTIVE


# 1.2 23-Oct-2006 christos

pass lint; fix install.


# 1.1 22-Oct-2006 pooka

add libpuffs - the userspace programming interface for puffs

This work was initially started and completed for Google SoC 2005
and tweaked to work a bit better in the past few weeks. While
being far from complete, it is functional enough to be able and
stable to host a fairly general-purpose in-memory file system in
userspace. Even so, puffs should be considered experimental and
no binary compatibility for interfaces or crash-freedom or zero
security implications should be relied upon just yet.

The GSoC project was mentored by William Studenmund and the final
review for the code was done by Christos.


# 1.122 05-Nov-2017 christos

fix error messages (use __func__, quotes)
also differentiate between canonical and non-relative.


Revision tags: matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base
# 1.121 31-May-2017 christos

Adjust to prototype.


Revision tags: prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.120 17-Jun-2015 christos

fix error messages


# 1.119 22-Dec-2014 manu

Do not warn about relative path because of trailing slash

libpuffs calls realpath() to obtain an absolute path to use for mounting.
If the obtained path is different from the one given by the caller, a
warning is issued. This included the situation where the path passed by
the caller just have trailing slashes, a situation where we just want them
to be striped without a warning.


# 1.118 31-Oct-2014 manu

libpuffs support for fallocate and fdiscard operations


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-7-base yamt-pagecache-base9 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 agc-symver-base netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 tls-maxphys-base matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base
# 1.117 14-Nov-2011 chs

branches: 1.117.18;
fix crashes caused by using the results of getcontext()
after the caller returns.


Revision tags: yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base cherry-xenmp-base
# 1.116 03-May-2011 manu

branches: 1.116.4;
Call advlock method if supplied


Revision tags: bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231
# 1.115 06-Dec-2010 pooka

Remove PUFFS_WITH_THREADS ifdef garbage, just use libc weak symbols.


# 1.114 06-Jul-2010 pooka

unwhine lint


# 1.113 06-Jul-2010 pooka

stat mount target path only if we're actually goint to use it.
This avoids errors from the comfd case when the mount target does
not exist in our local namespace.


# 1.112 06-Jul-2010 pooka

set time_t compat where necessary


# 1.111 06-Jul-2010 pooka

When using the top secret PUFFS_COMFD model, write out size of the
puffs kernel args before the contents. This allows parties which
have no clue about the contents to proxy the protocol easily.


# 1.110 07-Jun-2010 pooka

Reenable pathconf now that the retval argument is register_t.


# 1.109 06-Jun-2010 pooka

Actually, disable pathconf for a while longer: the retval needs a
little finetuning (not that everyone is jumping right to using it,
but fixing will have to wait until tomorrow, and who knows what
i'll forget during the night and how long it will eventually take).


# 1.108 06-Jun-2010 pooka

signal pathconf in the vector of supported ops


# 1.107 21-May-2010 pooka

* support extended attributes
* bump major due to structure growth
* add some spare space
* remove ABI sillyness


# 1.106 19-May-2010 pooka

remove three years out-of-date comment


# 1.105 12-Jan-2010 pooka

Add convenience routine puffs_unmountonsignal(), which does exactly that.


# 1.104 07-Jan-2010 pooka

Use typecast instead of ULL for a less whiny lint on LP64.


# 1.103 07-Jan-2010 pooka

Rewrite puffs_exit() in terms of the PUFFSOP_UNMOUNT kernel request.
Now server exit is a lot quite cleaner than previously.


# 1.102 07-Jan-2010 pooka

Set high bit on server->kernel requests to better differentiate
between the direction of the request.


Revision tags: matt-premerge-20091211
# 1.101 05-Dec-2009 pooka

Add an error handler which syslogs but does not abort() and make it
the default. Most servers just shovel bits from their backend to
the kernel without checking the contents and dumping core in case
the backend gives garbage is a bit harsh.


# 1.100 18-Oct-2009 pooka

Make it possible to supply parameters to puffs_init() later (but
before puffs_mount()).


# 1.99 17-Oct-2009 pooka

Dispatch puffs_node_abortop().

Note: We use the storage of puffs_cache_write from puffs_ops for
this purpose. It's not issued by the kernel and hence currently
unused, and this saves us from the trouble of bumping the lib major
version.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.98 08-Jan-2009 lukem

fix some sign comparison warnings


# 1.97 13-Dec-2008 dsl

Actually we need 'long int' to avoif a stupid 'truncating long to int'
warning.


# 1.96 13-Dec-2008 dsl

Change type of 'n' to 'int' so that it can be printed with %d.
The domain of the value is [-1..sizeof (int)] so a type of 'int' is fine.


# 1.95 12-Dec-2008 pooka

Close write-end of daemonpipe in reader to get EOF if the writer
goes awol.


# 1.94 12-Dec-2008 pooka

Add puffs_cancel(), which allows to back down after puffs_init()
and before puffs_mount().
(this should actually be integrated with puffs_exit(), but that
routine is currently so non-sensible that I didn't bother now)


# 1.93 12-Dec-2008 pooka

add:
puffs_setspecific(pu, private)
Can be used to set the specific data after the call to
puffs_init().


Revision tags: netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.92 12-Aug-2008 pooka

branches: 1.92.4; 1.92.8;
Replace void * by puffs_cookie_t where appropriate. No functional change.


# 1.91 11-Aug-2008 pooka

clear cached puffs_cc's in puffs_exit()


# 1.90 11-Aug-2008 pooka

* make sure we come out of mainloop in the main context. otherwise in
certain cases the server would jump to hyperspace when unmounted
* sprinkle some debug prints


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base keiichi-mipv6-base matt-armv6-nbase hpcarm-cleanup-base
# 1.89 28-Jan-2008 pooka

branches: 1.89.6;
Implement lazy contexts for file systems using puffs_mainloop().
Previously each request was executed on its own callcontext and
switched to every time the request was being processed. Now requests
borrow the mainloop context and switch only if/when they yield.
This takes two context switches away from a file system request
bringing down the typical amounts 2->0 (e.g. dtfs) and 4->2 (e.g.
psshfs).

The interfaces for manually executing requests changed a bit:
puffs_dispatch_create() and puffs_dispatch_exec() must now be used.
They are not tested, as nothing in-tree wants them and I doubt
anyone else is really interested in them either.

Also do some misc code cleanup related to execution contexts. The
"work-in-progress checkpoint" committed over a year ago was starting
to look slightly weed-infested.


# 1.88 16-Jan-2008 pooka

Cache a number of execution contexts instead of re-initializing
them every time. Speeds up pure in-memory file systems such as
sysctlfs or dtfs quite a bit. For actual I/O-workhorses the result
is of course less tasty.


# 1.87 16-Jan-2008 pooka

Use PROT_NONE page to protect bottom of stack from overrun


# 1.86 14-Jan-2008 pooka

Introduce PUFFS_STACKSIZE_MIN to avoid overloading 0 and getting
a warning from the library when really wanting to say "just the
minimum, please".


Revision tags: matt-armv6-base
# 1.85 08-Jan-2008 pooka

liberate gas-huffin crack-puffin' assert


# 1.84 02-Jan-2008 pooka

fix pasto


# 1.83 02-Jan-2008 pooka

Also pass fromname in the "distributed" case.


# 1.82 02-Jan-2008 pooka

Provide some transparent "support" for "distributed" file systems.
If the env variable PUFFS_COMFD is set, the descriptor value
contained in it is used for communication instead of opening
/dev/puffs and doing mount(2).

This feature is obviously very undocumented and should not be used
without adult supervision.


# 1.81 25-Dec-2007 pooka

Add a public interface for setting a cookie mapper.


Revision tags: cube-autoconf-base
# 1.80 05-Dec-2007 pooka

Send a response message for flush operations from the kernel instead
of abusing the return value of write(2).


# 1.79 04-Dec-2007 pooka

Part 3/n of extensive changes to message handling:

Get rid of the original puffs_req(3) framework and use puffs_framebuf(3)
instead for file system requests. It has the advantage of being
suitable for transporting a distributed message passing protocol
and therefore us being able to run the file system server on any
host.

Ok, puffs is not quite here yet: libpuffs needs to grow request
routing support and the message contents need to be munged into a
host independent format. Saying which format would be telling,
but it might begin with an X, end in an L and have the 13th character
in the middle. Keep an eye out for the sequels: Parts 3+m/n.


# 1.78 29-Nov-2007 pooka

* allocate pcc as a slice from the stack instead of allocating it
separately
* provide puffs_cc_getcc()

This is in preparation for the removal of you-should-guess-what as
an argument to routines here and there and everywhere.


# 1.77 26-Nov-2007 pooka

print more info when receiving an abort


# 1.76 17-Nov-2007 pooka

puffs_mount():
* initialize values better
* always go through "fail" to see if puffs_daemon() needs to be
woken up
* open device r/w instead of r/o


# 1.75 16-Nov-2007 pooka

Introduce puffs_daemon(), which works like daemon(3) except that it
also synchronizes with puffs_mount() and does not return (exit) in the
parent process until the file system has been mounted. This makes
it possible to reliably run e.g. mount_foo jippi /kai ; cd /kai/ee


# 1.74 06-Nov-2007 pooka

Open the kernel descriptor as part of mount(), not init(). Then
it doesn't matter if someone fork()s or does other tricks between
init() and mount() (and besides, now it's where it logically should be).


# 1.73 05-Nov-2007 pooka

Pull the daemonizing code out of the library mainloop into the file
servers. Calling daemon() (i.e. fork()ing) inside a library can
cause nice surprises for e.g. threaded programs. As discussed with
Greg Oster & others.


# 1.72 29-Oct-2007 pooka

Sprinkle some hackish locks here and there, just enough to allow
libp2k & rump to run multithreaded.


# 1.71 28-Oct-2007 pooka

Add possibility to set pre- and post callbacks which will be called
for all operations before or after executing the specific callback
(the api is not be final yet, though).


# 1.70 26-Oct-2007 pooka

Add some very initial support for a threading worker model as an
alternative to the (vastly superior ;) continuation model. This
is very preliminary stuff and not compiled by default (which it
even won't do without some other patches I cannot commit yet).

The raison d'commit of the patch is a snippet which ensures proper
in-order dispatching of all operations, including those which don't
require a response. Previously many of them would be dispatched
simultaneosly, e.g. fsync and reclaim on the same node, which
obviously isn't all that nice for correct operation.


# 1.69 26-Oct-2007 pooka

mmap stacks, makes it possible to align them


# 1.68 25-Oct-2007 pooka

Make pu_haskq a flag instead of its own variable.


# 1.67 21-Oct-2007 pooka

Add puffs_cc_schedule() which marks a pcc runnable and will pass
execution to it when in the main loop the next time.


# 1.66 11-Oct-2007 pooka

Part 1/n of some pretty extensive changes to how the kernel module
interacts with the userspace file server:

* since the kernel-user communication is not purely request-response
anymore (hasn't been since 2006), try to rename some "request" to
"message". more similar mangling will take place in the future.

* completely rework how messages are allocated. previously most of
them were borrowed from the stack (originally *all* of them),
but now always allocate dynamically. this makes the structure
of the code much cleaner. also makes it possible to fix a
locking order violation. it enables plenty of future enhancements.

* start generalizing the transport interface to be independent of puffs

* move transport interface to read/write instead of ioctl. the
old one had legacy design problems, and besides, ioctl's suck.
implement a very generic version for now; this will be
worked on later hopefully some day reaching "highly optimized".

* implement libpuffs support behind existing library request
interfaces. this will change eventually (I hate those interfaces)


# 1.65 01-Oct-2007 pooka

Pass reason string to pu_errnotify. Print it in the default
version before aborting.


# 1.64 27-Sep-2007 pooka

silence lint. also noticed by xtraeme


# 1.63 27-Sep-2007 pooka

Add error notifications, which are used to deliver errors from the
kernel to the file server for silly things the file server did,
e.g. attempting to create a file with size VSIZENOTSET. The file
server can handle these as it chooses, but the default action is
for it to throw its hands in the air and sing "goodbye, cruel world,
it's over, walk on by".


# 1.62 11-Aug-2007 pooka

branches: 1.62.2;
run realpath() on the mountpath


Revision tags: matt-mips64-base
# 1.61 20-Jul-2007 pooka

branches: 1.61.4;
Add puffs_framev_enqueue_waitevent, which waits for read/write/error
events from an i/o descriptor. It yields until an event happens
and continues execution when the event loop notices the event has
happened.


# 1.60 19-Jul-2007 pooka

Don't float puffs_kargs needlessly around after mount, saves
a couple k of memory (and there was much rejoycing!)


# 1.59 19-Jul-2007 pooka

Use ioctl(PUFFSREQSIZEOP) instead of mount(MNT_GETARGS) to fetch
the maximum request size after mount. Calling mount(MNT_GETARGS)
from the file server is currently not kosher, as it vrele()s the
root vnode, potentially causing an inactive, which the file server
cannot handle while it itself is inactive in the kernel (deadlock).


# 1.58 17-Jul-2007 pooka

* add mntfromname parameter to puffs_init()
* set it in file servers


# 1.57 14-Jul-2007 dsl

Add new 'data_len' parameter to mount system call.
Add an additional call with MNT_GETARGS to retrieve the modified
information instead of relying on the kernel code abusing the mount
interface during mount.


# 1.56 07-Jul-2007 pooka

Make puffs_framebuf better suited from environments with multiple sources:

* in addition add/remove, allow enable/disable, which can be used
to control events for descriptors without having to remove all the
data associated with them
* add directsend/receive, which can be used to pass the same buffer
from the caller to read/writeframe and back again
* add flags to enqueue functions and allow urgent buffers to be
processed as the next PDU


# 1.55 05-Jul-2007 pooka

* reorder calls to get results processed even if our I/O descriptors
go back to zero
* don't give up on the read-side of an fd if there is still unreceived data


# 1.54 02-Jul-2007 pooka

Get rid of the "int *refs" parameter to inactive: the same can be
accomplished now with puffs_setbacks.


# 1.53 11-Jun-2007 pooka

print a specific warning if /dev/puffs cannot be opened in init


# 1.52 06-Jun-2007 pooka

Move puffs to a two clause license where it already isn't so. And
as agc pointed out, even files with the third clause were already
effectively two clause because of a slight bug in the language...


# 1.51 21-May-2007 pooka

remember to put the results of the final operations (including unmount)
to the kernel in mainloop


# 1.50 18-May-2007 pooka

* stuff results back to kernel before calling kevent - the file server
loop function might generate some results. and this is still "after"
event handling (except for the first call, but I'm not too keen on
optimizing for that)
* don't be such a baby about EINTR from kevent(). if we get it, suck
it up and continue instead of quitting


# 1.49 17-May-2007 pooka

Reflect kernel changes for supplying root node information in mount
instead of puffs_start(). Get completely rid of puffs_start(), as
everything it used to do is now handled by the mount routine.
Introduce an optional pre-mount call puffs_setrootinfo() for setting
non-default root node information. As the old puffs_mount() is
now virtually useless, say byebye to it and rename the old
puffs_domount() to puffs_mount(), but add a root cookie parameter
to compensate for the late puffs_start().


# 1.48 16-May-2007 pooka

switch the arbitrary default errno value for network i/o from
ECONNABORTED to ECONNRESET, which is at least a little bit better


# 1.47 15-May-2007 pooka

memset freshly allocated puffs_usermount to 0


# 1.46 15-May-2007 pooka

Step 3 and currently final step of a more general purpose event loop:
support removal and addition of i/o file descriptors on the fly.

* detect closed file descriptors
* automatically free waiters of a dead file descriptor
* give the file server the possibility to specify a callback which
notifies of a dead file descriptor
* move loop function to be a property of the mainloop instead of
framebuf (doesn't change effective behaviour)
* add the possibility to configure a timespec parameter which
attempts to call the loop function periodically
* move the event loop functions from the puffs_framebuf namespace
to puffs_framev to differential between pure memory management
functions


# 1.45 11-May-2007 pooka

move puffs request dispatching code into it's own module.
no functional change


# 1.44 11-May-2007 pooka

Step 2 of general-purpose eventloop: get rid of puffs_framebuf_eventloop().
puffs_mainloop() now handles that functionality as well.


# 1.43 10-May-2007 pooka

Add some kludges to be able to execute requests on the regular program
stack instead of the continuation stack. This is for lib/36011, where
pthread gets confused since we aren't running on the regular stack.
I'm not really sure which direction to go to with this quite yet, so
make the hack hard to enable on purpose. The whole request dispatch
code needs cleaning anyway.


# 1.42 09-May-2007 pooka

Remove the puffs_usermount argument from puffs_req_handle(). It can
be found from the other arguments and this way puffs_req_handle() is
more symmetric with the other puffs_req() routines.


# 1.41 09-May-2007 pooka

Return 0 from puffs_mainloop() if no error occurs.
pointed out by Phil Nelson


# 1.40 07-May-2007 pooka

Add puffs_setback(), which can be used to set setbacks for nodes before
the call returns to the kernel. Currently it can be called only from
open(), mmap(), remove() and rmdir(). (But that might change)


# 1.39 20-Apr-2007 pooka

assert that the file server doesn't try to return more cookies than
it was supposed to


# 1.38 16-Apr-2007 pooka

alloc to set flags when setting fhsize


# 1.37 16-Apr-2007 pooka

some routines for setting mount parameters


# 1.36 13-Apr-2007 pooka

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--


# 1.35 12-Apr-2007 pooka

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().


# 1.34 11-Apr-2007 pooka

* support nodetofh and fhtonode callbacks
* use new signature of node_readdir


# 1.33 20-Mar-2007 pooka

initial support for cacheops


# 1.32 18-Feb-2007 pooka

Until someone can sort non-priviledged mounts and kauth, force
MNT_NOSUID | MNT_NODEV for mounts with geteuid() != 0. I'm tired
of typing them on the command line every time I test a file system.


# 1.31 18-Feb-2007 pooka

dump return values for operations


# 1.30 15-Feb-2007 pooka

Introduce puffs_path_walkcmp(), which is to be called from nodewalk
and compares the path of the node against the given pathobject.
Also make comparison method take a flag to indicate if it should
check if the second path is a true prefix of the first.

plus some namespace cleanup


# 1.29 15-Feb-2007 pooka

* get rid of the holy kernel-given ISDOTDOT, and instead define a
macro which does strcmp against ".." and (the untranslated)
componentname
* make PUFFS_FLAG_BUILDPATH build paths also if dotdot is the case,
and adapt the regular path objects to this
* make nullfs lookup readable because we can now get rid of dotdot
processing there


# 1.28 26-Jan-2007 pooka

add interfaces for suspending the file system


# 1.27 20-Jan-2007 pooka

Be consistent with the rest of the framework about the argument
order of puffs_docc and puffs_dopreq


# 1.26 20-Jan-2007 pooka

be consistent in naming request handlers


# 1.25 16-Jan-2007 pooka

revoke revoke


# 1.24 15-Jan-2007 pooka

Checkpoint some more work in progress: for the benefit those file
system backends which operate purely based on paths, push out more
path management into the library and make path management more
abstract: enable a file system to define a bunch of path management
callbacks, which are used by the framework. Management of normal
/this/is/a/path type paths is provided by the library.


# 1.23 11-Jan-2007 pooka

For directory renames we need to rename all the child nodes for
the given directory if the file system wants paths (PUFFS_FLAG_BUILDPATH).
Do this by walking the nodelist and adjusting the path prefix of
each matching node.


# 1.22 10-Jan-2007 pooka

* don't chdir in possible daemon() call for the benefit of file systems
which specify a relative path as the root
* if (buildpath), build link source full pathname for the duration of
the operation


# 1.21 06-Jan-2007 pooka

* get rid of the mount callback; it's no great surprise to the
server that it needs to mount the file system backend if it wants
to call mount
* provide some options for getmntopts(), assume that callers will parse
command line (or fstab) args
* reorganize the puffs_cc interface just a bit, preparing for a bigger
revamp later


# 1.20 02-Jan-2007 pooka

* inform kernel of our version
* homegrown lib ABI check (to avoid bumping major a ludicrillion times
before reaching stability)


# 1.19 29-Dec-2006 pooka

checkpoint some experimental work-in-progress, namely:

Add support for having multiple outstanding operations. This is done
by exposing enough interfaces so that it is convenient to have the
main event loop in the implementation itself and by providing a
continuation framework for convinient blocking and rescheduling.

works fine, but will undergo further cleanup & development


# 1.18 14-Dec-2006 alc

CID4360: don't leak `buf' upon return
ok pooka@


# 1.17 07-Dec-2006 pooka

outline & export code for interfacing with kernel GET/PUT requests


# 1.16 07-Dec-2006 pooka

g/c out-of-date comment


# 1.15 07-Dec-2006 pooka

support mmap


# 1.14 07-Dec-2006 pooka

cleanup generated stuff from comments


# 1.13 07-Dec-2006 pooka

rototill the operation callbacks: unify the ops under struct puffs_ops
and namespace them


# 1.12 05-Dec-2006 pooka

adapt to kernel change:
Allow multiple requests to be transferred in each GET/PUTOP


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base netbsd-4-base
# 1.11 01-Dec-2006 pooka

PUFFSFLAG -> PUFFS_FLAG to be consistent with the kernel


# 1.10 01-Dec-2006 pooka

build & send implemented operations list to kernel


# 1.9 30-Nov-2006 pooka

summon daemon(3) in mainloop unless the nodaemon flag is given


# 1.8 18-Nov-2006 pooka

* call statvfs() at mount() time, pass that info along
* start is gone


# 1.7 17-Nov-2006 pooka

shuffle flags a bit


# 1.6 09-Nov-2006 pooka

* catch up with kernel changes
* better error handling when mounting


# 1.5 07-Nov-2006 pooka

* support FAF (Fire-And-Forget) class operations
* adapt to new lookup


# 1.4 26-Oct-2006 pooka

pass rdev for specfs support


# 1.3 25-Oct-2006 pooka

handle PUFFS_VN_INACTIVE


# 1.2 23-Oct-2006 christos

pass lint; fix install.


# 1.1 22-Oct-2006 pooka

add libpuffs - the userspace programming interface for puffs

This work was initially started and completed for Google SoC 2005
and tweaked to work a bit better in the past few weeks. While
being far from complete, it is functional enough to be able and
stable to host a fairly general-purpose in-memory file system in
userspace. Even so, puffs should be considered experimental and
no binary compatibility for interfaces or crash-freedom or zero
security implications should be relied upon just yet.

The GSoC project was mentored by William Studenmund and the final
review for the code was done by Christos.


# 1.121 31-May-2017 christos

Adjust to prototype.


Revision tags: prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.120 17-Jun-2015 christos

fix error messages


# 1.119 22-Dec-2014 manu

Do not warn about relative path because of trailing slash

libpuffs calls realpath() to obtain an absolute path to use for mounting.
If the obtained path is different from the one given by the caller, a
warning is issued. This included the situation where the path passed by
the caller just have trailing slashes, a situation where we just want them
to be striped without a warning.


# 1.118 31-Oct-2014 manu

libpuffs support for fallocate and fdiscard operations


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-7-base yamt-pagecache-base9 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 agc-symver-base netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 tls-maxphys-base matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base
# 1.117 14-Nov-2011 chs

branches: 1.117.18;
fix crashes caused by using the results of getcontext()
after the caller returns.


Revision tags: yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base cherry-xenmp-base
# 1.116 03-May-2011 manu

branches: 1.116.4;
Call advlock method if supplied


Revision tags: bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231
# 1.115 06-Dec-2010 pooka

Remove PUFFS_WITH_THREADS ifdef garbage, just use libc weak symbols.


# 1.114 06-Jul-2010 pooka

unwhine lint


# 1.113 06-Jul-2010 pooka

stat mount target path only if we're actually goint to use it.
This avoids errors from the comfd case when the mount target does
not exist in our local namespace.


# 1.112 06-Jul-2010 pooka

set time_t compat where necessary


# 1.111 06-Jul-2010 pooka

When using the top secret PUFFS_COMFD model, write out size of the
puffs kernel args before the contents. This allows parties which
have no clue about the contents to proxy the protocol easily.


# 1.110 07-Jun-2010 pooka

Reenable pathconf now that the retval argument is register_t.


# 1.109 06-Jun-2010 pooka

Actually, disable pathconf for a while longer: the retval needs a
little finetuning (not that everyone is jumping right to using it,
but fixing will have to wait until tomorrow, and who knows what
i'll forget during the night and how long it will eventually take).


# 1.108 06-Jun-2010 pooka

signal pathconf in the vector of supported ops


# 1.107 21-May-2010 pooka

* support extended attributes
* bump major due to structure growth
* add some spare space
* remove ABI sillyness


# 1.106 19-May-2010 pooka

remove three years out-of-date comment


# 1.105 12-Jan-2010 pooka

Add convenience routine puffs_unmountonsignal(), which does exactly that.


# 1.104 07-Jan-2010 pooka

Use typecast instead of ULL for a less whiny lint on LP64.


# 1.103 07-Jan-2010 pooka

Rewrite puffs_exit() in terms of the PUFFSOP_UNMOUNT kernel request.
Now server exit is a lot quite cleaner than previously.


# 1.102 07-Jan-2010 pooka

Set high bit on server->kernel requests to better differentiate
between the direction of the request.


Revision tags: matt-premerge-20091211
# 1.101 05-Dec-2009 pooka

Add an error handler which syslogs but does not abort() and make it
the default. Most servers just shovel bits from their backend to
the kernel without checking the contents and dumping core in case
the backend gives garbage is a bit harsh.


# 1.100 18-Oct-2009 pooka

Make it possible to supply parameters to puffs_init() later (but
before puffs_mount()).


# 1.99 17-Oct-2009 pooka

Dispatch puffs_node_abortop().

Note: We use the storage of puffs_cache_write from puffs_ops for
this purpose. It's not issued by the kernel and hence currently
unused, and this saves us from the trouble of bumping the lib major
version.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.98 08-Jan-2009 lukem

fix some sign comparison warnings


# 1.97 13-Dec-2008 dsl

Actually we need 'long int' to avoif a stupid 'truncating long to int'
warning.


# 1.96 13-Dec-2008 dsl

Change type of 'n' to 'int' so that it can be printed with %d.
The domain of the value is [-1..sizeof (int)] so a type of 'int' is fine.


# 1.95 12-Dec-2008 pooka

Close write-end of daemonpipe in reader to get EOF if the writer
goes awol.


# 1.94 12-Dec-2008 pooka

Add puffs_cancel(), which allows to back down after puffs_init()
and before puffs_mount().
(this should actually be integrated with puffs_exit(), but that
routine is currently so non-sensible that I didn't bother now)


# 1.93 12-Dec-2008 pooka

add:
puffs_setspecific(pu, private)
Can be used to set the specific data after the call to
puffs_init().


Revision tags: netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.92 12-Aug-2008 pooka

branches: 1.92.4; 1.92.8;
Replace void * by puffs_cookie_t where appropriate. No functional change.


# 1.91 11-Aug-2008 pooka

clear cached puffs_cc's in puffs_exit()


# 1.90 11-Aug-2008 pooka

* make sure we come out of mainloop in the main context. otherwise in
certain cases the server would jump to hyperspace when unmounted
* sprinkle some debug prints


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base keiichi-mipv6-base matt-armv6-nbase hpcarm-cleanup-base
# 1.89 28-Jan-2008 pooka

branches: 1.89.6;
Implement lazy contexts for file systems using puffs_mainloop().
Previously each request was executed on its own callcontext and
switched to every time the request was being processed. Now requests
borrow the mainloop context and switch only if/when they yield.
This takes two context switches away from a file system request
bringing down the typical amounts 2->0 (e.g. dtfs) and 4->2 (e.g.
psshfs).

The interfaces for manually executing requests changed a bit:
puffs_dispatch_create() and puffs_dispatch_exec() must now be used.
They are not tested, as nothing in-tree wants them and I doubt
anyone else is really interested in them either.

Also do some misc code cleanup related to execution contexts. The
"work-in-progress checkpoint" committed over a year ago was starting
to look slightly weed-infested.


# 1.88 16-Jan-2008 pooka

Cache a number of execution contexts instead of re-initializing
them every time. Speeds up pure in-memory file systems such as
sysctlfs or dtfs quite a bit. For actual I/O-workhorses the result
is of course less tasty.


# 1.87 16-Jan-2008 pooka

Use PROT_NONE page to protect bottom of stack from overrun


# 1.86 14-Jan-2008 pooka

Introduce PUFFS_STACKSIZE_MIN to avoid overloading 0 and getting
a warning from the library when really wanting to say "just the
minimum, please".


Revision tags: matt-armv6-base
# 1.85 08-Jan-2008 pooka

liberate gas-huffin crack-puffin' assert


# 1.84 02-Jan-2008 pooka

fix pasto


# 1.83 02-Jan-2008 pooka

Also pass fromname in the "distributed" case.


# 1.82 02-Jan-2008 pooka

Provide some transparent "support" for "distributed" file systems.
If the env variable PUFFS_COMFD is set, the descriptor value
contained in it is used for communication instead of opening
/dev/puffs and doing mount(2).

This feature is obviously very undocumented and should not be used
without adult supervision.


# 1.81 25-Dec-2007 pooka

Add a public interface for setting a cookie mapper.


Revision tags: cube-autoconf-base
# 1.80 05-Dec-2007 pooka

Send a response message for flush operations from the kernel instead
of abusing the return value of write(2).


# 1.79 04-Dec-2007 pooka

Part 3/n of extensive changes to message handling:

Get rid of the original puffs_req(3) framework and use puffs_framebuf(3)
instead for file system requests. It has the advantage of being
suitable for transporting a distributed message passing protocol
and therefore us being able to run the file system server on any
host.

Ok, puffs is not quite here yet: libpuffs needs to grow request
routing support and the message contents need to be munged into a
host independent format. Saying which format would be telling,
but it might begin with an X, end in an L and have the 13th character
in the middle. Keep an eye out for the sequels: Parts 3+m/n.


# 1.78 29-Nov-2007 pooka

* allocate pcc as a slice from the stack instead of allocating it
separately
* provide puffs_cc_getcc()

This is in preparation for the removal of you-should-guess-what as
an argument to routines here and there and everywhere.


# 1.77 26-Nov-2007 pooka

print more info when receiving an abort


# 1.76 17-Nov-2007 pooka

puffs_mount():
* initialize values better
* always go through "fail" to see if puffs_daemon() needs to be
woken up
* open device r/w instead of r/o


# 1.75 16-Nov-2007 pooka

Introduce puffs_daemon(), which works like daemon(3) except that it
also synchronizes with puffs_mount() and does not return (exit) in the
parent process until the file system has been mounted. This makes
it possible to reliably run e.g. mount_foo jippi /kai ; cd /kai/ee


# 1.74 06-Nov-2007 pooka

Open the kernel descriptor as part of mount(), not init(). Then
it doesn't matter if someone fork()s or does other tricks between
init() and mount() (and besides, now it's where it logically should be).


# 1.73 05-Nov-2007 pooka

Pull the daemonizing code out of the library mainloop into the file
servers. Calling daemon() (i.e. fork()ing) inside a library can
cause nice surprises for e.g. threaded programs. As discussed with
Greg Oster & others.


# 1.72 29-Oct-2007 pooka

Sprinkle some hackish locks here and there, just enough to allow
libp2k & rump to run multithreaded.


# 1.71 28-Oct-2007 pooka

Add possibility to set pre- and post callbacks which will be called
for all operations before or after executing the specific callback
(the api is not be final yet, though).


# 1.70 26-Oct-2007 pooka

Add some very initial support for a threading worker model as an
alternative to the (vastly superior ;) continuation model. This
is very preliminary stuff and not compiled by default (which it
even won't do without some other patches I cannot commit yet).

The raison d'commit of the patch is a snippet which ensures proper
in-order dispatching of all operations, including those which don't
require a response. Previously many of them would be dispatched
simultaneosly, e.g. fsync and reclaim on the same node, which
obviously isn't all that nice for correct operation.


# 1.69 26-Oct-2007 pooka

mmap stacks, makes it possible to align them


# 1.68 25-Oct-2007 pooka

Make pu_haskq a flag instead of its own variable.


# 1.67 21-Oct-2007 pooka

Add puffs_cc_schedule() which marks a pcc runnable and will pass
execution to it when in the main loop the next time.


# 1.66 11-Oct-2007 pooka

Part 1/n of some pretty extensive changes to how the kernel module
interacts with the userspace file server:

* since the kernel-user communication is not purely request-response
anymore (hasn't been since 2006), try to rename some "request" to
"message". more similar mangling will take place in the future.

* completely rework how messages are allocated. previously most of
them were borrowed from the stack (originally *all* of them),
but now always allocate dynamically. this makes the structure
of the code much cleaner. also makes it possible to fix a
locking order violation. it enables plenty of future enhancements.

* start generalizing the transport interface to be independent of puffs

* move transport interface to read/write instead of ioctl. the
old one had legacy design problems, and besides, ioctl's suck.
implement a very generic version for now; this will be
worked on later hopefully some day reaching "highly optimized".

* implement libpuffs support behind existing library request
interfaces. this will change eventually (I hate those interfaces)


# 1.65 01-Oct-2007 pooka

Pass reason string to pu_errnotify. Print it in the default
version before aborting.


# 1.64 27-Sep-2007 pooka

silence lint. also noticed by xtraeme


# 1.63 27-Sep-2007 pooka

Add error notifications, which are used to deliver errors from the
kernel to the file server for silly things the file server did,
e.g. attempting to create a file with size VSIZENOTSET. The file
server can handle these as it chooses, but the default action is
for it to throw its hands in the air and sing "goodbye, cruel world,
it's over, walk on by".


# 1.62 11-Aug-2007 pooka

branches: 1.62.2;
run realpath() on the mountpath


Revision tags: matt-mips64-base
# 1.61 20-Jul-2007 pooka

branches: 1.61.4;
Add puffs_framev_enqueue_waitevent, which waits for read/write/error
events from an i/o descriptor. It yields until an event happens
and continues execution when the event loop notices the event has
happened.


# 1.60 19-Jul-2007 pooka

Don't float puffs_kargs needlessly around after mount, saves
a couple k of memory (and there was much rejoycing!)


# 1.59 19-Jul-2007 pooka

Use ioctl(PUFFSREQSIZEOP) instead of mount(MNT_GETARGS) to fetch
the maximum request size after mount. Calling mount(MNT_GETARGS)
from the file server is currently not kosher, as it vrele()s the
root vnode, potentially causing an inactive, which the file server
cannot handle while it itself is inactive in the kernel (deadlock).


# 1.58 17-Jul-2007 pooka

* add mntfromname parameter to puffs_init()
* set it in file servers


# 1.57 14-Jul-2007 dsl

Add new 'data_len' parameter to mount system call.
Add an additional call with MNT_GETARGS to retrieve the modified
information instead of relying on the kernel code abusing the mount
interface during mount.


# 1.56 07-Jul-2007 pooka

Make puffs_framebuf better suited from environments with multiple sources:

* in addition add/remove, allow enable/disable, which can be used
to control events for descriptors without having to remove all the
data associated with them
* add directsend/receive, which can be used to pass the same buffer
from the caller to read/writeframe and back again
* add flags to enqueue functions and allow urgent buffers to be
processed as the next PDU


# 1.55 05-Jul-2007 pooka

* reorder calls to get results processed even if our I/O descriptors
go back to zero
* don't give up on the read-side of an fd if there is still unreceived data


# 1.54 02-Jul-2007 pooka

Get rid of the "int *refs" parameter to inactive: the same can be
accomplished now with puffs_setbacks.


# 1.53 11-Jun-2007 pooka

print a specific warning if /dev/puffs cannot be opened in init


# 1.52 06-Jun-2007 pooka

Move puffs to a two clause license where it already isn't so. And
as agc pointed out, even files with the third clause were already
effectively two clause because of a slight bug in the language...


# 1.51 21-May-2007 pooka

remember to put the results of the final operations (including unmount)
to the kernel in mainloop


# 1.50 18-May-2007 pooka

* stuff results back to kernel before calling kevent - the file server
loop function might generate some results. and this is still "after"
event handling (except for the first call, but I'm not too keen on
optimizing for that)
* don't be such a baby about EINTR from kevent(). if we get it, suck
it up and continue instead of quitting


# 1.49 17-May-2007 pooka

Reflect kernel changes for supplying root node information in mount
instead of puffs_start(). Get completely rid of puffs_start(), as
everything it used to do is now handled by the mount routine.
Introduce an optional pre-mount call puffs_setrootinfo() for setting
non-default root node information. As the old puffs_mount() is
now virtually useless, say byebye to it and rename the old
puffs_domount() to puffs_mount(), but add a root cookie parameter
to compensate for the late puffs_start().


# 1.48 16-May-2007 pooka

switch the arbitrary default errno value for network i/o from
ECONNABORTED to ECONNRESET, which is at least a little bit better


# 1.47 15-May-2007 pooka

memset freshly allocated puffs_usermount to 0


# 1.46 15-May-2007 pooka

Step 3 and currently final step of a more general purpose event loop:
support removal and addition of i/o file descriptors on the fly.

* detect closed file descriptors
* automatically free waiters of a dead file descriptor
* give the file server the possibility to specify a callback which
notifies of a dead file descriptor
* move loop function to be a property of the mainloop instead of
framebuf (doesn't change effective behaviour)
* add the possibility to configure a timespec parameter which
attempts to call the loop function periodically
* move the event loop functions from the puffs_framebuf namespace
to puffs_framev to differential between pure memory management
functions


# 1.45 11-May-2007 pooka

move puffs request dispatching code into it's own module.
no functional change


# 1.44 11-May-2007 pooka

Step 2 of general-purpose eventloop: get rid of puffs_framebuf_eventloop().
puffs_mainloop() now handles that functionality as well.


# 1.43 10-May-2007 pooka

Add some kludges to be able to execute requests on the regular program
stack instead of the continuation stack. This is for lib/36011, where
pthread gets confused since we aren't running on the regular stack.
I'm not really sure which direction to go to with this quite yet, so
make the hack hard to enable on purpose. The whole request dispatch
code needs cleaning anyway.


# 1.42 09-May-2007 pooka

Remove the puffs_usermount argument from puffs_req_handle(). It can
be found from the other arguments and this way puffs_req_handle() is
more symmetric with the other puffs_req() routines.


# 1.41 09-May-2007 pooka

Return 0 from puffs_mainloop() if no error occurs.
pointed out by Phil Nelson


# 1.40 07-May-2007 pooka

Add puffs_setback(), which can be used to set setbacks for nodes before
the call returns to the kernel. Currently it can be called only from
open(), mmap(), remove() and rmdir(). (But that might change)


# 1.39 20-Apr-2007 pooka

assert that the file server doesn't try to return more cookies than
it was supposed to


# 1.38 16-Apr-2007 pooka

alloc to set flags when setting fhsize


# 1.37 16-Apr-2007 pooka

some routines for setting mount parameters


# 1.36 13-Apr-2007 pooka

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--


# 1.35 12-Apr-2007 pooka

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().


# 1.34 11-Apr-2007 pooka

* support nodetofh and fhtonode callbacks
* use new signature of node_readdir


# 1.33 20-Mar-2007 pooka

initial support for cacheops


# 1.32 18-Feb-2007 pooka

Until someone can sort non-priviledged mounts and kauth, force
MNT_NOSUID | MNT_NODEV for mounts with geteuid() != 0. I'm tired
of typing them on the command line every time I test a file system.


# 1.31 18-Feb-2007 pooka

dump return values for operations


# 1.30 15-Feb-2007 pooka

Introduce puffs_path_walkcmp(), which is to be called from nodewalk
and compares the path of the node against the given pathobject.
Also make comparison method take a flag to indicate if it should
check if the second path is a true prefix of the first.

plus some namespace cleanup


# 1.29 15-Feb-2007 pooka

* get rid of the holy kernel-given ISDOTDOT, and instead define a
macro which does strcmp against ".." and (the untranslated)
componentname
* make PUFFS_FLAG_BUILDPATH build paths also if dotdot is the case,
and adapt the regular path objects to this
* make nullfs lookup readable because we can now get rid of dotdot
processing there


# 1.28 26-Jan-2007 pooka

add interfaces for suspending the file system


# 1.27 20-Jan-2007 pooka

Be consistent with the rest of the framework about the argument
order of puffs_docc and puffs_dopreq


# 1.26 20-Jan-2007 pooka

be consistent in naming request handlers


# 1.25 16-Jan-2007 pooka

revoke revoke


# 1.24 15-Jan-2007 pooka

Checkpoint some more work in progress: for the benefit those file
system backends which operate purely based on paths, push out more
path management into the library and make path management more
abstract: enable a file system to define a bunch of path management
callbacks, which are used by the framework. Management of normal
/this/is/a/path type paths is provided by the library.


# 1.23 11-Jan-2007 pooka

For directory renames we need to rename all the child nodes for
the given directory if the file system wants paths (PUFFS_FLAG_BUILDPATH).
Do this by walking the nodelist and adjusting the path prefix of
each matching node.


# 1.22 10-Jan-2007 pooka

* don't chdir in possible daemon() call for the benefit of file systems
which specify a relative path as the root
* if (buildpath), build link source full pathname for the duration of
the operation


# 1.21 06-Jan-2007 pooka

* get rid of the mount callback; it's no great surprise to the
server that it needs to mount the file system backend if it wants
to call mount
* provide some options for getmntopts(), assume that callers will parse
command line (or fstab) args
* reorganize the puffs_cc interface just a bit, preparing for a bigger
revamp later


# 1.20 02-Jan-2007 pooka

* inform kernel of our version
* homegrown lib ABI check (to avoid bumping major a ludicrillion times
before reaching stability)


# 1.19 29-Dec-2006 pooka

checkpoint some experimental work-in-progress, namely:

Add support for having multiple outstanding operations. This is done
by exposing enough interfaces so that it is convenient to have the
main event loop in the implementation itself and by providing a
continuation framework for convinient blocking and rescheduling.

works fine, but will undergo further cleanup & development


# 1.18 14-Dec-2006 alc

CID4360: don't leak `buf' upon return
ok pooka@


# 1.17 07-Dec-2006 pooka

outline & export code for interfacing with kernel GET/PUT requests


# 1.16 07-Dec-2006 pooka

g/c out-of-date comment


# 1.15 07-Dec-2006 pooka

support mmap


# 1.14 07-Dec-2006 pooka

cleanup generated stuff from comments


# 1.13 07-Dec-2006 pooka

rototill the operation callbacks: unify the ops under struct puffs_ops
and namespace them


# 1.12 05-Dec-2006 pooka

adapt to kernel change:
Allow multiple requests to be transferred in each GET/PUTOP


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base netbsd-4-base
# 1.11 01-Dec-2006 pooka

PUFFSFLAG -> PUFFS_FLAG to be consistent with the kernel


# 1.10 01-Dec-2006 pooka

build & send implemented operations list to kernel


# 1.9 30-Nov-2006 pooka

summon daemon(3) in mainloop unless the nodaemon flag is given


# 1.8 18-Nov-2006 pooka

* call statvfs() at mount() time, pass that info along
* start is gone


# 1.7 17-Nov-2006 pooka

shuffle flags a bit


# 1.6 09-Nov-2006 pooka

* catch up with kernel changes
* better error handling when mounting


# 1.5 07-Nov-2006 pooka

* support FAF (Fire-And-Forget) class operations
* adapt to new lookup


# 1.4 26-Oct-2006 pooka

pass rdev for specfs support


# 1.3 25-Oct-2006 pooka

handle PUFFS_VN_INACTIVE


# 1.2 23-Oct-2006 christos

pass lint; fix install.


# 1.1 22-Oct-2006 pooka

add libpuffs - the userspace programming interface for puffs

This work was initially started and completed for Google SoC 2005
and tweaked to work a bit better in the past few weeks. While
being far from complete, it is functional enough to be able and
stable to host a fairly general-purpose in-memory file system in
userspace. Even so, puffs should be considered experimental and
no binary compatibility for interfaces or crash-freedom or zero
security implications should be relied upon just yet.

The GSoC project was mentored by William Studenmund and the final
review for the code was done by Christos.