]> git.lizzy.rs Git - plan9front.git/commit
devfs: fix locking and ignore undocumented "fsdev:\n" configuration signature
authorcinap_lenrek <cinap_lenrek@felloff.net>
Wed, 31 Mar 2021 15:49:10 +0000 (17:49 +0200)
committercinap_lenrek <cinap_lenrek@felloff.net>
Wed, 31 Mar 2021 15:49:10 +0000 (17:49 +0200)
commita2ebe5c79a45a0f9ed35bbb690f5070cdfded3ad
tree014a979f88cdda75d5fcf89d1f4abc50dd6fbf9a
parent4a83ce37c649dbcfb5a87c022aad626226904363
devfs: fix locking and ignore undocumented "fsdev:\n" configuration signature

The confstr was shared between readers so seprintconf() could
write concurrently to that buffer which is not safe.

This replaces the shared static confstr[Maxconf] buffer with a
pointer that is initially nil and a buffer that is alloced on
demand.

The new confstr pointer (and buffer) is now only updated while
wlock()ed from the new setconfstr() function.

This is now done by mconfig() / mdelctl() just before releasing
the wlock.

Now, rdconf() will check if confstr has been initialized, and
test for it again while wlock()ed; making sure the configuration
is read only once.

Also, rdconf() used to check for a undocumented "fsdev:\n" string
at the beginning of config data tho that was never documented.

This changes mconfig() to ignore that particular signature so
the example from the manpage will work as documented.
sys/src/9/port/devfs.c