filesystem-reporting-tools icon indicating copy to clipboard operation
filesystem-reporting-tools copied to clipboard

multi-threading fix and enhancements

Open dirkpetersen opened this issue 1 year ago • 2 comments

As it turns out, Claude actually 'forgot' to take the multi-threading logic from pwalk, ah well, now fixed and added

  • --force-group-writable option to implement a parallel chmod -R g+rw
  • multiple --exclude possible
  • --threads to change the default of 32 threads
  • if setuid bit in binary active, replace target folder with current one

dirkpetersen avatar Jul 03 '24 20:07 dirkpetersen

The fundamental change that I wanted to make to pwalk was to have conditional compiles that would allow me to create many different flavors of the program. The tree walking is done in a single function, fileDir. When <fileDir> reports on a file, it calls the function pointer fileProcess which points to the function printStat. Line 346 of pwalk.c should look like this:

#ifdef PWALK
    fileProcess = &printStat;
#endif
#ifdef REPAIRSHR
   fileProcess = &REPARSHR
#endif

Makefile would look something like the following. The core walk feature of pwalk would stay the same, but the function pointer will change.

pwalk: pwalk.c exclude.c fileProcess.c
	$(CC) $(CFLAGS) -DPWALK -o pwalk exclude.c fileProcess.c pwalk.c $(LDFLAGS)
repair-shared: pwalk.c exclude.c repairshr.c repexcl.c
	$(CC) $(CFLAGS) -DREPAIRSHR -o repair-shared pwalk exclude  repairshr.c repexcl.c $(LDFLAGS)	

And add a second function pointer to complement fileProcess; dirProcess. To implement your request to only output directory data, the file_action could be a null pointer, and dir_action would output directory info.

fizwit avatar Jul 03 '24 21:07 fizwit

Yes, that would be nice and remove a lot of redundancy ..... Claude starts to become cumbersome if a single code file is longer than 400 lines and ChatGPT prefers < 100 lines

Also on new infrastructure this has incredible performance

dirkpetersen avatar Jul 03 '24 21:07 dirkpetersen