USF-OS / FogOS

Other
1 stars 32 forks source link

Enhance functionality of stat command #69

Open jcmendoza2 opened 5 days ago

jcmendoza2 commented 5 days ago

stat command: Displays detailed information about a file, including the last modification and access times of the file.

Plan: Extend and enhance the functionality of the stat (fstat) command Extend version control of files: allow user to be able to save current state of a file as a new version and have it stored in a directory-like structure titled the name of the file and be stored as a separate file with a timestamp and/or version number in its name. User can save current state of a file whenever and access the prior versions in case of needing to backtrack after exiting OS entirely. For now, the list of versions of a certain file will be 3 for memory/storage purposes. If user wants to save the current state of a file as a new version but 3 versions of the file already exist in storage, a message will ask if they want to proceed with overwriting the oldest version in the existing version list (to not require complex algorithms for version tracking just yet = simplified version management) and if yes, the oldest version will be overwritten.

Add flags/commands: stat -listVersions [textfile.txt] Description: display a list of all saved versions with their timestamps and access times etc. stat -viewVersion [version num (1 to 3 only)] [textfile.txt] or -viewVersion "2024-09-14 12:20:02" [textfile.txt] Description: allows user to view the selected file version that existed at a specific timestamps the output would be similar to if we were to say cat textfile.txt. To allow user to copy functions or implementations they wish they didn't get rid of stat -saveVersion [textfile.txt] Description: save the current state of the file as a new version

Files to be added or modified tbd: Create user/xstat.c: the main implementation of the stat command but defining the additonal flags/commands. Modify user/user.h: add the new flags/commands that can be used by stat Modify user/Makefile: to build and include xstat.c Modify kernel/syscall.h: to define new system calls Modify syscall.c: to add the new system calls and make sure they'll be handled Modify sysfile.c: to ensure argument checking of the system calls

Future Implementation: Add flag/commands: stat -restoreVersion "2024-09-14 12:20:02" [textfile.txt] or stat -restoreVersion [version num in list] [textfile.txt] Description: If user totally veered from the original implementation they wanted, they can have the option to restore whatever version they had. Extend version storage: Allow for a larger number of versions to be stored in a directory-like structure. As each version is saved as a separate file with a timestamp in its name in a directory related to the file name, extend the number of versions that can be kept. 3? 10? 20? User Configuration: Allow users to set a preference in the maximum number of versions that can be kept or max storage space to use.

malensek commented 2 days ago

This looks good to me, but I'd propose renaming this: the usual stat command outputs a lot of info that xv6 FS doesn't have (permissions, ownership, modification / access times, etc). So instead, I think what you're proposing is a straight up version control or backup program.

You could use the latest lab and last semester's date project to get the date info, and I like the idea of allowing rolling backups to be created automatically. So, I'd remove any usual unix stat related functionality and stick with the vc/backup aspects of your project. This would also mean you don't need to add any system calls (apart from date-related stuff)