Commit graph

91 commits

Author SHA1 Message Date
Ori Bernstein 4eeefed7b0 cwfs: fix iounit negotiation
cwfs had an issue with iounit negotiation as a result
of the conversion to 9p2000 -- with the move to variable
size messages, the fixed message overhead decreased, but
the advertised message size was still adding the old
fixed overhead.

This meant that if the kernel negotiated the maximum io
size, cwfs would negotiate something larger than it
supported, and would hang up when an io of that size
was made.

In addition, the size of messages was stored in a short,
which means that negotiating an iounit larger than 16384
bytes would overflow the message count, and cause things
to fall over.

Finally, whle we're here, we clean up some duplicated
and unused constants.
2022-06-07 22:38:04 +00:00
Alex Musolino 5d790e08ca cwfs: fix interpretation of startdump argument 2020-12-06 13:54:10 +10:30
cinap_lenrek a469cffafe cwfs: update mtime and qid.vers for directory on rename
when wstating a file, its directory should be updated to
reflect this change.

here is what the manpage states:

> The mtime field reflects the time of the last change of content
> (except when later changed by wstat). For a directory it is the
> time of the most recent remove, create, or wstat of a file in the
> directory.
2020-07-12 18:52:28 +02:00
cinap_lenrek af23bb343a cwfs: fix listen filedescriptor leaks 2019-10-04 18:54:01 +02:00
cinap_lenrek b767b2ce23 cwfs: remove orphaned lrand.c 2019-06-20 14:15:20 +02:00
cinap_lenrek d8a8ac237a cwfs: remove old some assert() debugging 2019-06-20 14:06:29 +02:00
cinap_lenrek 07af9be3a9 cwfs: fix root access time qid path comparsion 2019-06-20 13:15:26 +02:00
cinap_lenrek 159f96c534 cwfs: properly handle 64 bit qid path
for historical reasons, kenfs stores directory entries in pre 9p2000
format with directories having the QPDIR bit 31 set in the qid path.

however, the 64 bit fileserver allows 64 bit qid paths.

given that we do not support pre 9p2000 clients and do not rely on
the QPDIR, but want to keep the block check tags consistent, we will
*INVERT* the QPDIR bit in directory entry qid paths for directories.

this preserves the on-disk semantics (for < 31 bit qmax) but does
not complicate qid generation and recovery. also makes it easy to
convert between directory entry qid and 9p format.
2019-06-19 22:58:16 +02:00
cinap_lenrek b76a78c1a1 cwfs: fix %.*s format in cmd_printconf() 2019-02-25 04:36:37 +01:00
cinap_lenrek 19166f2cf3 libc: add procsetname() 2018-09-26 14:56:23 +02:00
Ori Bernstein 72a840b31d Disallow '/' in file names.
A bad rename call could send a path with a '/' to cwfs.
	This is invalid, and should be disallowed.
2018-09-25 01:02:31 -07:00
cinap_lenrek 77757dbdb1 cwfs: use /dev/swap instead of #c/swap to determine memory size 2017-10-29 21:41:35 +01:00
cinap_lenrek 8fce6cb18b cwfs: -n always overrides postservice() name, no matter if config mode changes service 2017-08-04 14:12:02 +02:00
cinap_lenrek b4b2cd72b0 cwfs: allow "none" user to rename files 2017-04-29 17:28:35 +02:00
cinap_lenrek 5fc5c18208 cwfs: handle DMTMP flag in create 2017-03-06 03:07:03 +01:00
cinap_lenrek d643cf2fe6 cwfs: handle worm exhaustion more gracefully
don't deadlock when cwgrow() detects we'r out of worm space
by releasing the cache superblock buffer.

don't allocate space beyond the worm device when dumping by
having slit() check. after cwrecur(), we check if there are
enougth blocks remaining to write the dump date directories
and superblocks.
2017-01-30 23:17:18 +01:00
cinap_lenrek 5171a0ac52 cwfs: fix cwcmd startdump 2017-01-27 02:00:20 +01:00
cinap_lenrek a0d4c5e208 make error handling in 9p service loops consistent
when we get eof, stop the loop immidiately and do not
rely on the read to eventually return an error.

when convM2S() fails to decode the message, error out
and stop the loop. there is no point in continuing.
2016-07-24 02:21:32 +02:00
cinap_lenrek 772afbe98c format pointer subtraction results with %zd instead of %ld (for long -> intptr on amd64) 2016-01-07 04:44:13 +01:00
cinap_lenrek bab31af707 cwfs: fix wstat() failing to mark block dirty when noatime is set
code assumed the accessdir() call would always mark the block dirty, but
this is not the case when noatime flag is enabled. this was reported by
michael in bug:

"open/with_noatime_option_cwfs_doesnt_preserve_changes_in_file_permissionowner"

--
cinap
2015-10-09 19:22:53 +02:00
cinap_lenrek ffe4844da8 cwfs: various cleanups
- consistently refer to Dentry.name length with NAMELEN
- make sure whoname is null terminated
- remove useless nil check for whoname
2015-09-26 11:44:29 +02:00
cinap_lenrek 76e0968e35 cwfs: don't use sprint() to fill directory name
sprint() will replace invalid utf8 sequences with U+FFFD
which caused directory reads and stats to return the wrong
filename. just strcpy the name bytes.
2015-09-26 11:41:31 +02:00
cinap_lenrek c06e464ec4 cwfs: initialize /env/timezone on boot so dumps are in localtime
when /env/timezone file is missing (boot case), copy /adm/timezone/local
to /env/timezone so localtime() can correct timezone offset.
2015-09-12 03:58:46 +02:00
cinap_lenrek 0ce50ebc57 cwfs: remove 9p1 support 2015-08-21 18:43:25 +02:00
cinap_lenrek 167ea748f8 cwfs: adjust for new libauthsrv changes 2015-08-20 20:44:17 +02:00
cinap_lenrek ad91dc7ffb cwfs: set permission of / to 0775 on ream
this allows members of the -1 group to create new directories in /
without having to fiddle with the fileserver console. this also
makes it consistent to hjfs.
2015-08-05 13:06:11 +02:00
cinap_lenrek 427e925eea cwfs: add optional uid argument to allow command, unify permission override code
the allow command now takes an optional uid argument for the user
to be granted temporary god status on the fileserver for maintenance.

this was kenji okomotos idea, so thanks :)

remove wstatallow and writeallow flags. instead, we have global:

int allowed;

that contains the uid of the currently allowed user id or -1
if permission checking is globally disabled for the fileserver.
when zero, normal permission checking takes place.

added int isallowed(File*) function that returns non-zero when the
context is the console, or the allowed user. this is also used internally
by iaccess(), so all the extra code of in the callers of iaccess()
is gone now.

dont conflate allowed user with noauth flag and auto-allow on ream.
the installer already knows about noauth and allow flags so theres no
problem with bootstraping.
2014-08-11 22:36:59 +02:00
cinap_lenrek 760063ab57 cwfs: fix 32bit multiplication overflows for allocation sizes (thanks kenji okomoto) 2014-08-09 17:37:02 +02:00
cinap_lenrek 4c639475ce cwfs: fix 1GB memsize limitation
the malloc pool allocator is limited in its allocation
size. as almost all data structures in cwfs are never
freed, use brk() in ialloc() instead of mallocalign().
this means memory returned by ialloc() cannot be freed!

to make sure we do not call free by accident, remove
the #define malloc(n) ialloc(n, 0) macro and use ialloc()
directly as in the original code to show the intend
of permanent allocations.
2014-05-03 00:51:45 +02:00
cinap_lenrek 88cc09a580 cwfs: limit memsize() to 1GB until pool can handle huge allocations 2014-02-07 23:33:34 +01:00
cinap_lenrek 03d26f8087 cwfs: use pragma pack for on disk structures for amd64 2014-02-01 20:26:36 +01:00
cinap_lenrek 1cd4579cdc cwfs: fix putbuf(nil) in error case of cmd_check() 2013-10-16 07:21:12 +02:00
cinap_lenrek 0460e4be7d cwfs: add checktag() call for cache bucket in dumpblock(), fix error strings 2013-10-11 10:17:17 +02:00
cinap_lenrek 5982c50fa4 cwfs: more checking for cfsdump(), cleanup Tsuper hack in cwrecur()
add checktag and nil checks in cfsdump() making sure to notice
when the roroot directory structures is corrupted.

cwrecur() used tag == Tsuper to indicate that this is the first
level recursive invocation. this is confusing as we really expect
Tdir tag in that case for the root directory. instead, we now
pass the correct tag (Tdir) and use cw->depth > 1 to see if we
are past the root.

the block tag was only checked when the block was not in
the memory cache. check the tag always!
2013-10-11 06:01:55 +02:00
cinap_lenrek a28bdd3e1f cwfs: fix out of order replies
using a shared reply queue and a pool of worker procs does
result in replies to be send out of order under some conditions.
the symptoms are mnt errors when interrupting requests (Rflush
arriving before the original requests response).

this change gives each connection its own reply queue and its
own srvo process. so now a connection consists of one reply
queue, a srvi process reading the connections file descriptor
and a srvo process reading the reply queue and writng replies
to the connections file descriptor.

the srvi processes live as long as the connection is established.
the srvo prcoesses live forever and are attached to the chan
(which gets reused).

to avoid excessive process creation, we limit the number of
connections to 30. srvchan() returns nil when all 30 network
channels are in use.
2013-08-08 01:07:01 +02:00
cinap_lenrek 3663ffeefa cwfs: use atomic compare and swap to avoid semacquire() syscalls in new queue implementation 2013-08-07 01:32:11 +02:00
cinap_lenrek cdc0b89d81 fix this megashit 2013-08-05 22:31:37 +02:00
cinap_lenrek 755108a144 cwfs: remove reflock
queues allow multiple readers, reflock seems unneccesary.
2013-08-05 22:07:50 +02:00
cinap_lenrek e3d9591283 cwfs: faster queue implementation using semacquire() 2013-08-04 06:47:56 +02:00
cinap_lenrek 24e8c78cb2 cwfs: add rtmp flag for check command to remove temporary files after recover 2013-07-18 15:04:37 +02:00
cinap_lenrek 70b9c8574f cwfs: fix mtime for dump yyyy directories 2013-02-25 06:11:43 +01:00
cinap_lenrek 3787f721c1 9p message size too small
various fileservers do not check if the message size is too small
(they subtract IOHDRSZ later from it to calculate iounit) which
can overflow.
2013-01-30 06:28:42 +01:00
cinap_lenrek 9507061986 cwfs: allow previously authorized channels to attach as none
we allow allow previously authorized channels to attach as none
even if anonymous logins are disabled with nonone.
2012-12-07 09:53:08 +01:00
cinap_lenrek 52b500af61 cwfs: make none attach work
allow attach as none. (this was supposed to work but it
doesnt for 9p2000 because we have to check for
afid being NOFID instead of checking the uname string).

and add "nonone" flag to disable this.
2012-12-07 06:30:26 +01:00
cinap_lenrek 235f71ba47 cwfs: fix read offset integer overflow 2012-08-01 01:10:24 +02:00
cinap_lenrek dc544a3462 cwfs: remove noatime runtime option 2012-07-24 20:09:28 +02:00
cinap_lenrek ffc58b3429 cwfs: make sure we do a full dump after toggling noatime 2012-07-24 19:42:18 +02:00
cinap_lenrek 42cf4e2371 cwfs: fix noatime dumps 2012-07-23 18:57:33 +02:00
cinap_lenrek 8099d78f44 cwfs: noatime flag 2012-07-14 23:49:17 +02:00
cinap_lenrek 8e11ff283f cwfs: make /srv/cwfs.cmd redable to receive command output
before, cwfs would print everything to /dev/cons. this change
will redirect the output of commands to the /srv/cwfs.cmd pipe
so one can use:

con -C /srv/cwfs.cmd

and not have the fish for the output in /dev/kmesg.

use standard error (/dev/cons) for unsolicited messages as
there is not always a reader on the command file.
2012-07-13 15:09:39 +02:00