With the new errors.log (related to the monitor mode) we really need a way to delete files on the robot. Although we could use another oplet (e.g. 'e' for 'e'rase is available) it seems like there is a lot of overlap on the 'W' or write_to_robot oplet. We can add a sub oplet for the 'W' oplet, but 'e' is already "end". We could use 'd'. e.g. W 0 d /srv/samba/share/errors.log;
It would also be good if it were a two step process to reduce the possibility of bad packets (remember, our socket system doesn't guarantee correct delivery) accidentally deleting a file. We could use the 'f' suboplet of the 'W' command to first open the file, then make the 'd' suboplet delete the currently open file. e.g. W 0 f \srv\samba\share\errors.log; and then W d The trick with that is Linux doesn't have a way to delete a file by handle. You can only int unlink(const char *pathname); There is a sort of hacky trick to get the pathname back from the file id:
https://stackoverflow.com/a/1189582/663416
Another way of adding safety is to require a checksum of the path. For consistency, the W oplet requires a number after the suboplet but before the filename. We could do a Fletcher 16 on the path and send that with the W command. E.g. W d 63301 /srv/samba/share/errors.log would work because that F16 sum of "/srv/samba/share/errors.log" is correct. This seems like it would be good enough.
With the new errors.log (related to the monitor mode) we really need a way to delete files on the robot. Although we could use another oplet (e.g. 'e' for 'e'rase is available) it seems like there is a lot of overlap on the 'W' or write_to_robot oplet. We can add a sub oplet for the 'W' oplet, but 'e' is already "end". We could use 'd'. e.g.
W 0 d /srv/samba/share/errors.log;
It would also be good if it were a two step process to reduce the possibility of bad packets (remember, our socket system doesn't guarantee correct delivery) accidentally deleting a file. We could use the 'f' suboplet of the 'W' command to first open the file, then make the 'd' suboplet delete the currently open file. e.g.
W 0 f \srv\samba\share\errors.log;
and thenW d
The trick with that is Linux doesn't have a way to delete a file by handle. You can onlyint unlink(const char *pathname);
There is a sort of hacky trick to get the pathname back from the file id: https://stackoverflow.com/a/1189582/663416Another way of adding safety is to require a checksum of the path. For consistency, the W oplet requires a number after the suboplet but before the filename. We could do a Fletcher 16 on the path and send that with the W command. E.g.
W d 63301 /srv/samba/share/errors.log
would work because that F16 sum of "/srv/samba/share/errors.log" is correct. This seems like it would be good enough.This also allows deleting (empty) folders if we use
int remove(const char *pathname);
instead of unlink.