Skip to content

Commit

Permalink
moved macros to common.h
Browse files Browse the repository at this point in the history
Signed-off-by: Nick1296 <mattianicolella@gmail.com>
  • Loading branch information
Nick1296 committed Sep 18, 2018
1 parent a293843 commit d983d46
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 19 deletions.
15 changes: 13 additions & 2 deletions common.h
@@ -1,4 +1,4 @@
#pragma once
#pragma once

#include <inttypes.h>
#include <sys/stat.h>
Expand Down Expand Up @@ -29,6 +29,17 @@
#define FILE 0
#define FILENAME_MAX_LENGTH 128
#define PERM_ERR (-2)
// root uid
#define ROOT ((unsigned) 0)
#define GROUP_SIZE 1024
#define NAME_LENGTH 128
// uasername length
#define NAME_LENGTH 128
// gpasswd operation type
#define ADD 1
#define REMOVE 0
// empty group entry
#define EMPTY (-1)
// defining permissions number
#define READ 4
#define WRITE 2
#define EXECUTE 1
2 changes: 1 addition & 1 deletion shell.c
Expand Up @@ -490,7 +490,7 @@ do_cmd(SimpleFS *fs, DirectoryHandle *dh, char tok_buf[MAX_NUM_TOK][MAX_COMMAND_
"\t- info per avere informazioni sul disco\n"
"\t- info -bmap per avere informazioni sulla bitmap del disco\n"
"\t- touch [nome file] per creare un file vuoto\n"
"\t- echo [-a] [contenuto] > [file] per scrivere un messaggio su un file (sovrascive il contenuto se"
"\t- echo [-a] [contenuto] > [file] per scrivere un messaggio su un file (sovrascrive il contenuto se"
"non viene usata l'opzione -a)\n"
"\t- cat [files] per concatenare i file e scriverli sullo schermo\n"
"\t- mkdir [directory] per creare una nuova directory\n"
Expand Down
4 changes: 1 addition & 3 deletions simplefs.h
@@ -1,4 +1,4 @@
#pragma once
#pragma once

#include "bitmap.h"
#include "disk_driver.h"
Expand Down Expand Up @@ -58,5 +58,3 @@ int SimpleFS_mkDir(DirectoryHandle *d, const char *dirname);
// returns -1 on failure 0 on success
// if a directory, it removes recursively all contained files
int SimpleFS_remove(DirectoryHandle *d, const char *filename);


8 changes: 2 additions & 6 deletions simplefs_apis.h
@@ -1,13 +1,9 @@
#pragma once
#pragma once
//macros used to identify the permission octal values
#include "simplefs_structures.h"
#include "common.h"
#include "disk_driver_structures.h"

#define READ 4
#define WRITE 2
#define EXECUTE 1


/* setting the permissions on a file/directory according to the values of each set
it can be called by the root user or the owner of the file
Expand Down Expand Up @@ -91,4 +87,4 @@ int mkDir(DirectoryHandle *d, const char *dirname, int current_user, int user_pr
// returns -1 on failure 0 on success
// if a directory, it removes recursively all contained files
// it requires WRITE permission on the directory which contains the element to remove
int removeFile(DirectoryHandle *d, const char *filename, int current_user, int usr_in_grp);
int removeFile(DirectoryHandle *d, const char *filename, int current_user, int usr_in_grp);
8 changes: 1 addition & 7 deletions users.h
@@ -1,15 +1,9 @@
#pragma once
#pragma once

#include "common.h"
#include "simplefs_structures.h"
#include "list.h"

//macros for gpasswd operation type
#define ADD 1
#define REMOVE 0
//macro to define and empty group entry
#define EMPTY (-1)

//all the operation must be executed as root user

//this struct represents a user account
Expand Down

0 comments on commit d983d46

Please sign in to comment.