Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

On linux with python lib, when using mkdir -p, does not capture child folder creations #66

Closed
yufei-pan opened this issue Jan 29, 2025 · 5 comments

Comments

@yufei-pan
Copy link

mkdir -p tfp/new

only one event got generated
{"effect_time":1738138437295141641,"path_name":".../test/tfp","associated_path_name":null,"effect_type":"create","path_type":"dir"}

This maybe a limit of underlying inotify ?

I am on 6.12.10-200.fc41.x86_64

@e-dant
Copy link
Owner

e-dant commented Jan 29, 2025

I'm pretty sure that we're not adding a mark on that first directory quickly enough to receive the second event.

If there was an error watching new directories, we'd shoot a warning up and tell you. It looks like we just didn't notice.

Ideally we should write the watcher in such a way that avoids the race altogether.

@e-dant
Copy link
Owner

e-dant commented Feb 1, 2025

We do notice destroy events on the nested path, though those events are tied to the first path, so not much of a surprise.

$ ( wtr.watcher /tmp -ms 1000 | grep -v self | jq -c '. | {(.path_name): .effect_type}' ) & ( cd /tmp ; sleep 0.1 ; mkdir -p a/b ; rmdir a/b a )
{"/tmp/a":"create"}
{"/tmp/a/b":"destroy"}
{"/tmp/a":"destroy"}

@e-dant
Copy link
Owner

e-dant commented Feb 1, 2025

f4aaf62 should fix this.

@e-dant
Copy link
Owner

e-dant commented Feb 1, 2025

For fanotify, things get a bit weird. It "works", but:

{"path_type":"dir","path_name":"/tmp/a","effect_type":"create","effect_time":1738444397609015400,"associated":null}
{"path_type":"dir","path_name":"/tmp/a/b","effect_type":"create","effect_time":1738444397609122077,"associated":null}
{"path_type":"dir","path_name":"/tmp/a (deleted)/b","effect_type":"destroy","effect_time":1738444397610121378,"associated":null}
{"path_type":"dir","path_name":"/tmp/a","effect_type":"destroy","effect_time":1738444397610169432,"associated":null}

We get some weird "/tmp/a (deleted)/b" action there. The "(deleted)" part is just something fanotify decided to add all by itself.

@e-dant
Copy link
Owner

e-dant commented Feb 1, 2025

For fanotify, things get a bit weird. It "works", but...

Can't perfectly reproduce the behavior. I didn't write the kernel's fanotify implementation, but maybe if someone more versed in it could explain when that path is concatenated with extra metadata, and when it is not, that would be nice. Seems a bit weird.

@e-dant e-dant closed this as completed Feb 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants