Hi Genodians,
I'm working on my HnH19-project to create a component listening on a
shared filesystem to open each pdf file into a separate instance of
mupdf. Goal is to tie the share to a linux-vm in vbox so firefox and
thunderbird can have a simple 'cp' command to get pdfs rendered outside
that vm.
I add a RAM-FS, FS-QUERY and REPORT-ROM to mupdf.run. The file gets put
in the ram-fs, fs-query should pick that up and report it to the report-rom.
<start name="pdf_share">
<binary name="ram_fs"/>
<resource name="RAM" quantum="128M"/>
<provides> <service name="File_system"/> </provides>
<config verbose="yes">
<default-policy root="/" writeable="yes" />
</config>
</start>
<start name="report_new_pdf">
<binary name="report_rom"/>
<resource name="RAM" quantum="1M"/>
<provides> <service name="Report"/> <service name="ROM"/>
</provides>
<config verbose="yes"/>
</start>
<start name="fs_query">
<resource name="RAM" quantum="1M"/>
<config verbose="yes">
<vfs> <fs writeable="yes"/> </vfs>
<query path="/" content="yes"/>
</config>
</start>
I change the test-scenario to copy a pdf into the share and start the
pdf-viewer. The viewer picks up the pdf and renders it. So far so good.
The problem is that while the 'add'-test copies the file, it gets
detected by fs_query but fs_query thinks it's gone:
[init -> test -> add] --- noux started ---
[init -> fs_query] Error: failed to watch '//foo.pdf'
[init -> fs_query] Warning: could not obtain content of nonexistent file
foo.pdf
(The error comes from gems/vfs.h L556, the warning from fs_query/main.cc
L80.)
Fs_quey does send a new report but does not show the file, it show an
empty directory.
[init -> report_new_pdf] report 'fs_query -> listing'
[init -> report_new_pdf] <listing>
[init -> report_new_pdf] <dir path="/"/>
[init -> report_new_pdf] </listing>
However, a ls -laR shows it's there:
[init -> test -> ls-after] /dest:
[init -> test -> ls-after] total 1
[init -> test -> ls-after] drwxr-xr-x 0 root 0 0 Jan 1 00:00 .
[init -> test -> ls-after] drwxr-xr-x 0 root 0 0 Jan 1 00:00 ..
[init -> test -> ls-after] -rwxrwxrwx 0 root 0 8192 Jan 1 00:00 foo.pdf
Now the race condition:
When I set the fs-query option to show the content to "no", it gives the
same error: failed to watch '//foo.pdf' but it now it does send the file
name to the report:
[init -> report_new_pdf] <file name="foo.pdf"/>
So it seems that somehow that fs_query watch learns there is a file
while the contents are not yet committed. Accessing that triggers a
file-not-found error.
Did I discover a race condition or am I doing something wrong?
With regards, Guido.
PS. I added the complete run-file and logs for completeness. (log-1
shows the contents-flag to no).
PPS. I'm testing with Qemu in a linux VM on my AMD nixos host.