Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: asmeurer/OS_lab1
base: 25add5dd5f
...
head fork: asmeurer/OS_lab1
compare: 2612627988
  • 4 commits
  • 3 files changed
  • 0 commit comments
  • 2 contributors
View
3  filesystem/definitions.h
@@ -72,6 +72,7 @@ typedef unsigned char byte;
#define OPEN_TYPE_WRITE_ACC_BITMASK 0x02
#define DEVICE_FORMAT_BITMASK 0x01
#define DEVICE_MOUNTED_BITMASK 0x02
+#define DEVICE_INIT_BITMASK 0x04
#define NAME_LIMIT 11
#define NUM_BUFFERS 5
/*256 MB*/
@@ -129,7 +130,7 @@ typedef struct {
byte bitmap[MAX_BLOCK_SIZE];
byte numblock;
char fs_name;
- /*0 0 0 0 0 0 (Mounted) (Formatted)*/
+ /*0 0 0 0 0 (Init) (Mounted) (Formatted)*/
byte bits;
} device;
View
4 filesystem/file_manager.c
@@ -34,6 +34,7 @@ int init_fs(int device){
buf_flush(i);
}
+ device_array[device].bits = device_array[device].bits | DEVICE_INIT_BITMASK;
return ERROR_SUCCESS;
}
@@ -110,6 +111,9 @@ int format(int device_num, char fs_name, int blocksize){
if(format_me->bits & DEVICE_MOUNTED_BITMASK){
return ERROR_DEVICE_MOUNTED;
}
+ if(!(format_me->bits & DEVICE_INIT_BITMASK)){
+ return ERROR_DEVICE_NOT_KNOWN;
+ }
if (fs_name < 'A' || fs_name > 'Z') {
return ERROR_BAD_FS_NAME;
View
64 filesystem/file_test.c
@@ -9,6 +9,37 @@
#include "file_test.h"
+void list_devices(){
+ int i;
+ printf("Listing devices:\n");
+ for(i = 0; i < MAX_DEVICE; i++){
+ /*If device is initialized*/
+ if (device_array[i].bits & DEVICE_INIT_BITMASK){
+ printf("Device number: %d ", i);
+ printf("Formated: ");
+ if(device_array[i].bits & DEVICE_FORMAT_BITMASK){
+ printf("Yes Fs_name: %c ", device_array[i].fs_name);
+ }
+ else{
+ printf("No Fs_name: - ");
+ }
+ printf("Mounted: ");
+ if(device_array[i].bits & DEVICE_MOUNTED_BITMASK){
+ printf("Yes");
+ }
+ else{
+ printf("No");
+ }
+ printf("\n");
+ }
+ }
+}
+
+
+
+
+
+
/**
* Gets a string from the file.
* @param fFile The file to read the string from.
@@ -675,11 +706,42 @@ int main(int argc, char *argv[]) {
}
if(error == 1){
textcolor(BRIGHT, RED, BLACK);
- printf("Usage: MKDIR <dirname>\n");
+ printf("Usage: DELETE <filepath>\n");
textcolor(RESET, -1, -1);
}
}
+ else if (!strcmp(command, "LIST")) {
+ fgets(line, LINE_MAX, file);
+ error = 1;
+ /*Initial split of line*/
+ init_arg = strtok(line, " ");
+ /*If there exists arguments*/
+ if (strcmp(init_arg, "\n" != 0) {
+ if (!strcmp(init_arg, "DEVICES\n")) {
+ printf("LIST USER called\n");
+ list_devices();
+ error = 0;
+ }
+ else if (!strcmp(init_arg, "FILEINFO\n")) {
+ printf("LIST SYSTEM called\n");
+ error = 0;
+ }
+ else if (!strcmp(init_arg, "DIRECTORY\n")) {
+ printf("LIST BS (Backing Store) called\n");
+ error = 0;
+ }
+ else{
+ error = 1;
+ }
+ }
+ if(error == 1){
+ textcolor(BRIGHT, RED, BLACK);
+ printf("Usage: LIST [DEVICES|FILEINFO <filename>|DIRECTORY]\n");
+ textcolor(RESET, -1, -1);
+ }
+
+
else if (!strcmp(command, "#")) {
printf("\n################################################################################\n");
printf("#");

No commit comments for this range

Something went wrong with that request. Please try again.