Update limit values

This commit is contained in:
Enrico Fraccaroli
2019-05-16 13:59:07 +02:00
parent c0e5808656
commit 552e2a073f
16 changed files with 39 additions and 27 deletions
+6
View File
@@ -39,3 +39,9 @@
/// Maximum value a `signed long int' can hold.
#define LONG_MIN (-LONG_MAX - 1L)
/// Maximum number of characters in a file name.
#define NAME_MAX 255
/// Maximum number of characters in a path name.
#define PATH_MAX 4096
+2 -1
View File
@@ -17,6 +17,7 @@
#include "unistd.h"
#include "list_head.h"
#include "signal_defs.h"
#include "limits.h"
/// The maximum length of a name for a task_struct.
#define TASK_NAME_MAX_LENGTH 100
@@ -170,7 +171,7 @@ typedef struct task_struct {
int error_no;
/// The current working directory.
char cwd[MAX_PATH_LENGTH];
char cwd[PATH_MAX];
//==== Future work =========================================================
// - task's attributes:
+1 -3
View File
@@ -7,9 +7,7 @@
#pragma once
#include "stddef.h"
/// The maximum length for a name.
#define NAME_MAX 30
#include "limits.h"
/// @brief Contains the entries of a directory.
typedef struct dirent_t {
+2 -1
View File
@@ -8,6 +8,7 @@
#include "stdint.h"
#include "kernel.h"
#include "limits.h"
/// Maximum length of credentials.
#define CREDENTIALS_LENGTH 50
@@ -55,7 +56,7 @@ typedef struct userenv_t
char username[CREDENTIALS_LENGTH];
/// The current path.
char cur_path[MAX_PATH_LENGTH];
char cur_path[PATH_MAX];
/// The user identifier.
unsigned int uid;
+2 -1
View File
@@ -7,10 +7,11 @@
#include "fcntl.h"
#include "string.h"
#include "vfs.h"
#include "limits.h"
int remove(const char *pathname)
{
char absolute_path[MAX_PATH_LENGTH];
char absolute_path[PATH_MAX];
strcpy(absolute_path, pathname);
if (pathname[0] != '/') {
get_absolute_path(absolute_path);
+2 -1
View File
@@ -6,6 +6,7 @@
#include "syscall.h"
#include "string.h"
#include "limits.h"
#include "debug.h"
#include "stdio.h"
#include "vfs.h"
@@ -13,7 +14,7 @@
int sys_open(const char *pathname, int flags, mode_t mode)
{
// Allocate a variable for the path.
char absolute_path[MAX_PATH_LENGTH];
char absolute_path[PATH_MAX];
// Copy the path to the working variable.
strcpy(absolute_path, pathname);
+3 -2
View File
@@ -9,6 +9,7 @@
#include "stdio.h"
#include "string.h"
#include "initrd.h"
#include "limits.h"
int sys_stat(const char *path, stat_t *buf)
{
@@ -23,7 +24,7 @@ int sys_stat(const char *path, stat_t *buf)
buf->st_mtime = 0;
buf->st_ctime = 0;
char absolute_path[MAX_PATH_LENGTH];
char absolute_path[PATH_MAX];
strcpy(absolute_path, path);
if (path[0] != '/')
@@ -53,7 +54,7 @@ int sys_stat(const char *path, stat_t *buf)
int sys_mkdir(const char *path, mode_t mode)
{
char absolute_path[MAX_PATH_LENGTH];
char absolute_path[PATH_MAX];
strcpy(absolute_path, path);
int result = -1;
+5 -4
View File
@@ -12,6 +12,7 @@
#include "shell.h"
#include "string.h"
#include "initrd.h"
#include "limits.h"
int current_fd;
char *module_start[MAX_MODULES];
@@ -106,7 +107,7 @@ mountpoint_t *get_mountpoint_from_id(int32_t mp_id)
int get_relative_path(uint32_t mp_id, char *path)
{
char relative_path[MAX_PATH_LENGTH];
char relative_path[PATH_MAX];
// Get the size of the path.
size_t path_size = strlen(path);
@@ -133,9 +134,9 @@ int get_relative_path(uint32_t mp_id, char *path)
int get_absolute_path(char *path)
{
if (path[0] != '/') {
char abspath[MAX_PATH_LENGTH];
memset(abspath, '\0', MAX_PATH_LENGTH);
getcwd(abspath, MAX_PATH_LENGTH);
char abspath[PATH_MAX];
memset(abspath, '\0', PATH_MAX);
getcwd(abspath, PATH_MAX);
int abs_size = strlen(abspath);
if (abspath[abs_size - 1] == '/') {
strncat(abspath, path, strlen(path));
+2 -1
View File
@@ -7,6 +7,7 @@
#include "libgen.h"
#include "string.h"
#include "initrd.h"
#include "limits.h"
int parse_path(char *out, char **cur, char sep, size_t max)
{
@@ -31,7 +32,7 @@ int parse_path(char *out, char **cur, char sep, size_t max)
char *dirname(const char *path)
{
static char s[MAX_PATH_LENGTH];
static char s[PATH_MAX];
static char dot[2] = ".";
+1 -1
View File
@@ -71,7 +71,7 @@ task_struct *create_init_process()
// Enable the interrupts.
init_proc->thread.eflags = init_proc->thread.eflags | EFLAG_IF;
// Clear the current working directory.
memset(init_proc->cwd, '\0', MAX_PATH_LENGTH);
memset(init_proc->cwd, '\0', PATH_MAX);
// Set the state of the process as running.
init_proc->state = TASK_RUNNING;
// Active the current process.
+1 -1
View File
@@ -17,7 +17,7 @@
DIR *opendir(const char *path)
{
char absolute_path[MAX_PATH_LENGTH];
char absolute_path[PATH_MAX];
DIR *pdir = NULL;
strcpy(absolute_path, path);
+2 -1
View File
@@ -7,12 +7,13 @@
#include "unistd.h"
#include "string.h"
#include "limits.h"
#include "stdio.h"
#include "vfs.h"
int rmdir(const char *path)
{
char absolute_path[MAX_PATH_LENGTH];
char absolute_path[PATH_MAX];
strcpy(absolute_path, path);
if (path[0] != '/') {
+4 -4
View File
@@ -16,11 +16,11 @@
void cmd_cd(int argc, char **argv)
{
DIR *dirp = NULL;
char path[MAX_PATH_LENGTH];
memset(path, 0, MAX_PATH_LENGTH);
char path[PATH_MAX];
memset(path, 0, PATH_MAX);
char current_path[MAX_PATH_LENGTH];
getcwd(current_path, MAX_PATH_LENGTH);
char current_path[PATH_MAX];
getcwd(current_path, PATH_MAX);
if (argc <= 1) {
strcpy(path, "/");
+2 -2
View File
@@ -92,8 +92,8 @@ void cmd_ls(int argc, char **argv)
print_ls(dirp, flags);
}
if (no_directory) {
char cwd[MAX_PATH_LENGTH];
getcwd(cwd, MAX_PATH_LENGTH);
char cwd[PATH_MAX];
getcwd(cwd, PATH_MAX);
DIR *dirp = opendir(cwd);
if (dirp == NULL) {
printf("%s: cannot access '%s': %s\n\n", argv[0], cwd, "unknown");
+2 -2
View File
@@ -13,7 +13,7 @@ void cmd_pwd(int argc, char **argv)
{
(void)argc;
(void)argv;
char cwd[MAX_PATH_LENGTH];
getcwd(cwd, MAX_PATH_LENGTH);
char cwd[PATH_MAX];
getcwd(cwd, PATH_MAX);
printf("%s\n", cwd);
}
+2 -2
View File
@@ -215,8 +215,8 @@ static void shell_print_prompt()
video_set_color(BRIGHT_BLUE);
printf(current_user.username);
video_set_color(WHITE);
char cwd[MAX_PATH_LENGTH];
getcwd(cwd, MAX_PATH_LENGTH);
char cwd[PATH_MAX];
getcwd(cwd, PATH_MAX);
printf("~:%s# ", cwd);
// Update the lower-bounds for the video.
lower_bound_x = video_get_column();