Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ $U/usys.o : $U/usys.S
$U/_forktest: $U/forktest.o $(ULIB)
# forktest has less library code linked in - needs to be small
# in order to be able to max out the proc table.
$(LD) $(LDFLAGS) -N -e main -Ttext 0 -o $U/_forktest $U/forktest.o $U/ulib.o $U/usys.o $U/umalloc.o $U/printf.o
$(LD) $(LDFLAGS) -N -e main -Ttext 0 -o $U/_forktest $U/forktest.o $U/ulib.o $U/usys.o $U/umalloc.o
$(OBJDUMP) -S $U/_forktest > $U/forktest.asm

mkfs/mkfs: mkfs/mkfs.c $K/fs.h $K/param.h
Expand All @@ -130,11 +130,13 @@ UPROGS=\
$U/_stressfs\
$U/_usertests\
$U/_grind\
$U/_vcp\
$U/_wc\
$U/_zombie\

fs.img: mkfs/mkfs README.md $(UPROGS)
mkfs/mkfs fs.img README.md $(UPROGS)
fs.img: mkfs/mkfs README.md getlinetest.txt $(UPROGS)
mkfs/mkfs fs.img README.md getlinetest.txt vcpTest.txt $(UPROGS)


-include kernel/*.d user/*.d

Expand Down
48 changes: 48 additions & 0 deletions docs/VCP_doc
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
vcp

The "vcp" command revolves around the idea of a version control/backup program. A hidden root directory (vctl) is created when the command is ran; within it a sub-directory with the name of the file we are working with is also created. Within this sub-directory a maximum of 3 files can be saved (in essence 3 different versions of the sub-directory's file name).

Example: vctl / filename / Version1_filename
The point is to be able to save the most important versions of a program so that if necessary, the user can come back and review past versions of that exact program and extract the needed info that can be applied in the user's current program. When 3 versions already exist for a specific file and the user wants to save another version, the oldest of the 3 versions will be overwritten upon confirmation that the user agrees upon this process. If agreed, all existing versions will be shifted forward and renamed and the newest version will be added to the version control directory.

Example: Version2_filename -> Version1_filename, Version3_filename -> Version2_filename and filename -> Version3_filename

Added Files:
user/vcp.c
// Testing
FogOS-VCP/getlinetest.txt
FogOS-VCP/vcpTest.txt
our lab with broken.c to test long files

Modifications:
FogOS-VCP/Makefile

Flags:

(-saveVersion): saves the current state of the file as a new version and label it with its respective version number

(-listVersions) : displays a list of all saved versions of the specified file for example: Version3_filename.txt

(-viewVersion) : displays the selected file version existing in the list of file versions for the specified file like the format of 'cat [filename]' allowing user to copy and access functions or implementations they wish they didn't get rid of etc. For example: /vcp -viewVersion Version2_filename.txt

How to Test | How it Works | Limitations:
You can refer to the file vcpTest.txt where I included examples of how to test the program within QEMU.
As of now you can only test with files in your OS directory (where your Makefile exists) or with files you create in QEMU with echo. Future implementation will handle accessing files from other directories.
Due to limitations in xv6: only inside QEMU using echo can you really see the multiple versions of saving, viewing, and listing [refer to vcpTest.txt for why]. Saving, viewing, and listing can also be done for files in OS but not in the way the program was designed [vcpTest.txt]

If testing in OS, ensure the file is added to your Makefile fs.img: 2nd line only. Do not make clean after you save versions as this will erase all versions and directories you've saved with vcp (due to xv6 limitations). You can exit QEMU and then rerun QEMU and the data will still be there.
Inside QEMU:

/vcp -saveVersion filename.txt
/vcp -listVersions filename.txt
/vcp -viewVersion Version1_filename.txt
The program will work like normal, saving max 3 versions and overwriting but all versions will have same content (but they are separate files [refer to vcpTest.txt])

If testing inside QEMU: create a program with content like so

echo "content you want" > filename.txt (any extension)
/vcp -saveVersion filename.txt
echo "different content" > filename.txt (to change the file content)
/vcp -saveVersion filename.txt
Now you can /vcp -listVersions filename.txt
and then you can view each version. If you want to try overwriting, save more than 3 versions and then check if everything has been shifted forward
13 changes: 13 additions & 0 deletions getlinetest.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# FogOS

Hello world!!

What's going on, class??

How about that fog out there?!

Let's create a REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY long line. IS THAT LONG ENOUGH?!?!?!

Okay all done.

Have a good one!
2 changes: 1 addition & 1 deletion kernel/fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ struct dinode {
#define BBLOCK(b, sb) ((b)/BPB + sb.bmapstart)

// Directory is a file containing a sequence of dirent structures.
#define DIRSIZ 14
#define DIRSIZ 30

struct dirent {
ushort inum;
Expand Down
20 changes: 18 additions & 2 deletions user/user.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
#define NULL ((void *) 0)

#define bool _Bool
#define true 1
#define false 0

#define SEEK_SET 0
#define STDIN_FILENO 0
#define SEEK_CUR 1
#define STDOUT_FILENO 1
#define SEEK_END 2
#define STDERR_FILENO 2

struct stat;

// system calls
Expand All @@ -22,6 +35,9 @@ int getpid(void);
char* sbrk(int);
int sleep(int);
int uptime(void);
int reboot(void);
int shutdown(void);
uint64 timestamp(void);

// ulib.c
int stat(const char*, struct stat*);
Expand All @@ -32,8 +48,8 @@ int strcmp(const char*, const char*);
void fprintf(int, const char*, ...);
void printf(const char*, ...);
char* gets(char*, int max);
int fgets(int fd, char*, int max);
int getline(char **lineptr, uint *n, int fd);
int fgets(int fd, char *buf, int max);
int getline(char **ptr, uint *size, int fd);
uint strlen(const char*);
void* memset(void*, int, uint);
void* malloc(uint);
Expand Down
Loading