Use of all NIL_* defines converted to NULL

This commit is contained in:
Tomas Hruby 2010-05-10 13:26:00 +00:00
parent a1636b85b7
commit 6e25ad8b0a
86 changed files with 447 additions and 476 deletions

View file

@ -25,6 +25,7 @@ static char RcsId[] = "$Header$";
#endif #endif
*/ */
#include <stdlib.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#ifndef S_IREAD #ifndef S_IREAD
@ -47,7 +48,6 @@ struct ranlib *tab;
unsigned int tnum = 0; unsigned int tnum = 0;
char *tstrtab; char *tstrtab;
unsigned int tssiz = 0; unsigned int tssiz = 0;
char *malloc(), *realloc(), *strcpy(), *strncpy();
long time(); long time();
unsigned int tabsz, strtabsz; unsigned int tabsz, strtabsz;
#else #else
@ -68,10 +68,6 @@ typedef char BOOL;
#define MEMBER struct ar_hdr #define MEMBER struct ar_hdr
#define NIL_PTR ((char *) 0)
#define NIL_MEM ((MEMBER *) 0)
#define NIL_LONG ((long *) 0)
#define IO_SIZE (10 * 1024) #define IO_SIZE (10 * 1024)
#define equal(str1, str2) (!strncmp((str1), (str2), 14)) #define equal(str1, str2) (!strncmp((str1), (str2), 14))
@ -136,14 +132,14 @@ char *basename(path)
char *path; char *path;
{ {
register char *ptr = path; register char *ptr = path;
register char *last = NIL_PTR; register char *last = NULL;
while (*ptr != '\0') { while (*ptr != '\0') {
if (*ptr == '/') if (*ptr == '/')
last = ptr; last = ptr;
ptr++; ptr++;
} }
if (last == NIL_PTR) if (last == NULL)
return path; return path;
if (*(last + 1) == '\0') { if (*(last + 1) == '\0') {
*last = '\0'; *last = '\0';
@ -302,7 +298,7 @@ get_member()
again: again:
if (rd_arhdr(ar_fd, &member) == 0) if (rd_arhdr(ar_fd, &member) == 0)
return NIL_MEM; return NULL;
if (member.ar_size < 0) { if (member.ar_size < 0) {
error(TRUE, "archive has member with negative size\n"); error(TRUE, "archive has member with negative size\n");
} }
@ -332,7 +328,7 @@ register char *argv[];
#endif #endif
) )
temp_fd = open_archive(temp_arch, CREATE); temp_fd = open_archive(temp_arch, CREATE);
while ((member = get_member()) != NIL_MEM) { while ((member = get_member()) != NULL) {
if (argc > 3) { if (argc > 3) {
for (i = 3; i < argc; i++) { for (i = 3; i < argc; i++) {
if (equal(basename(argv[i]), member->ar_name)) if (equal(basename(argv[i]), member->ar_name))

View file

@ -52,7 +52,6 @@ typedef struct dir_entry DIRECTORY;
#define DIR 0x2E #define DIR 0x2E
#define DIR_SIZE (sizeof (struct dir_entry)) #define DIR_SIZE (sizeof (struct dir_entry))
#define SUB_DIR 0x10 #define SUB_DIR 0x10
#define NIL_DIR ((DIRECTORY *) 0)
#define LAST_CLUSTER12 0xFFF #define LAST_CLUSTER12 0xFFF
#define LAST_CLUSTER 0xFFFF #define LAST_CLUSTER 0xFFFF
@ -64,7 +63,6 @@ typedef int BOOL;
#define TRUE 1 #define TRUE 1
#define FALSE 0 #define FALSE 0
#define NIL_PTR ((char *) 0)
#define DOS_TIME 315532800L /* 1970 - 1980 */ #define DOS_TIME 315532800L /* 1970 - 1980 */
@ -75,9 +73,9 @@ typedef int BOOL;
#define LABEL 4 #define LABEL 4
#define ENTRY 5 #define ENTRY 5
#define find_entry(d, e, p) directory(d, e, FIND, p) #define find_entry(d, e, p) directory(d, e, FIND, p)
#define list_dir(d, e, f) (void) directory(d, e, f, NIL_PTR) #define list_dir(d, e, f) (void) directory(d, e, f, NULL)
#define label() directory(root, root_entries, LABEL, NIL_PTR) #define label() directory(root, root_entries, LABEL, NULL)
#define new_entry(d, e) directory(d, e, ENTRY, NIL_PTR) #define new_entry(d, e) directory(d, e, ENTRY, NULL)
#define is_dir(d) ((d)->d_attribute & SUB_DIR) #define is_dir(d) ((d)->d_attribute & SUB_DIR)
@ -362,12 +360,12 @@ register char *argv[];
if (dos_dir && Lflag) { if (dos_dir && Lflag) {
entry = label(); entry = label();
printf ("Volume in drive %c ", dev_nr); printf ("Volume in drive %c ", dev_nr);
if (entry == NIL_DIR) if (entry == NULL)
printf("has no label.\n\n"); printf("has no label.\n\n");
else else
printf ("is %.11s\n\n", entry->d_name); printf ("is %.11s\n\n", entry->d_name);
} }
if (argv[idx] == NIL_PTR) { if (argv[idx] == NULL) {
if (!dos_dir) usage(argv[0]); if (!dos_dir) usage(argv[0]);
if (Lflag) printf ("Root directory:\n"); if (Lflag) printf ("Root directory:\n");
list_dir(root, root_entries, FALSE); list_dir(root, root_entries, FALSE);
@ -393,7 +391,7 @@ register char *argv[];
} else if (dos_read) } else if (dos_read)
extract(entry); extract(entry);
else { else {
if (entry != NIL_DIR) { if (entry != NULL) {
fflush (stdout); fflush (stdout);
if (is_dir(entry)) if (is_dir(entry))
fprintf (stderr, "%s: %s is a directory.\n", cmnd, path); fprintf (stderr, "%s: %s is a directory.\n", cmnd, path);
@ -401,7 +399,7 @@ register char *argv[];
fprintf (stderr, "%s: %s already exists.\n", cmnd, argv[idx]); fprintf (stderr, "%s: %s already exists.\n", cmnd, argv[idx]);
exit(1); exit(1);
} }
add_path(NIL_PTR, TRUE); add_path(NULL, TRUE);
if (*path) make_file(find_entry(root, root_entries, path), if (*path) make_file(find_entry(root, root_entries, path),
sub_entries, slash(argv[idx])); sub_entries, slash(argv[idx]));
@ -445,7 +443,7 @@ int function;
register char *pathname; register char *pathname;
{ {
register DIRECTORY *dir_ptr = dir; register DIRECTORY *dir_ptr = dir;
DIRECTORY *mem = NIL_DIR; DIRECTORY *mem = NULL;
unsigned short cl_no = dir->d_cluster; unsigned short cl_no = dir->d_cluster;
unsigned short type, last = 0; unsigned short type, last = 0;
char file_name[14]; char file_name[14];
@ -528,7 +526,7 @@ register char *pathname;
printf ( "Directory %s%s:\n", path, name); printf ( "Directory %s%s:\n", path, name);
add_path(name, FALSE); add_path(name, FALSE);
list_dir(dir_ptr, sub_entries, FALSE); list_dir(dir_ptr, sub_entries, FALSE);
add_path(NIL_PTR, FALSE); add_path(NULL, FALSE);
} }
} }
} }
@ -537,12 +535,12 @@ register char *pathname;
switch (function) { switch (function) {
case FIND: case FIND:
if (dos_write && *pathname == '\0') return NIL_DIR; if (dos_write && *pathname == '\0') return NULL;
fflush (stdout); fflush (stdout);
fprintf (stderr, "%s: Cannot find `%s'.\n", cmnd, file_name); fprintf (stderr, "%s: Cannot find `%s'.\n", cmnd, file_name);
exit(1); exit(1);
case LABEL: case LABEL:
return NIL_DIR; return NULL;
case ENTRY: case ENTRY:
if (!mem) { if (!mem) {
fflush (stdout); fflush (stdout);
@ -1079,7 +1077,7 @@ BOOL slash_fl;
while (*ptr) ptr++; while (*ptr) ptr++;
if (file == NIL_PTR) { if (file == NULL) {
if (ptr != path) ptr--; if (ptr != path) ptr--;
if (ptr != path) do { if (ptr != path) do {
ptr--; ptr--;

View file

@ -128,10 +128,6 @@ struct regex {
typedef struct regex REGEX; typedef struct regex REGEX;
/* NULL definitions */ /* NULL definitions */
#define NIL_PTR ((char *) 0)
#define NIL_LINE ((LINE *) 0)
#define NIL_REG ((REGEX *) 0)
#define NIL_INT ((int *) 0)
/* /*
* Forward declarations * Forward declarations
@ -210,7 +206,7 @@ extern long chars_saved; /* Nr of chars saved in buffer */
/* /*
* Move to coordinates and set textp. (Don't use address) * Move to coordinates and set textp. (Don't use address)
*/ */
#define move_to(nx, ny) move((nx), NIL_PTR, (ny)) #define move_to(nx, ny) move((nx), NULL, (ny))
/* /*
* Move to coordinates on screen as indicated by textp. * Move to coordinates on screen as indicated by textp.
@ -221,12 +217,12 @@ extern long chars_saved; /* Nr of chars saved in buffer */
* Functions handling status_line. ON means in reverse video. * Functions handling status_line. ON means in reverse video.
*/ */
#define status_line(str1, str2) (void) bottom_line(ON, (str1), \ #define status_line(str1, str2) (void) bottom_line(ON, (str1), \
(str2), NIL_PTR, FALSE) (str2), NULL, FALSE)
#define error(str1, str2) (void) bottom_line(ON, (str1), \ #define error(str1, str2) (void) bottom_line(ON, (str1), \
(str2), NIL_PTR, FALSE) (str2), NULL, FALSE)
#define get_string(str1,str2, fl) bottom_line(ON, (str1), NIL_PTR, (str2), fl) #define get_string(str1,str2, fl) bottom_line(ON, (str1), NULL, (str2), fl)
#define clear_status() (void) bottom_line(OFF, NIL_PTR, NIL_PTR, \ #define clear_status() (void) bottom_line(OFF, NULL, NULL, \
NIL_PTR, FALSE) NULL, FALSE)
/* /*
* Print info about current file and buffer. * Print info about current file and buffer.

View file

@ -111,7 +111,7 @@
* *
* A special structure is allocated and its address is assigned to the * A special structure is allocated and its address is assigned to the
* variable header as well as the variable tail. The text field of this * variable header as well as the variable tail. The text field of this
* structure is set to NIL_PTR. The tail->prev of this structure points * structure is set to NULL. The tail->prev of this structure points
* to the last LINE of the file and the header->next to the first LINE. * to the last LINE of the file and the header->next to the first LINE.
* Other LINE *variables are top_line and bot_line which point to the * Other LINE *variables are top_line and bot_line which point to the
* first line resp. the last line on the screen. * first line resp. the last line on the screen.
@ -238,7 +238,7 @@
* startposition on the current line, and a flag indicating FORWARD or * startposition on the current line, and a flag indicating FORWARD or
* REVERSE search. Match () checks out the whole file until a match is * REVERSE search. Match () checks out the whole file until a match is
* found. If match is found it returns a pointer to the line in which the * found. If match is found it returns a pointer to the line in which the
* match was found else it returns a NIL_LINE. Line_check () takes the * match was found else it returns a NULL. Line_check () takes the
* same arguments, but return either MATCH or NO_MATCH. * same arguments, but return either MATCH or NO_MATCH.
* During checking, the start_ptr and end_ptr fields of the REGEX * During checking, the start_ptr and end_ptr fields of the REGEX
* structure are assigned to the start and end of the match. * structure are assigned to the start and end of the match.
@ -259,7 +259,7 @@
* backwards search (SR)) call search () with an apropiate message and a * backwards search (SR)) call search () with an apropiate message and a
* flag indicating FORWARD or REVERSE search. Search () will get an * flag indicating FORWARD or REVERSE search. Search () will get an
* expression from the user by calling get_expression(). Get_expression() * expression from the user by calling get_expression(). Get_expression()
* returns a pointer to a REGEX structure or NIL_REG upon errors and * returns a pointer to a REGEX structure or NULL upon errors and
* prompts for the expression. If no expression if given, the previous is * prompts for the expression. If no expression if given, the previous is
* used instead. After that search will call match (), and if a match is * used instead. After that search will call match (), and if a match is
* found, we can move to that place in the file by the functions find_x() * found, we can move to that place in the file by the functions find_x()
@ -452,7 +452,7 @@ void VI()
#else #else
string_print (enter_string); string_print (enter_string);
#endif /* UNIX */ #endif /* UNIX */
load_file(new_file[0] == '\0' ? NIL_PTR : new_file); load_file(new_file[0] == '\0' ? NULL : new_file);
} }
/* /*
@ -466,7 +466,7 @@ int WT()
int fd; /* Filedescriptor of file */ int fd; /* Filedescriptor of file */
if (modified == FALSE) { if (modified == FALSE) {
error ("Write not necessary.", NIL_PTR); error ("Write not necessary.", NULL);
return FINE; return FINE;
} }
@ -532,11 +532,11 @@ void SH()
int pid, status; int pid, status;
char *shell; char *shell;
if ((shell = getenv("SHELL")) == NIL_PTR) shell = "/bin/sh"; if ((shell = getenv("SHELL")) == NULL) shell = "/bin/sh";
switch (pid = fork()) { switch (pid = fork()) {
case -1: /* Error */ case -1: /* Error */
error("Cannot fork.", NIL_PTR); error("Cannot fork.", NULL);
return; return;
case 0: /* This is the child */ case 0: /* This is the child */
set_cursor(0, ymax); set_cursor(0, ymax);
@ -564,7 +564,7 @@ void SH()
if ((status >> 8) == 127) /* Child died with 127 */ if ((status >> 8) == 127) /* Child died with 127 */
error("Cannot exec ", shell); error("Cannot exec ", shell);
else if ((status >> 8) == 126) else if ((status >> 8) == 126)
error("Cannot open /dev/tty as fd #0", NIL_PTR); error("Cannot open /dev/tty as fd #0", NULL);
} }
/* /*
@ -601,10 +601,10 @@ FLAG statfl;
register char *p = buf; register char *p = buf;
*p++ = ' '; *p++ = ' ';
if (s1 != NIL_PTR) if (s1 != NULL)
while (*p = *s1++) while (*p = *s1++)
p++; p++;
if (s2 != NIL_PTR) if (s2 != NULL)
while (*p = *s2++) while (*p = *s2++)
p++; p++;
*p++ = ' '; *p++ = ' ';
@ -626,7 +626,7 @@ FLAG statfl;
string_print(buf); string_print(buf);
if (inbuf != NIL_PTR) if (inbuf != NULL)
ret = input(inbuf, statfl); ret = input(inbuf, statfl);
/* Print normal video */ /* Print normal video */
@ -637,7 +637,7 @@ FLAG statfl;
string_print(normal_video); string_print(normal_video);
string_print(blank_line); /* Clear the rest of the line */ string_print(blank_line); /* Clear the rest of the line */
#endif /* UNIX */ #endif /* UNIX */
if (inbuf != NIL_PTR) if (inbuf != NULL)
set_cursor(0, ymax); set_cursor(0, ymax);
else else
set_cursor(x, y); /* Set cursor back to old position */ set_cursor(x, y); /* Set cursor back to old position */
@ -713,7 +713,7 @@ char *new_address;
} }
/* Set or unset relative x-coordinate */ /* Set or unset relative x-coordinate */
if (new_address == NIL_PTR) { if (new_address == NULL) {
new_address = find_address(line, (new_x == x) ? rel_x : new_x , &tx); new_address = find_address(line, (new_x == x) ? rel_x : new_x , &tx);
if (new_x != x) if (new_x != x)
rel_x = tx; rel_x = tx;
@ -805,7 +805,7 @@ register char *string;
{ {
register int count = 0; register int count = 0;
if (string != NIL_PTR) { if (string != NULL) {
while (*string++ != '\0') while (*string++ != '\0')
count++; count++;
} }
@ -1061,7 +1061,7 @@ int fd;
build_string(text_buffer, "Command aborted: %s (File incomplete)", build_string(text_buffer, "Command aborted: %s (File incomplete)",
(errno == ENOSPC || errno == -ENOSPC) ? (errno == ENOSPC || errno == -ENOSPC) ?
"No space on device" : "Write error"); "No space on device" : "Write error");
error(text_buffer, NIL_PTR); error(text_buffer, NULL);
} }
/* /*
@ -1083,7 +1083,7 @@ void abort_mined()
quit = FALSE; quit = FALSE;
/* Ask for confirmation */ /* Ask for confirmation */
status_line("Really abort? ", NIL_PTR); status_line("Really abort? ", NULL);
if (getchar() != 'y') { if (getchar() != 'y') {
clear_status(); clear_status();
return; return;
@ -1172,7 +1172,7 @@ int bytes;
char *p; char *p;
p = malloc((unsigned) bytes); p = malloc((unsigned) bytes);
if (p == NIL_PTR) { if (p == NULL) {
if (loading == TRUE) if (loading == TRUE)
panic("File too big."); panic("File too big.");
panic("Out of memory."); panic("Out of memory.");
@ -1281,14 +1281,14 @@ char *basename(path)
char *path; char *path;
{ {
register char *ptr = path; register char *ptr = path;
register char *last = NIL_PTR; register char *last = NULL;
while (*ptr != '\0') { while (*ptr != '\0') {
if (*ptr == '/') if (*ptr == '/')
last = ptr; last = ptr;
ptr++; ptr++;
} }
if (last == NIL_PTR) if (last == NULL)
return path; return path;
if (*(last + 1) == '\0') { /* E.g. /usr/tmp/pipo/ */ if (*(last + 1) == '\0') { /* E.g. /usr/tmp/pipo/ */
*last = '\0'; *last = '\0';
@ -1298,7 +1298,7 @@ char *path;
} }
/* /*
* Load_file loads the file `file' into core. If file is a NIL_PTR or the file * Load_file loads the file `file' into core. If file is a NULL or the file
* couldn't be opened, just some initializations are done, and a line consisting * couldn't be opened, just some initializations are done, and a line consisting
* of a `\n' is installed. * of a `\n' is installed.
*/ */
@ -1314,9 +1314,9 @@ char *file;
/* Open file */ /* Open file */
writable = TRUE; /* Benefit of the doubt */ writable = TRUE; /* Benefit of the doubt */
if (file == NIL_PTR) { if (file == NULL) {
if (rpipe == FALSE) if (rpipe == FALSE)
status_line("No file.", NIL_PTR); status_line("No file.", NULL);
else { else {
fd = 0; fd = 0;
file = "standard input"; file = "standard input";
@ -1370,8 +1370,8 @@ int get_line(fd, buffer)
int fd; int fd;
register char *buffer; register char *buffer;
{ {
static char *last = NIL_PTR; static char *last = NULL;
static char *current = NIL_PTR; static char *current = NULL;
static int read_chars; static int read_chars;
register char *cur_pos = current; register char *cur_pos = current;
char *begin = buffer; char *begin = buffer;
@ -1455,14 +1455,14 @@ char *argv[];
raw_mode(ON); /* Set tty to appropriate mode */ raw_mode(ON); /* Set tty to appropriate mode */
header = tail = (LINE *) alloc(sizeof(LINE)); /* Make header of list*/ header = tail = (LINE *) alloc(sizeof(LINE)); /* Make header of list*/
header->text = NIL_PTR; header->text = NULL;
header->next = tail->prev = header; header->next = tail->prev = header;
/* Load the file (if any) */ /* Load the file (if any) */
if (argc < 2) if (argc < 2)
load_file(NIL_PTR); load_file(NULL);
else { else {
(void) get_file(NIL_PTR, argv[1]); /* Truncate filename */ (void) get_file(NULL, argv[1]); /* Truncate filename */
load_file(argv[1]); load_file(argv[1]);
} }
@ -1652,7 +1652,7 @@ void ESC()
} }
if (quit == TRUE) /* Abort has been given */ if (quit == TRUE) /* Abort has been given */
error("Aborted", NIL_PTR); error("Aborted", NULL);
} }
/* /*
@ -1735,7 +1735,7 @@ FLAG writefl, changed;
msg[LINE_LEN - 4] = SHIFT_MARK; /* Overflow on status line */ msg[LINE_LEN - 4] = SHIFT_MARK; /* Overflow on status line */
msg[LINE_LEN - 3] = '\0'; msg[LINE_LEN - 3] = '\0';
} }
status_line(msg, NIL_PTR); /* Print the information */ status_line(msg, NULL); /* Print the information */
} }
/* /*
@ -1828,11 +1828,11 @@ int *result;
register int index; register int index;
register int count = 0; register int count = 0;
status_line(message, NIL_PTR); status_line(message, NULL);
index = getchar(); index = getchar();
if (quit == FALSE && (index < '0' || index > '9')) { if (quit == FALSE && (index < '0' || index > '9')) {
error("Bad count", NIL_PTR); error("Bad count", NULL);
return ERRORS; return ERRORS;
} }
@ -1923,7 +1923,7 @@ char *message, *file;
char *ptr; char *ptr;
int ret; int ret;
if (message == NIL_PTR || (ret = get_string(message, file, TRUE)) == FINE) { if (message == NULL || (ret = get_string(message, file, TRUE)) == FINE) {
if (length_of((ptr = basename(file))) > NAME_MAX) if (length_of((ptr = basename(file))) > NAME_MAX)
ptr[NAME_MAX] = '\0'; ptr[NAME_MAX] = '\0';
} }

View file

@ -471,13 +471,13 @@ void CTL()
{ {
register char ctrl; register char ctrl;
status_line("Enter control character.", NIL_PTR); status_line("Enter control character.", NULL);
if ((ctrl = getchar()) >= '\01' && ctrl <= '\037') { if ((ctrl = getchar()) >= '\01' && ctrl <= '\037') {
S(ctrl); /* Insert the char */ S(ctrl); /* Insert the char */
clear_status(); clear_status();
} }
else else
error ("Unknown control character", NIL_PTR); error ("Unknown control character", NULL);
} }
/* /*
@ -528,7 +528,7 @@ char *location, *string;
register char *textp = line->text; register char *textp = line->text;
if (length_of(textp) + length_of(string) >= MAX_CHARS) { if (length_of(textp) + length_of(string) >= MAX_CHARS) {
error("Line too long", NIL_PTR); error("Line too long", NULL);
return ERRORS; return ERRORS;
} }
@ -607,12 +607,12 @@ char *start_textp, *end_textp;
/* Check if line doesn't exceed MAX_CHARS */ /* Check if line doesn't exceed MAX_CHARS */
if (count + length_of(end_textp) >= MAX_CHARS) { if (count + length_of(end_textp) >= MAX_CHARS) {
error("Line too long", NIL_PTR); error("Line too long", NULL);
return; return;
} }
/* Copy last part of end_line if end_line is not tail */ /* Copy last part of end_line if end_line is not tail */
copy_string(bufp, (end_textp != NIL_PTR) ? end_textp : "\n"); copy_string(bufp, (end_textp != NULL) ? end_textp : "\n");
/* Delete all lines between start and end_position (including end_line) */ /* Delete all lines between start and end_position (including end_line) */
line = start_line->next; line = start_line->next;
@ -623,7 +623,7 @@ char *start_textp, *end_textp;
} }
/* Check if last line of file should be deleted */ /* Check if last line of file should be deleted */
if (end_textp == NIL_PTR && length_of(start_line->text) == 1 && nlines > 1) { if (end_textp == NULL && length_of(start_line->text) == 1 && nlines > 1) {
start_line = start_line->prev; start_line = start_line->prev;
(void) line_delete(start_line->next); (void) line_delete(start_line->next);
line_cnt++; line_cnt++;
@ -681,7 +681,7 @@ void PT()
register int fd; /* File descriptor for buffer */ register int fd; /* File descriptor for buffer */
if ((fd = scratch_file(READ)) == ERRORS) if ((fd = scratch_file(READ)) == ERRORS)
error("Buffer is empty.", NIL_PTR); error("Buffer is empty.", NULL);
else { else {
file_insert(fd, FALSE);/* Insert the buffer */ file_insert(fd, FALSE);/* Insert the buffer */
(void) close(fd); (void) close(fd);
@ -782,7 +782,7 @@ void WB()
/* Checkout the buffer */ /* Checkout the buffer */
if ((yank_fd = scratch_file(READ)) == ERRORS) { if ((yank_fd = scratch_file(READ)) == ERRORS) {
error("Buffer is empty.", NIL_PTR); error("Buffer is empty.", NULL);
return; return;
} }
@ -821,7 +821,7 @@ void MA()
{ {
mark_line = cur_line; mark_line = cur_line;
mark_text = cur_text; mark_text = cur_text;
status_line("Mark set", NIL_PTR); status_line("Mark set", NULL);
} }
/* /*
@ -851,7 +851,7 @@ FLAG remove; /* DELETE if text should be deleted */
{ {
switch (checkmark()) { switch (checkmark()) {
case NOT_VALID : case NOT_VALID :
error("Mark not set.", NIL_PTR); error("Mark not set.", NULL);
return; return;
case SMALLER : case SMALLER :
yank(mark_line, mark_text, cur_line, cur_text, remove); yank(mark_line, mark_text, cur_line, cur_text, remove);
@ -862,7 +862,7 @@ FLAG remove; /* DELETE if text should be deleted */
case SAME : /* Ignore stupid behaviour */ case SAME : /* Ignore stupid behaviour */
yank_status = EMPTY; yank_status = EMPTY;
chars_saved = 0L; chars_saved = 0L;
status_line("0 characters saved in buffer.", NIL_PTR); status_line("0 characters saved in buffer.", NULL);
break; break;
} }
} }
@ -938,7 +938,7 @@ FLAG remove; /* DELETE if text should be deleted */
chars_saved = 0L; chars_saved = 0L;
lines_saved = 0; lines_saved = 0;
status_line("Saving text.", NIL_PTR); status_line("Saving text.", NULL);
/* Keep writing chars until the end_location is reached. */ /* Keep writing chars until the end_location is reached. */
while (textp != end_textp) { while (textp != end_textp) {
@ -1005,7 +1005,7 @@ FLAG mode; /* Can be READ or WRITE permission */
/* Check file existence */ /* Check file existence */
if (access(yank_file, 0) == 0 || (fd = creat(yank_file, 0644)) < 0) { if (access(yank_file, 0) == 0 || (fd = creat(yank_file, 0644)) < 0) {
if (trials++ >= MAXTRAILS) { if (trials++ >= MAXTRAILS) {
error("Unable to creat scratchfile.", NIL_PTR); error("Unable to creat scratchfile.", NULL);
return ERRORS; return ERRORS;
} }
else else
@ -1065,7 +1065,7 @@ void SR()
/* /*
* Get_expression() prompts for an expression. If just a return is typed, the * Get_expression() prompts for an expression. If just a return is typed, the
* old expression is used. If the expression changed, compile() is called and * old expression is used. If the expression changed, compile() is called and
* the returning REGEX structure is returned. It returns NIL_REG upon error. * the returning REGEX structure is returned. It returns NULL upon error.
* The save flag indicates whether the expression should be appended at the * The save flag indicates whether the expression should be appended at the
* message pointer. * message pointer.
*/ */
@ -1076,11 +1076,11 @@ char *message;
char exp_buf[LINE_LEN]; /* Buffer for new expr. */ char exp_buf[LINE_LEN]; /* Buffer for new expr. */
if (get_string(message, exp_buf, FALSE) == ERRORS) if (get_string(message, exp_buf, FALSE) == ERRORS)
return NIL_REG; return NULL;
if (exp_buf[0] == '\0' && typed_expression[0] == '\0') { if (exp_buf[0] == '\0' && typed_expression[0] == '\0') {
error("No previous expression.", NIL_PTR); error("No previous expression.", NULL);
return NIL_REG; return NULL;
} }
if (exp_buf[0] != '\0') { /* A new expr. is typed */ if (exp_buf[0] != '\0') { /* A new expr. is typed */
@ -1089,8 +1089,8 @@ char *message;
} }
if (program.status == REG_ERROR) { /* Error during compiling */ if (program.status == REG_ERROR) { /* Error during compiling */
error(program.result.err_mess, NIL_PTR); error(program.result.err_mess, NULL);
return NIL_REG; return NULL;
} }
return &program; return &program;
} }
@ -1133,7 +1133,7 @@ FLAG file;
/* Save message and get expression */ /* Save message and get expression */
copy_string(mess_buf, message); copy_string(mess_buf, message);
if ((program = get_expression(mess_buf)) == NIL_REG) if ((program = get_expression(mess_buf)) == NULL)
return; return;
/* Get substitution pattern */ /* Get substitution pattern */
@ -1151,7 +1151,7 @@ FLAG file;
do { do {
subs++; /* Increment subs */ subs++; /* Increment subs */
if ((textp = substitute(line, program,replacement)) if ((textp = substitute(line, program,replacement))
== NIL_PTR) == NULL)
return; /* Line too long */ return; /* Line too long */
} while ((program->status & BEGIN_LINE) != BEGIN_LINE && } while ((program->status & BEGIN_LINE) != BEGIN_LINE &&
(program->status & END_LINE) != END_LINE && (program->status & END_LINE) != END_LINE &&
@ -1170,11 +1170,11 @@ FLAG file;
copy_string(mess_buf, (quit == TRUE) ? "(Aborted) " : ""); copy_string(mess_buf, (quit == TRUE) ? "(Aborted) " : "");
/* Fix the status line */ /* Fix the status line */
if (subs == 0L && quit == FALSE) if (subs == 0L && quit == FALSE)
error("Pattern not found.", NIL_PTR); error("Pattern not found.", NULL);
else if (lines >= REPORT || quit == TRUE) { else if (lines >= REPORT || quit == TRUE) {
build_string(mess_buf, "%s %D substitutions on %D lines.", mess_buf, build_string(mess_buf, "%s %D substitutions on %D lines.", mess_buf,
subs, lines); subs, lines);
status_line(mess_buf, NIL_PTR); status_line(mess_buf, NULL);
} }
else if (file == NOT_VALID && subs >= REPORT) else if (file == NOT_VALID && subs >= REPORT)
status_line(num_out(subs), " substitutions."); status_line(num_out(subs), " substitutions.");
@ -1224,8 +1224,8 @@ char *replacement; /* Contains replacement pattern */
/* Check for line length not exceeding MAX_CHARS */ /* Check for line length not exceeding MAX_CHARS */
if (length_of(text_buffer) + length_of(program->end_ptr) >= MAX_CHARS) { if (length_of(text_buffer) + length_of(program->end_ptr) >= MAX_CHARS) {
error("Substitution result: line too big", NIL_PTR); error("Substitution result: line too big", NULL);
return NIL_PTR; return NULL;
} }
/* Append last part of line to the new build line */ /* Append last part of line to the new build line */
@ -1242,7 +1242,7 @@ char *replacement; /* Contains replacement pattern */
/* /*
* Search() calls get_expression to fetch the expression. If this went well, * Search() calls get_expression to fetch the expression. If this went well,
* the function match() is called which returns the line with the next match. * the function match() is called which returns the line with the next match.
* If this line is the NIL_LINE, it means that a match could not be found. * If this line is the NULL, it means that a match could not be found.
* Find_x() and find_y() display the right page on the screen, and return * Find_x() and find_y() display the right page on the screen, and return
* the right coordinates for x and y. These coordinates are passed to move_to() * the right coordinates for x and y. These coordinates are passed to move_to()
*/ */
@ -1254,17 +1254,17 @@ FLAG method;
register LINE *match_line; register LINE *match_line;
/* Get the expression */ /* Get the expression */
if ((program = get_expression(message)) == NIL_REG) if ((program = get_expression(message)) == NULL)
return; return;
set_cursor(0, ymax); set_cursor(0, ymax);
flush(); flush();
/* Find the match */ /* Find the match */
if ((match_line = match(program, cur_text, method)) == NIL_LINE) { if ((match_line = match(program, cur_text, method)) == NULL) {
if (quit == TRUE) if (quit == TRUE)
status_line("Aborted", NIL_PTR); status_line("Aborted", NULL);
else else
status_line("Pattern not found.", NIL_PTR); status_line("Pattern not found.", NULL);
return; return;
} }
@ -1499,7 +1499,7 @@ REGEX *program;
* Match gets as argument the program, pointer to place in current line to * Match gets as argument the program, pointer to place in current line to
* start from and the method to search for (either FORWARD or REVERSE). * start from and the method to search for (either FORWARD or REVERSE).
* Match() will look through the whole file until a match is found. * Match() will look through the whole file until a match is found.
* NIL_LINE is returned if no match could be found. * NULL is returned if no match could be found.
*/ */
LINE *match(program, string, method) LINE *match(program, string, method)
REGEX *program; REGEX *program;
@ -1511,7 +1511,7 @@ register FLAG method;
/* Corrupted program */ /* Corrupted program */
if (program->status == REG_ERROR) if (program->status == REG_ERROR)
return NIL_LINE; return NULL;
/* Check part of text first */ /* Check part of text first */
if (!(program->status & BEGIN_LINE)) { if (!(program->status & BEGIN_LINE)) {
@ -1533,14 +1533,14 @@ register FLAG method;
/* No match in last (or first) part of line. Check out rest of file */ /* No match in last (or first) part of line. Check out rest of file */
do { do {
line = (method == FORWARD) ? line->next : line->prev; line = (method == FORWARD) ? line->next : line->prev;
if (line->text == NIL_PTR) /* Header/tail */ if (line->text == NULL) /* Header/tail */
continue; continue;
if (line_check(program, line->text, method) == MATCH) if (line_check(program, line->text, method) == MATCH)
return line; return line;
} while (line != cur_line && quit == FALSE); } while (line != cur_line && quit == FALSE);
/* No match found. */ /* No match found. */
return NIL_LINE; return NULL;
} }
/* /*
@ -1560,7 +1560,7 @@ FLAG method;
/* If the match must be anchored, just check the string. */ /* If the match must be anchored, just check the string. */
if (program->status & BEGIN_LINE) if (program->status & BEGIN_LINE)
return check_string(program, string, NIL_INT); return check_string(program, string, NULL);
if (method == REVERSE) { if (method == REVERSE) {
/* First move to the end of the string */ /* First move to the end of the string */
@ -1569,7 +1569,7 @@ FLAG method;
/* Start checking string until the begin of the string is met */ /* Start checking string until the begin of the string is met */
while (textp >= string) { while (textp >= string) {
program->start_ptr = textp; program->start_ptr = textp;
if (check_string(program, textp--, NIL_INT)) if (check_string(program, textp--, NULL))
return MATCH; return MATCH;
} }
} }
@ -1577,7 +1577,7 @@ FLAG method;
/* Move through the string until the end of is found */ /* Move through the string until the end of is found */
while (quit == FALSE && *textp != '\0') { while (quit == FALSE && *textp != '\0') {
program->start_ptr = textp; program->start_ptr = textp;
if (check_string(program, textp, NIL_INT)) if (check_string(program, textp, NULL))
return MATCH; return MATCH;
if (*textp == '\n') if (*textp == '\n')
break; break;
@ -1606,7 +1606,7 @@ int *expression;
char *mark; /* For marking position */ char *mark; /* For marking position */
int star_fl; /* A star has been born */ int star_fl; /* A star has been born */
if (expression == NIL_INT) if (expression == NULL)
expression = program->result.expression; expression = program->result.expression;
/* Loop until end of string or end of expression */ /* Loop until end of string or end of expression */

View file

@ -55,7 +55,6 @@
/* Return status of functions */ /* Return status of functions */
#define OK 0 #define OK 0
#define ERROR -1 #define ERROR -1
#define NIL_PTR ((char *) 0)
/* Compare return values */ /* Compare return values */
#define LOWER -1 #define LOWER -1
@ -82,7 +81,6 @@ typedef struct {
char *line; /* Contains line currently used */ char *line; /* Contains line currently used */
} MERGE; } MERGE;
#define NIL_MERGE ((MERGE *) 0)
MERGE merge_f[OPEN_FILES]; /* Merge structs */ MERGE merge_f[OPEN_FILES]; /* Merge structs */
int buf_size; /* Size of core available for each struct */ int buf_size; /* Size of core available for each struct */
@ -256,7 +254,7 @@ register FIELD *field;
field->reverse = TRUE; field->reverse = TRUE;
break; break;
default: /* Illegal options */ default: /* Illegal options */
error(TRUE, USAGE, NIL_PTR); error(TRUE, USAGE, NULL);
} }
} }
@ -302,7 +300,7 @@ BOOL beg_fl; /* Assign beg or end of field */
if (ptr && *ptr == '-' && ((table[*(ptr + 1)] & DIGIT) || *(ptr + 1) == '.')) { if (ptr && *ptr == '-' && ((table[*(ptr + 1)] & DIGIT) || *(ptr + 1) == '.')) {
new_field(field, offset, FALSE); new_field(field, offset, FALSE);
if (field->beg_field > field->end_field) if (field->beg_field > field->end_field)
error(TRUE, "End field is before start field!", NIL_PTR); error(TRUE, "End field is before start field!", NULL);
} else /* No end pos. */ } else /* No end pos. */
field->end_field = ERROR; field->end_field = ERROR;
} }
@ -326,7 +324,7 @@ char *argv[];
break; break;
if (*ptr == '+') { /* Assign field. */ if (*ptr == '+') { /* Assign field. */
if (++field_cnt == FIELDS_LIMIT) if (++field_cnt == FIELDS_LIMIT)
error(TRUE, "Too many fields", NIL_PTR); error(TRUE, "Too many fields", NULL);
new_field(&fields[field_cnt], &arg_count, TRUE); new_field(&fields[field_cnt], &arg_count, TRUE);
} else { /* Get output options */ } else { /* Get output options */
while (*++ptr) { while (*++ptr) {
@ -372,14 +370,14 @@ char *argv[];
/* Only merge files. Set up */ /* Only merge files. Set up */
if (only_merge) { if (only_merge) {
args_limit = args_offset = arg_count; args_limit = args_offset = arg_count;
while (argv[args_limit] != NIL_PTR) while (argv[args_limit] != NULL)
args_limit++; /* Find nr of args */ args_limit++; /* Find nr of args */
files_merge(args_limit - arg_count); files_merge(args_limit - arg_count);
exit(0); exit(0);
} }
if (arg_count == argc) { /* No args left. Use stdin */ if (arg_count == argc) { /* No args left. Use stdin */
if (check) if (check)
check_file(0, NIL_PTR); check_file(0, NULL);
else else
get_file(0, (off_t) 0); get_file(0, (off_t) 0);
} else } else
@ -436,7 +434,7 @@ register BOOL quit;
register char *message, *arg; register char *message, *arg;
{ {
write(2, message, strlen(message)); write(2, message, strlen(message));
if (arg != NIL_PTR) write(2, arg, strlen(arg)); if (arg != NULL) write(2, arg, strlen(arg));
perror(" "); perror(" ");
if (quit) exit(1); if (quit) exit(1);
} }
@ -446,7 +444,7 @@ register char *message, *arg;
*/ */
void open_outfile() void open_outfile()
{ {
if (output_file == NIL_PTR) if (output_file == NULL)
out_fd = STD_OUT; out_fd = STD_OUT;
else if ((out_fd = creat(output_file, 0644)) < 0) else if ((out_fd = creat(output_file, 0644)) < 0)
error(TRUE, "Cannot creat ", output_file); error(TRUE, "Cannot creat ", output_file);
@ -534,10 +532,10 @@ int fd;
if ((fd = creat(file_name(nr_of_files), 0644)) < 0) if ((fd = creat(file_name(nr_of_files), 0644)) < 0)
error(TRUE, "Cannot creat ", file_name(nr_of_files)); error(TRUE, "Cannot creat ", file_name(nr_of_files));
} }
for (line_ptr = line_table; *line_ptr != NIL_PTR; line_ptr++) { for (line_ptr = line_table; *line_ptr != NULL; line_ptr++) {
ptr = *line_ptr; ptr = *line_ptr;
/* Skip all same lines if uniq is set */ /* Skip all same lines if uniq is set */
if (uniq && *(line_ptr + 1) != NIL_PTR) { if (uniq && *(line_ptr + 1) != NULL) {
if (compare(ptr, *(line_ptr + 1)) == SAME) continue; if (compare(ptr, *(line_ptr + 1)) == SAME) continue;
} }
do { /* Print line in a buffered way */ do { /* Print line in a buffered way */
@ -575,7 +573,7 @@ char *address;
register int bytes; register int bytes;
{ {
if (read(fd, address, bytes) < 0 && bytes != 0) if (read(fd, address, bytes) < 0 && bytes != 0)
error(TRUE, "Read error", NIL_PTR); error(TRUE, "Read error", NULL);
} }
/* Mwrite () performs a normal write (), but checks the return value. */ /* Mwrite () performs a normal write (), but checks the return value. */
@ -585,7 +583,7 @@ char *address;
register int bytes; register int bytes;
{ {
if (write(fd, address, bytes) != bytes && bytes != 0) if (write(fd, address, bytes) != bytes && bytes != 0)
error(TRUE, "Write error", NIL_PTR); error(TRUE, "Write error", NULL);
} }
/* Sort () sorts the input in memory starting at mem_top. */ /* Sort () sorts the input in memory starting at mem_top. */
@ -608,7 +606,7 @@ void sort()
if (*ptr++ == '\n') line_table[count++] = ptr; if (*ptr++ == '\n') line_table[count++] = ptr;
} }
line_table[count - 1] = NIL_PTR; line_table[count - 1] = NULL;
/* Sort the line table */ /* Sort the line table */
sort_table(count - 1); sort_table(count - 1);
@ -972,20 +970,20 @@ int start_file, limit_file;
if (only_merge && uniq) if (only_merge && uniq)
uniq_lines(smallest); /* Print only uniq lines */ uniq_lines(smallest); /* Print only uniq lines */
else /* Print rest of file */ else /* Print rest of file */
while (print(smallest, file_cnt) != NIL_MERGE); while (print(smallest, file_cnt) != NULL);
put_line(NIL_PTR); /* Flush output buffer */ put_line(NULL); /* Flush output buffer */
} }
/* Put_line () prints the line into the out_fd filedescriptor. If line equals /* Put_line () prints the line into the out_fd filedescriptor. If line equals
* NIL_PTR, the out_fd is flushed and closed. * NULL, the out_fd is flushed and closed.
*/ */
void put_line(line) void put_line(line)
register char *line; register char *line;
{ {
static int index = 0; /* Index in out_buffer */ static int index = 0; /* Index in out_buffer */
if (line == NIL_PTR) { /* Flush and close */ if (line == NULL) { /* Flush and close */
mwrite(out_fd, out_buffer, index); mwrite(out_fd, out_buffer, index);
index = 0; index = 0;
(void) close(out_fd); (void) close(out_fd);
@ -1021,7 +1019,7 @@ int file_cnt; /* Nr of files that are being merged */
} }
} }
if (i == file_cnt) /* No more files left */ if (i == file_cnt) /* No more files left */
return NIL_MERGE; return NULL;
} }
return merg; return merg;
} }
@ -1170,7 +1168,7 @@ register int size;
register char *address; register char *address;
if ((address = sbrk(size)) == (char *) -1) if ((address = sbrk(size)) == (char *) -1)
error(TRUE, "Not enough memory. Use chmem to allocate more", NIL_PTR); error(TRUE, "Not enough memory. Use chmem to allocate more", NULL);
return address; return address;
} }
@ -1178,7 +1176,7 @@ register int size;
void mbrk(address) void mbrk(address)
char *address; char *address;
{ {
if (brk(address) == -1) error(TRUE, "Cannot reset memory", NIL_PTR); if (brk(address) == -1) error(TRUE, "Cannot reset memory", NULL);
} }
void catch(dummy) void catch(dummy)

View file

@ -579,7 +579,7 @@ PRIVATE int w_do_open(struct driver *dp, message *m_ptr)
struct wini *wn; struct wini *wn;
if (w_prepare(m_ptr->DEVICE) == NIL_DEV) return(ENXIO); if (w_prepare(m_ptr->DEVICE) == NULL) return(ENXIO);
wn = w_wn; wn = w_wn;
@ -657,7 +657,7 @@ PRIVATE struct device *w_prepare(int device)
w_dv = &w_wn->subpart[device % SUB_PER_DRIVE]; w_dv = &w_wn->subpart[device % SUB_PER_DRIVE];
} else { } else {
w_device = -1; w_device = -1;
return(NIL_DEV); return(NULL);
} }
return(w_dv); return(w_dv);
} }
@ -954,13 +954,13 @@ PRIVATE int w_io_test(void)
w_testing = 1; w_testing = 1;
/* Try I/O on the actual drive (not any (sub)partition). */ /* Try I/O on the actual drive (not any (sub)partition). */
if (w_prepare(w_drive * DEV_PER_DRIVE) == NIL_DEV) if (w_prepare(w_drive * DEV_PER_DRIVE) == NULL)
panic("Couldn't switch devices"); panic("Couldn't switch devices");
r = w_transfer(SELF, DEV_GATHER_S, cvu64(0), &iov, 1); r = w_transfer(SELF, DEV_GATHER_S, cvu64(0), &iov, 1);
/* Switch back. */ /* Switch back. */
if (w_prepare(save_dev) == NIL_DEV) if (w_prepare(save_dev) == NULL)
panic("Couldn't switch back devices"); panic("Couldn't switch back devices");
/* Restore parameters. */ /* Restore parameters. */
@ -1726,7 +1726,7 @@ PRIVATE void w_need_reset()
PRIVATE int w_do_close(struct driver *dp, message *m_ptr) PRIVATE int w_do_close(struct driver *dp, message *m_ptr)
{ {
/* Device close: Release a device. */ /* Device close: Release a device. */
if (w_prepare(m_ptr->DEVICE) == NIL_DEV) if (w_prepare(m_ptr->DEVICE) == NULL)
return(ENXIO); return(ENXIO);
w_wn->open_ct--; w_wn->open_ct--;
#if ENABLE_ATAPI #if ENABLE_ATAPI
@ -2352,7 +2352,7 @@ message *m;
return OK; return OK;
} else if (m->REQUEST == DIOCOPENCT) { } else if (m->REQUEST == DIOCOPENCT) {
int count; int count;
if (w_prepare(m->DEVICE) == NIL_DEV) return ENXIO; if (w_prepare(m->DEVICE) == NULL) return ENXIO;
count = w_wn->open_ct; count = w_wn->open_ct;
r= sys_safecopyto(m->IO_ENDPT, (cp_grant_id_t) m->IO_GRANT, r= sys_safecopyto(m->IO_ENDPT, (cp_grant_id_t) m->IO_GRANT,
0, (vir_bytes)&count, sizeof(count), D); 0, (vir_bytes)&count, sizeof(count), D);

View file

@ -159,10 +159,10 @@ int device;
w_wn = &wini[w_drive]; w_wn = &wini[w_drive];
w_dv = &w_wn->subpart[device % SUB_PER_DRIVE]; w_dv = &w_wn->subpart[device % SUB_PER_DRIVE];
} else { } else {
return(NIL_DEV); return(NULL);
} }
if (w_drive >= MAX_DRIVES || !w_wn->present) if (w_drive >= MAX_DRIVES || !w_wn->present)
return NIL_DEV; return NULL;
return(w_dv); return(w_dv);
} }
@ -369,7 +369,7 @@ message *m_ptr;
if (!init_done) { w_init(); init_done = TRUE; } if (!init_done) { w_init(); init_done = TRUE; }
if (w_prepare(m_ptr->DEVICE) == NIL_DEV) return(ENXIO); if (w_prepare(m_ptr->DEVICE) == NULL) return(ENXIO);
if (w_wn->open_ct++ == 0) { if (w_wn->open_ct++ == 0) {
/* Partition the disk. */ /* Partition the disk. */
@ -387,7 +387,7 @@ message *m_ptr;
{ {
/* Device close: Release a device. */ /* Device close: Release a device. */
if (w_prepare(m_ptr->DEVICE) == NIL_DEV) return(ENXIO); if (w_prepare(m_ptr->DEVICE) == NULL) return(ENXIO);
w_wn->open_ct--; w_wn->open_ct--;
return(OK); return(OK);
} }
@ -526,7 +526,7 @@ PRIVATE int w_other(struct driver *UNUSED(dr), message *m)
if (m->REQUEST == DIOCOPENCT) { if (m->REQUEST == DIOCOPENCT) {
int count; int count;
if (w_prepare(m->DEVICE) == NIL_DEV) return ENXIO; if (w_prepare(m->DEVICE) == NULL) return ENXIO;
count = w_wn->open_ct; count = w_wn->open_ct;
r=sys_safecopyto(m->IO_ENDPT, (cp_grant_id_t)m->IO_GRANT, r=sys_safecopyto(m->IO_ENDPT, (cp_grant_id_t)m->IO_GRANT,
0, (vir_bytes)&count, sizeof(count), D); 0, (vir_bytes)&count, sizeof(count), D);

View file

@ -456,7 +456,7 @@ PRIVATE struct device *f_prepare(int device)
f_device = device; f_device = device;
f_drive = device & ~(DEV_TYPE_BITS | FORMAT_DEV_BIT); f_drive = device & ~(DEV_TYPE_BITS | FORMAT_DEV_BIT);
if (f_drive < 0 || f_drive >= NR_DRIVES) return(NIL_DEV); if (f_drive < 0 || f_drive >= NR_DRIVES) return(NULL);
f_fp = &floppy[f_drive]; f_fp = &floppy[f_drive];
f_dv = &f_fp->fl_geom; f_dv = &f_fp->fl_geom;
@ -1316,7 +1316,7 @@ message *m_ptr; /* pointer to open message */
struct test_order *top; struct test_order *top;
/* Decode the message parameters. */ /* Decode the message parameters. */
if (f_prepare(m_ptr->DEVICE) == NIL_DEV) return(ENXIO); if (f_prepare(m_ptr->DEVICE) == NULL) return(ENXIO);
dtype = f_device & DEV_TYPE_BITS; /* get density from minor dev */ dtype = f_device & DEV_TYPE_BITS; /* get density from minor dev */
if (dtype >= MINOR_fd0p0) dtype = 0; if (dtype >= MINOR_fd0p0) dtype = 0;

View file

@ -149,7 +149,7 @@ int device;
{ {
/* Prepare for I/O on a device: check if the minor device number is ok. */ /* Prepare for I/O on a device: check if the minor device number is ok. */
if (device < 0 || device >= NR_DEVS) return(NIL_DEV); if (device < 0 || device >= NR_DEVS) return(NULL);
log_device = device; log_device = device;
return(&log_geom[device]); return(&log_geom[device]);
@ -373,7 +373,7 @@ PRIVATE int log_do_open(dp, m_ptr)
struct driver *dp; struct driver *dp;
message *m_ptr; message *m_ptr;
{ {
if (log_prepare(m_ptr->DEVICE) == NIL_DEV) return(ENXIO); if (log_prepare(m_ptr->DEVICE) == NULL) return(ENXIO);
return(OK); return(OK);
} }

View file

@ -177,7 +177,7 @@ PRIVATE struct device *m_prepare(device)
int device; int device;
{ {
/* Prepare for I/O on a device: check if the minor device number is ok. */ /* Prepare for I/O on a device: check if the minor device number is ok. */
if (device < 0 || device >= NR_DEVS) return(NIL_DEV); if (device < 0 || device >= NR_DEVS) return(NULL);
m_device = device; m_device = device;
return(&m_geom[device]); return(&m_geom[device]);
@ -352,7 +352,7 @@ message *m_ptr;
int r; int r;
/* Check device number on open. */ /* Check device number on open. */
if (m_prepare(m_ptr->DEVICE) == NIL_DEV) return(ENXIO); if (m_prepare(m_ptr->DEVICE) == NULL) return(ENXIO);
if (m_device == MEM_DEV) if (m_device == MEM_DEV)
{ {
r = sys_enable_iop(m_ptr->IO_ENDPT); r = sys_enable_iop(m_ptr->IO_ENDPT);
@ -382,7 +382,7 @@ message *m_ptr;
{ {
int r; int r;
if (m_prepare(m_ptr->DEVICE) == NIL_DEV) return(ENXIO); if (m_prepare(m_ptr->DEVICE) == NULL) return(ENXIO);
if(m_device < 0 || m_device >= NR_DEVS) { if(m_device < 0 || m_device >= NR_DEVS) {
panic("wrong m_device: %d", m_device); panic("wrong m_device: %d", m_device);
@ -423,7 +423,7 @@ message *m_ptr; /* pointer to control message */
if((dev < RAM_DEV_FIRST || dev > RAM_DEV_LAST) && dev != RAM_DEV_OLD) { if((dev < RAM_DEV_FIRST || dev > RAM_DEV_LAST) && dev != RAM_DEV_OLD) {
printf("MEM: MIOCRAMSIZE: %d not a ramdisk\n", dev); printf("MEM: MIOCRAMSIZE: %d not a ramdisk\n", dev);
} }
if ((dv = m_prepare(dev)) == NIL_DEV) return(ENXIO); if ((dv = m_prepare(dev)) == NULL) return(ENXIO);
/* Get request structure */ /* Get request structure */
s= sys_safecopyfrom(m_ptr->IO_ENDPT, (vir_bytes)m_ptr->IO_GRANT, s= sys_safecopyfrom(m_ptr->IO_ENDPT, (vir_bytes)m_ptr->IO_GRANT,

View file

@ -142,7 +142,7 @@ int device;
{ {
/* Prepare for I/O on a device: check if the minor device number is ok. */ /* Prepare for I/O on a device: check if the minor device number is ok. */
if (device < 0 || device >= NR_DEVS) return(NIL_DEV); if (device < 0 || device >= NR_DEVS) return(NULL);
m_device = device; m_device = device;
return(&m_geom[device]); return(&m_geom[device]);
@ -233,7 +233,7 @@ message *m_ptr;
{ {
/* Check device number on open. /* Check device number on open.
*/ */
if (r_prepare(m_ptr->DEVICE) == NIL_DEV) return(ENXIO); if (r_prepare(m_ptr->DEVICE) == NULL) return(ENXIO);
return(OK); return(OK);
} }
@ -245,7 +245,7 @@ PRIVATE int r_ioctl(dp, m_ptr)
struct driver *dp; /* pointer to driver structure */ struct driver *dp; /* pointer to driver structure */
message *m_ptr; /* pointer to control message */ message *m_ptr; /* pointer to control message */
{ {
if (r_prepare(m_ptr->DEVICE) == NIL_DEV) return(ENXIO); if (r_prepare(m_ptr->DEVICE) == NULL) return(ENXIO);
switch (m_ptr->REQUEST) { switch (m_ptr->REQUEST) {

View file

@ -51,7 +51,6 @@
/* Message passing constants. */ /* Message passing constants. */
#define MESS_SIZE (sizeof(message)) /* might need usizeof from FS here */ #define MESS_SIZE (sizeof(message)) /* might need usizeof from FS here */
#define NIL_MESS ((message *) 0) /* null pointer */
/* Memory related constants. */ /* Memory related constants. */
#define SEGMENT_TYPE 0xFF00 /* bit mask to get segment type */ #define SEGMENT_TYPE 0xFF00 /* bit mask to get segment type */
@ -89,7 +88,6 @@
#define BYTE 0377 /* mask for 8 bits */ #define BYTE 0377 /* mask for 8 bits */
#define READING 0 /* copy data to user */ #define READING 0 /* copy data to user */
#define WRITING 1 /* copy data from user */ #define WRITING 1 /* copy data from user */
#define NIL_PTR (char *) 0 /* generally useful expression */
#define HAVE_SCATTERED_IO 1 /* scattered I/O is now standard */ #define HAVE_SCATTERED_IO 1 /* scattered I/O is now standard */
/* Macros. */ /* Macros. */

View file

@ -51,7 +51,6 @@ struct device {
u64_t dv_size; u64_t dv_size;
}; };
#define NIL_DEV ((struct device *) 0)
#define DRIVER_STD 0 /* Use the standard reply protocol */ #define DRIVER_STD 0 /* Use the standard reply protocol */
#define DRIVER_ASYN 1 /* Use the new asynchronous protocol */ #define DRIVER_ASYN 1 /* Use the new asynchronous protocol */

View file

@ -121,7 +121,7 @@ PUBLIC void exception_handler(int is_nested, struct exception_frame * frame)
{ "Stack exception", SIGSEGV, 286 }, /* STACK_FAULT already used */ { "Stack exception", SIGSEGV, 286 }, /* STACK_FAULT already used */
{ "General protection", SIGSEGV, 286 }, { "General protection", SIGSEGV, 286 },
{ "Page fault", SIGSEGV, 386 }, /* not close */ { "Page fault", SIGSEGV, 386 }, /* not close */
{ NIL_PTR, SIGILL, 0 }, /* probably software trap */ { NULL, SIGILL, 0 }, /* probably software trap */
{ "Coprocessor error", SIGFPE, 386 }, { "Coprocessor error", SIGFPE, 386 },
{ "Alignment check", SIGBUS, 386 }, { "Alignment check", SIGBUS, 386 },
{ "Machine check", SIGBUS, 386 }, { "Machine check", SIGBUS, 386 },
@ -198,7 +198,7 @@ PUBLIC void exception_handler(int is_nested, struct exception_frame * frame)
} }
/* Exception in system code. This is not supposed to happen. */ /* Exception in system code. This is not supposed to happen. */
if (ep->msg == NIL_PTR || machine.processor < ep->minprocessor) if (ep->msg == NULL || machine.processor < ep->minprocessor)
printf("\nIntel-reserved exception %d\n", frame->vector); printf("\nIntel-reserved exception %d\n", frame->vector);
else else
printf("\n%s\n", ep->msg); printf("\n%s\n", ep->msg);

View file

@ -67,7 +67,7 @@ PUBLIC void cstart(
/* XT, AT or MCA bus? */ /* XT, AT or MCA bus? */
value = get_value(params_buffer, "bus"); value = get_value(params_buffer, "bus");
if (value == NIL_PTR || strcmp(value, "at") == 0) { if (value == NULL || strcmp(value, "at") == 0) {
machine.pc_at = TRUE; /* PC-AT compatible hardware */ machine.pc_at = TRUE; /* PC-AT compatible hardware */
} else if (strcmp(value, "mca") == 0) { } else if (strcmp(value, "mca") == 0) {
machine.pc_at = machine.ps_mca = TRUE; /* PS/2 with micro channel */ machine.pc_at = machine.ps_mca = TRUE; /* PS/2 with micro channel */
@ -132,5 +132,5 @@ PRIVATE char *get_value(
while (*envp++ != 0) while (*envp++ != 0)
; ;
} }
return(NIL_PTR); return(NULL);
} }

View file

@ -20,7 +20,7 @@ int cmd;
* covers F_GETFD, F_GETFL and invalid commands. * covers F_GETFD, F_GETFL and invalid commands.
*/ */
m.m1_i3 = 0; m.m1_i3 = 0;
m.m1_p1 = NIL_PTR; m.m1_p1 = NULL;
/* Adjust for the stupid cases. */ /* Adjust for the stupid cases. */
switch(cmd) { switch(cmd) {

View file

@ -455,7 +455,7 @@ message *mp; /* pointer to read or write message */
if (mp->COUNT < 0) return(EINVAL); if (mp->COUNT < 0) return(EINVAL);
/* Prepare for I/O. */ /* Prepare for I/O. */
if ((*dp->dr_prepare)(mp->DEVICE) == NIL_DEV) return(ENXIO); if ((*dp->dr_prepare)(mp->DEVICE) == NULL) return(ENXIO);
/* Create a one element scatter/gather vector for the buffer. */ /* Create a one element scatter/gather vector for the buffer. */
if(mp->m_type == DEV_READ_S) opcode = DEV_GATHER_S; if(mp->m_type == DEV_READ_S) opcode = DEV_GATHER_S;
@ -501,7 +501,7 @@ message *mp; /* pointer to read or write message */
} }
/* Prepare for I/O. */ /* Prepare for I/O. */
if ((*dp->dr_prepare)(mp->DEVICE) == NIL_DEV) return(ENXIO); if ((*dp->dr_prepare)(mp->DEVICE) == NULL) return(ENXIO);
/* Transfer bytes from/to the device. */ /* Transfer bytes from/to the device. */
opcode = mp->m_type; opcode = mp->m_type;
@ -576,7 +576,7 @@ message *mp;
PUBLIC struct device *nop_prepare(int device) PUBLIC struct device *nop_prepare(int device)
{ {
/* Nothing to prepare for. */ /* Nothing to prepare for. */
return(NIL_DEV); return(NULL);
} }
/*===========================================================================* /*===========================================================================*
@ -624,7 +624,7 @@ message *mp; /* pointer to ioctl request */
} }
/* Decode the message parameters. */ /* Decode the message parameters. */
if ((dv = (*dp->dr_prepare)(mp->DEVICE)) == NIL_DEV) return(ENXIO); if ((dv = (*dp->dr_prepare)(mp->DEVICE)) == NULL) return(ENXIO);
if (mp->REQUEST == DIOCSETP) { if (mp->REQUEST == DIOCSETP) {
/* Copy just this one partition table entry. */ /* Copy just this one partition table entry. */

View file

@ -43,7 +43,7 @@ int atapi; /* atapi device */
unsigned long base, limit, part_limit; unsigned long base, limit, part_limit;
/* Get the geometry of the device to partition */ /* Get the geometry of the device to partition */
if ((dv = (*dp->dr_prepare)(device)) == NIL_DEV if ((dv = (*dp->dr_prepare)(device)) == NULL
|| cmp64u(dv->dv_size, 0) == 0) return; || cmp64u(dv->dv_size, 0) == 0) return;
base = div64u(dv->dv_base, SECTOR_SIZE); base = div64u(dv->dv_base, SECTOR_SIZE);
limit = base + div64u(dv->dv_size, SECTOR_SIZE); limit = base + div64u(dv->dv_size, SECTOR_SIZE);
@ -69,7 +69,7 @@ int atapi; /* atapi device */
} }
/* Find an array of devices. */ /* Find an array of devices. */
if ((dv = (*dp->dr_prepare)(device)) == NIL_DEV) return; if ((dv = (*dp->dr_prepare)(device)) == NULL) return;
/* Set the geometry of the partitions from the partition table. */ /* Set the geometry of the partitions from the partition table. */
for (par = 0; par < NR_PARTITIONS; par++, dv++) { for (par = 0; par < NR_PARTITIONS; par++, dv++) {
@ -131,7 +131,7 @@ unsigned long extbase; /* sector offset of the base extended partition */
nextoffset = pe->lowsec; nextoffset = pe->lowsec;
} else } else
if (pe->sysind != NO_PART) { if (pe->sysind != NO_PART) {
if ((dv = (*dp->dr_prepare)(subdev)) == NIL_DEV) return; if ((dv = (*dp->dr_prepare)(subdev)) == NULL) return;
dv->dv_base = mul64u(extbase + offset + pe->lowsec, dv->dv_base = mul64u(extbase + offset + pe->lowsec,
SECTOR_SIZE); SECTOR_SIZE);
@ -163,7 +163,7 @@ struct part_entry *table; /* four entries */
position = mul64u(offset, SECTOR_SIZE); position = mul64u(offset, SECTOR_SIZE);
iovec1.iov_addr = (vir_bytes) partbuf; iovec1.iov_addr = (vir_bytes) partbuf;
iovec1.iov_size = CD_SECTOR_SIZE; iovec1.iov_size = CD_SECTOR_SIZE;
if ((*dp->dr_prepare)(device) != NIL_DEV) { if ((*dp->dr_prepare)(device) != NULL) {
(void) (*dp->dr_transfer)(SELF, DEV_GATHER_S, position, &iovec1, 1); (void) (*dp->dr_transfer)(SELF, DEV_GATHER_S, position, &iovec1, 1);
} }
if (iovec1.iov_size != 0) { if (iovec1.iov_size != 0) {

View file

@ -40,7 +40,7 @@ char *name;
{ {
/* Given a directory inode and a component name, look up the inode associated /* Given a directory inode and a component name, look up the inode associated
* with that directory entry. Return the inode (with increased reference * with that directory entry. Return the inode (with increased reference
* count) if found, or NIL_INODE otherwise. * count) if found, or NULL otherwise.
*/ */
struct inode *ino; struct inode *ino;
unsigned int slot; unsigned int slot;
@ -54,8 +54,8 @@ char *name;
break; break;
} }
if (ino == NIL_INODE) if (ino == NULL)
return NIL_INODE; return NULL;
get_inode(ino); get_inode(ino);
@ -111,7 +111,7 @@ struct inode *ino;
* Do not touch open handles. Do not add to the free list. * Do not touch open handles. Do not add to the free list.
*/ */
assert(ino->i_parent != NIL_INODE); assert(ino->i_parent != NULL);
/* hash_del(ino); */ /* hash_del(ino); */
LIST_REMOVE(ino, i_hash); LIST_REMOVE(ino, i_hash);

View file

@ -40,7 +40,7 @@ PUBLIC struct inode *init_inode()
/* Mark all inodes except the root inode as free. */ /* Mark all inodes except the root inode as free. */
for (index = 1; index < NUM_INODES; index++) { for (index = 1; index < NUM_INODES; index++) {
ino = &inodes[index]; ino = &inodes[index];
ino->i_parent = NIL_INODE; ino->i_parent = NULL;
LIST_INIT(&ino->i_child); LIST_INIT(&ino->i_child);
ino->i_num = index + 1; ino->i_num = index + 1;
ino->i_gen = (unsigned short)-1; /* aesthetics */ ino->i_gen = (unsigned short)-1; /* aesthetics */
@ -78,7 +78,7 @@ ino_t ino_nr;
if (index < 0) { if (index < 0) {
printf("HGFS: VFS passed invalid inode number!\n"); printf("HGFS: VFS passed invalid inode number!\n");
return NIL_INODE; return NULL;
} }
assert(index < NUM_INODES); assert(index < NUM_INODES);
@ -89,7 +89,7 @@ ino_t ino_nr;
if (INODE_GEN(ino_nr) != ino->i_gen) { if (INODE_GEN(ino_nr) != ino->i_gen) {
printf("HGFS: VFS passed outdated inode number!\n"); printf("HGFS: VFS passed outdated inode number!\n");
return NIL_INODE; return NULL;
} }
/* The VFS/FS protocol only uses referenced inodes. */ /* The VFS/FS protocol only uses referenced inodes. */
@ -136,7 +136,7 @@ struct inode *ino;
dprintf(("HGFS: put_inode(%p) ['%s']\n", ino, ino->i_name)); dprintf(("HGFS: put_inode(%p) ['%s']\n", ino, ino->i_name));
assert(ino != NIL_INODE); assert(ino != NULL);
assert(ino->i_ref > 0); assert(ino->i_ref > 0);
ino->i_ref--; ino->i_ref--;
@ -157,7 +157,7 @@ struct inode *ino;
/* Add the inode to the head or tail of the free list, depending on whether /* Add the inode to the head or tail of the free list, depending on whether
* it is also deleted (and therefore can never be reused as is). * it is also deleted (and therefore can never be reused as is).
*/ */
if (ino->i_parent == NIL_INODE) if (ino->i_parent == NULL)
TAILQ_INSERT_HEAD(&free_list, ino, i_free); TAILQ_INSERT_HEAD(&free_list, ino, i_free);
else else
TAILQ_INSERT_TAIL(&free_list, ino, i_free); TAILQ_INSERT_TAIL(&free_list, ino, i_free);
@ -201,13 +201,13 @@ struct inode *ino;
LIST_REMOVE(ino, i_next); LIST_REMOVE(ino, i_next);
if (parent->i_ref == 0 && !HAS_CHILDREN(parent)) { if (parent->i_ref == 0 && !HAS_CHILDREN(parent)) {
if (parent->i_parent == NIL_INODE) if (parent->i_parent == NULL)
TAILQ_INSERT_HEAD(&free_list, parent, i_free); TAILQ_INSERT_HEAD(&free_list, parent, i_free);
else else
TAILQ_INSERT_TAIL(&free_list, parent, i_free); TAILQ_INSERT_TAIL(&free_list, parent, i_free);
} }
ino->i_parent = NIL_INODE; ino->i_parent = NULL;
} }
/*===========================================================================* /*===========================================================================*
@ -225,7 +225,7 @@ PUBLIC struct inode *get_free_inode()
if (TAILQ_EMPTY(&free_list)) { if (TAILQ_EMPTY(&free_list)) {
printf("HGFS: out of inodes!\n"); printf("HGFS: out of inodes!\n");
return NIL_INODE; return NULL;
} }
ino = TAILQ_FIRST(&free_list); ino = TAILQ_FIRST(&free_list);
@ -235,10 +235,10 @@ PUBLIC struct inode *get_free_inode()
assert(!HAS_CHILDREN(ino)); assert(!HAS_CHILDREN(ino));
/* If this was a cached inode, free it first. */ /* If this was a cached inode, free it first. */
if (ino->i_parent != NIL_INODE) if (ino->i_parent != NULL)
del_dentry(ino); del_dentry(ino);
assert(ino->i_parent == NIL_INODE); assert(ino->i_parent == NULL);
/* Initialize a subset of its fields */ /* Initialize a subset of its fields */
ino->i_gen++; ino->i_gen++;
@ -286,7 +286,7 @@ PUBLIC int do_putnode()
struct inode *ino; struct inode *ino;
int count; int count;
if ((ino = find_inode(m_in.REQ_INODE_NR)) == NIL_INODE) if ((ino = find_inode(m_in.REQ_INODE_NR)) == NULL)
return EINVAL; return EINVAL;
count = m_in.REQ_COUNT; count = m_in.REQ_COUNT;

View file

@ -72,7 +72,6 @@ struct inode {
#define i_file i_u.u_file #define i_file i_u.u_file
#define i_dir i_u.u_dir #define i_dir i_u.u_dir
#define NIL_INODE ((struct inode *)NULL)
#define I_DIR 0x01 /* this inode represents a directory */ #define I_DIR 0x01 /* this inode represents a directory */
#define I_HANDLE 0x02 /* this inode has an open handle */ #define I_HANDLE 0x02 /* this inode has an open handle */

View file

@ -40,7 +40,7 @@ PUBLIC int do_create()
if (!strcmp(name, ".") || !strcmp(name, "..")) return EEXIST; if (!strcmp(name, ".") || !strcmp(name, "..")) return EEXIST;
if ((parent = find_inode(m_in.REQ_INODE_NR)) == NIL_INODE) if ((parent = find_inode(m_in.REQ_INODE_NR)) == NULL)
return EINVAL; return EINVAL;
if ((r = verify_dentry(parent, name, path, &ino)) != OK) if ((r = verify_dentry(parent, name, path, &ino)) != OK)
@ -49,9 +49,9 @@ PUBLIC int do_create()
/* Are we going to need a new inode upon success? /* Are we going to need a new inode upon success?
* Then make sure there is one available before trying anything. * Then make sure there is one available before trying anything.
*/ */
if (ino == NIL_INODE || ino->i_ref > 1 || HAS_CHILDREN(ino)) { if (ino == NULL || ino->i_ref > 1 || HAS_CHILDREN(ino)) {
if (!have_free_inode()) { if (!have_free_inode()) {
if (ino != NIL_INODE) if (ino != NULL)
put_inode(ino); put_inode(ino);
return ENFILE; return ENFILE;
@ -66,7 +66,7 @@ PUBLIC int do_create()
* is wrong with the directory, we'll find out later anyway. * is wrong with the directory, we'll find out later anyway.
*/ */
if (ino != NIL_INODE) if (ino != NULL)
put_inode(ino); put_inode(ino);
return r; return r;
@ -85,7 +85,7 @@ PUBLIC int do_create()
hgfs_close(handle); hgfs_close(handle);
if (ino != NIL_INODE) { if (ino != NULL) {
del_dentry(ino); del_dentry(ino);
put_inode(ino); put_inode(ino);
@ -97,7 +97,7 @@ PUBLIC int do_create()
/* We do assume that the HGFS open(O_CREAT|O_EXCL) did its job. /* We do assume that the HGFS open(O_CREAT|O_EXCL) did its job.
* If we previousy found an inode, get rid of it now. It's old. * If we previousy found an inode, get rid of it now. It's old.
*/ */
if (ino != NIL_INODE) { if (ino != NULL) {
del_dentry(ino); del_dentry(ino);
put_inode(ino); put_inode(ino);
@ -107,7 +107,7 @@ PUBLIC int do_create()
*/ */
ino = get_free_inode(); ino = get_free_inode();
assert(ino != NIL_INODE); /* we checked before whether we had a free one */ assert(ino != NULL); /* we checked before whether we had a free one */
ino->i_file = handle; ino->i_file = handle;
ino->i_flags = I_HANDLE; ino->i_flags = I_HANDLE;
@ -146,7 +146,7 @@ PUBLIC int do_mkdir()
if (!strcmp(name, ".") || !strcmp(name, "..")) return EEXIST; if (!strcmp(name, ".") || !strcmp(name, "..")) return EEXIST;
if ((parent = find_inode(m_in.REQ_INODE_NR)) == NIL_INODE) if ((parent = find_inode(m_in.REQ_INODE_NR)) == NULL)
return EINVAL; return EINVAL;
if ((r = verify_dentry(parent, name, path, &ino)) != OK) if ((r = verify_dentry(parent, name, path, &ino)) != OK)
@ -156,7 +156,7 @@ PUBLIC int do_mkdir()
r = hgfs_mkdir(path, m_in.REQ_MODE); r = hgfs_mkdir(path, m_in.REQ_MODE);
if (r != OK) { if (r != OK) {
if (ino != NIL_INODE) if (ino != NULL)
put_inode(ino); put_inode(ino);
return r; return r;
@ -165,7 +165,7 @@ PUBLIC int do_mkdir()
/* If we thought the new dentry already existed, it was apparently gone /* If we thought the new dentry already existed, it was apparently gone
* already. Delete it. * already. Delete it.
*/ */
if (ino != NIL_INODE) { if (ino != NULL) {
del_dentry(ino); del_dentry(ino);
put_inode(ino); put_inode(ino);
@ -250,7 +250,7 @@ PUBLIC int do_unlink()
if (!strcmp(name, ".") || !strcmp(name, "..")) return EPERM; if (!strcmp(name, ".") || !strcmp(name, "..")) return EPERM;
if ((parent = find_inode(m_in.REQ_INODE_NR)) == NIL_INODE) if ((parent = find_inode(m_in.REQ_INODE_NR)) == NULL)
return EINVAL; return EINVAL;
if ((r = verify_dentry(parent, name, path, &ino)) != OK) if ((r = verify_dentry(parent, name, path, &ino)) != OK)
@ -260,14 +260,14 @@ PUBLIC int do_unlink()
r = force_remove(path, FALSE /*dir*/); r = force_remove(path, FALSE /*dir*/);
if (r != OK) { if (r != OK) {
if (ino != NIL_INODE) if (ino != NULL)
put_inode(ino); put_inode(ino);
return r; return r;
} }
/* If a dentry existed for this name, it is gone now. */ /* If a dentry existed for this name, it is gone now. */
if (ino != NIL_INODE) { if (ino != NULL) {
del_dentry(ino); del_dentry(ino);
put_inode(ino); put_inode(ino);
@ -298,7 +298,7 @@ PUBLIC int do_rmdir()
if (!strcmp(name, ".")) return EINVAL; if (!strcmp(name, ".")) return EINVAL;
if (!strcmp(name, "..")) return ENOTEMPTY; if (!strcmp(name, "..")) return ENOTEMPTY;
if ((parent = find_inode(m_in.REQ_INODE_NR)) == NIL_INODE) if ((parent = find_inode(m_in.REQ_INODE_NR)) == NULL)
return EINVAL; return EINVAL;
if ((r = verify_dentry(parent, name, path, &ino)) != OK) if ((r = verify_dentry(parent, name, path, &ino)) != OK)
@ -308,14 +308,14 @@ PUBLIC int do_rmdir()
r = force_remove(path, TRUE /*dir*/); r = force_remove(path, TRUE /*dir*/);
if (r != OK) { if (r != OK) {
if (ino != NIL_INODE) if (ino != NULL)
put_inode(ino); put_inode(ino);
return r; return r;
} }
/* If a dentry existed for this name, it is gone now. */ /* If a dentry existed for this name, it is gone now. */
if (ino != NIL_INODE) { if (ino != NULL) {
del_dentry(ino); del_dentry(ino);
put_inode(ino); put_inode(ino);
@ -353,15 +353,15 @@ PUBLIC int do_rename()
if (!strcmp(old_name, ".") || !strcmp(old_name, "..") || if (!strcmp(old_name, ".") || !strcmp(old_name, "..") ||
!strcmp(new_name, ".") || !strcmp(new_name, "..")) return EINVAL; !strcmp(new_name, ".") || !strcmp(new_name, "..")) return EINVAL;
if ((old_parent = find_inode(m_in.REQ_REN_OLD_DIR)) == NIL_INODE || if ((old_parent = find_inode(m_in.REQ_REN_OLD_DIR)) == NULL ||
(new_parent = find_inode(m_in.REQ_REN_NEW_DIR)) == NIL_INODE) (new_parent = find_inode(m_in.REQ_REN_NEW_DIR)) == NULL)
return EINVAL; return EINVAL;
if ((r = verify_dentry(old_parent, old_name, old_path, &old_ino)) != OK) if ((r = verify_dentry(old_parent, old_name, old_path, &old_ino)) != OK)
return r; return r;
if ((r = verify_dentry(new_parent, new_name, new_path, &new_ino)) != OK) { if ((r = verify_dentry(new_parent, new_name, new_path, &new_ino)) != OK) {
if (old_ino != NIL_INODE) if (old_ino != NULL)
put_inode(old_ino); put_inode(old_ino);
return r; return r;
@ -374,9 +374,9 @@ PUBLIC int do_rename()
* NULL, or they both refer to the same file. * NULL, or they both refer to the same file.
*/ */
if (r != OK || old_ino == new_ino) { if (r != OK || old_ino == new_ino) {
if (old_ino != NIL_INODE) put_inode(old_ino); if (old_ino != NULL) put_inode(old_ino);
if (new_ino != NIL_INODE) put_inode(new_ino); if (new_ino != NULL) put_inode(new_ino);
return r; return r;
} }
@ -384,14 +384,14 @@ PUBLIC int do_rename()
/* If the new dentry already existed, it has now been overwritten. /* If the new dentry already existed, it has now been overwritten.
* Delete the associated inode if we had found one. * Delete the associated inode if we had found one.
*/ */
if (new_ino != NIL_INODE) { if (new_ino != NULL) {
del_dentry(new_ino); del_dentry(new_ino);
put_inode(new_ino); put_inode(new_ino);
} }
/* If the old dentry existed, rename it accordingly. */ /* If the old dentry existed, rename it accordingly. */
if (old_ino != NIL_INODE) { if (old_ino != NULL) {
del_dentry(old_ino); del_dentry(old_ino);
add_dentry(new_parent, new_name, old_ino); add_dentry(new_parent, new_name, old_ino);

View file

@ -118,7 +118,7 @@ struct hgfs_attr *attr; /* place to store inode attributes */
pop_path(path); pop_path(path);
parent = ino->i_parent; parent = ino->i_parent;
assert(parent != NIL_INODE); assert(parent != NULL);
if ((r = verify_path(path, parent, attr, NULL)) != OK) if ((r = verify_path(path, parent, attr, NULL)) != OK)
return r; return r;
@ -154,7 +154,7 @@ struct hgfs_attr *attr; /* place to store inode attributes */
dprintf(("HGFS: lookup_dentry('%s') returned %p\n", name, ino)); dprintf(("HGFS: lookup_dentry('%s') returned %p\n", name, ino));
if (ino != NIL_INODE) if (ino != NULL)
r = verify_path(path, ino, attr, &stale); r = verify_path(path, ino, attr, &stale);
else else
r = hgfs_getattr(path, attr); r = hgfs_getattr(path, attr);
@ -162,10 +162,10 @@ struct hgfs_attr *attr; /* place to store inode attributes */
dprintf(("HGFS: path query returned %d\n", r)); dprintf(("HGFS: path query returned %d\n", r));
if (r != OK) { if (r != OK) {
if (ino != NIL_INODE) { if (ino != NULL) {
put_inode(ino); put_inode(ino);
ino = NIL_INODE; ino = NULL;
} }
if (!stale) if (!stale)
@ -174,8 +174,8 @@ struct hgfs_attr *attr; /* place to store inode attributes */
dprintf(("HGFS: name '%s'\n", name)); dprintf(("HGFS: name '%s'\n", name));
if (ino == NIL_INODE) { if (ino == NULL) {
if ((ino = get_free_inode()) == NIL_INODE) if ((ino = get_free_inode()) == NULL)
return ENFILE; return ENFILE;
dprintf(("HGFS: inode %p ref %d\n", ino, ino->i_ref)); dprintf(("HGFS: inode %p ref %d\n", ino, ino->i_ref));
@ -198,7 +198,7 @@ PUBLIC int do_lookup()
*/ */
ino_t dir_ino_nr, root_ino_nr; ino_t dir_ino_nr, root_ino_nr;
struct inode *cur_ino, *root_ino; struct inode *cur_ino, *root_ino;
struct inode *next_ino = NIL_INODE; struct inode *next_ino = NULL;
struct hgfs_attr attr; struct hgfs_attr attr;
char buf[PATH_MAX], path[PATH_MAX]; char buf[PATH_MAX], path[PATH_MAX];
char name[NAME_MAX+1]; char name[NAME_MAX+1];
@ -255,7 +255,7 @@ PUBLIC int do_lookup()
/* Start the actual lookup. */ /* Start the actual lookup. */
dprintf(("HGFS: lookup: got query '%s'\n", buf)); dprintf(("HGFS: lookup: got query '%s'\n", buf));
if ((cur_ino = find_inode(dir_ino_nr)) == NIL_INODE) if ((cur_ino = find_inode(dir_ino_nr)) == NULL)
return EINVAL; return EINVAL;
attr.a_mask = HGFS_ATTR_MODE | HGFS_ATTR_SIZE; attr.a_mask = HGFS_ATTR_MODE | HGFS_ATTR_SIZE;
@ -268,7 +268,7 @@ PUBLIC int do_lookup()
if (root_ino_nr > 0) if (root_ino_nr > 0)
root_ino = find_inode(root_ino_nr); root_ino = find_inode(root_ino_nr);
else else
root_ino = NIL_INODE; root_ino = NULL;
/* One possible optimization would be to check a path only right before the /* One possible optimization would be to check a path only right before the
* first ".." in a row, and at the very end (if still necessary). This would * first ".." in a row, and at the very end (if still necessary). This would
@ -299,7 +299,7 @@ PUBLIC int do_lookup()
if (r != OK) if (r != OK)
break; break;
assert(next_ino != NIL_INODE); assert(next_ino != NULL);
put_inode(cur_ino); put_inode(cur_ino);

View file

@ -79,7 +79,7 @@ PUBLIC int do_unmount()
dprintf(("HGFS: do_unmount\n")); dprintf(("HGFS: do_unmount\n"));
/* Decrease the reference count of the root inode. */ /* Decrease the reference count of the root inode. */
if ((ino = find_inode(ROOT_INODE_NR)) == NIL_INODE) if ((ino = find_inode(ROOT_INODE_NR)) == NULL)
return EINVAL; return EINVAL;
put_inode(ino); put_inode(ino);

View file

@ -33,7 +33,7 @@ struct inode *ino;
plen = strlen(prefix); plen = strlen(prefix);
/* Construct the path right-to-left in a temporary buffer first. */ /* Construct the path right-to-left in a temporary buffer first. */
for (total = plen; ino != NIL_INODE && !IS_ROOT(ino); ino = ino->i_parent) { for (total = plen; ino != NULL && !IS_ROOT(ino); ino = ino->i_parent) {
len = strlen(ino->i_name); len = strlen(ino->i_name);
total += len + 1; total += len + 1;
@ -49,7 +49,7 @@ struct inode *ino;
/* If any of the intermediate inodes has no parent, the final inode is no /* If any of the intermediate inodes has no parent, the final inode is no
* longer addressable by name. * longer addressable by name.
*/ */
if (ino == NIL_INODE) if (ino == NULL)
return ENOENT; return ENOENT;
/* Put the result in the actual buffer. We need the leading slash in the /* Put the result in the actual buffer. We need the leading slash in the

View file

@ -28,7 +28,7 @@ PUBLIC int do_read()
char *ptr; char *ptr;
int r, chunk; int r, chunk;
if ((ino = find_inode(m_in.REQ_INODE_NR)) == NIL_INODE) if ((ino = find_inode(m_in.REQ_INODE_NR)) == NULL)
return EINVAL; return EINVAL;
if (IS_DIR(ino)) return EISDIR; if (IS_DIR(ino)) return EISDIR;
@ -93,7 +93,7 @@ PUBLIC int do_getdents()
attr.a_mask = HGFS_ATTR_MODE; attr.a_mask = HGFS_ATTR_MODE;
if ((ino = find_inode(m_in.REQ_INODE_NR)) == NIL_INODE) if ((ino = find_inode(m_in.REQ_INODE_NR)) == NULL)
return EINVAL; return EINVAL;
if (m_in.REQ_SEEK_POS_HI != 0) return EINVAL; if (m_in.REQ_SEEK_POS_HI != 0) return EINVAL;
@ -130,7 +130,7 @@ PUBLIC int do_getdents()
} }
else if (pos == 1) { else if (pos == 1) {
/* Entry for "..", but only when there is a parent. */ /* Entry for "..", but only when there is a parent. */
if (ino->i_parent == NIL_INODE) if (ino->i_parent == NULL)
continue; continue;
child = ino->i_parent; child = ino->i_parent;
@ -164,11 +164,11 @@ PUBLIC int do_getdents()
if (!strcmp(name, ".") || !strcmp(name, "..")) if (!strcmp(name, ".") || !strcmp(name, ".."))
continue; continue;
if ((child = lookup_dentry(ino, name)) == NIL_INODE) { if ((child = lookup_dentry(ino, name)) == NULL) {
child = get_free_inode(); child = get_free_inode();
/* We were promised a free inode! */ /* We were promised a free inode! */
assert(child != NIL_INODE); assert(child != NULL);
child->i_flags = MODE_TO_DIRFLAG(attr.a_mode); child->i_flags = MODE_TO_DIRFLAG(attr.a_mode);

View file

@ -53,7 +53,7 @@ PUBLIC int do_stat()
ino_nr = m_in.REQ_INODE_NR; ino_nr = m_in.REQ_INODE_NR;
/* Don't increase the inode refcount: it's already open anyway */ /* Don't increase the inode refcount: it's already open anyway */
if ((ino = find_inode(ino_nr)) == NIL_INODE) if ((ino = find_inode(ino_nr)) == NULL)
return EINVAL; return EINVAL;
attr.a_mask = HGFS_ATTR_MODE | HGFS_ATTR_SIZE | HGFS_ATTR_ATIME | attr.a_mask = HGFS_ATTR_MODE | HGFS_ATTR_SIZE | HGFS_ATTR_ATIME |
@ -78,7 +78,7 @@ PUBLIC int do_stat()
* It's just not worth it. * It's just not worth it.
*/ */
stat.st_nlink = 0; stat.st_nlink = 0;
if (ino->i_parent != NIL_INODE) stat.st_nlink++; if (ino->i_parent != NULL) stat.st_nlink++;
if (IS_DIR(ino)) { if (IS_DIR(ino)) {
stat.st_nlink++; stat.st_nlink++;
if (HAS_CHILDREN(ino)) stat.st_nlink++; if (HAS_CHILDREN(ino)) stat.st_nlink++;
@ -103,7 +103,7 @@ PUBLIC int do_chmod()
if (state.read_only) if (state.read_only)
return EROFS; return EROFS;
if ((ino = find_inode(m_in.REQ_INODE_NR)) == NIL_INODE) if ((ino = find_inode(m_in.REQ_INODE_NR)) == NULL)
return EINVAL; return EINVAL;
if ((r = verify_inode(ino, path, NULL)) != OK) if ((r = verify_inode(ino, path, NULL)) != OK)
@ -140,7 +140,7 @@ PUBLIC int do_utime()
if (state.read_only) if (state.read_only)
return EROFS; return EROFS;
if ((ino = find_inode(m_in.REQ_INODE_NR)) == NIL_INODE) if ((ino = find_inode(m_in.REQ_INODE_NR)) == NULL)
return EINVAL; return EINVAL;
if ((r = verify_inode(ino, path, NULL)) != OK) if ((r = verify_inode(ino, path, NULL)) != OK)

View file

@ -97,7 +97,7 @@ struct inode **res_ino; /* pointer for addressed inode (or NULL) */
* directory entry, check whether the path to the parent is still valid, and * directory entry, check whether the path to the parent is still valid, and
* check whether there is an inode pointed to by the full path. Upon success, * check whether there is an inode pointed to by the full path. Upon success,
* res_ino will contain either the inode for the full path, with increased * res_ino will contain either the inode for the full path, with increased
* refcount, or NIL_INODE if no such inode exists. * refcount, or NULL if no such inode exists.
*/ */
int r; int r;

View file

@ -92,7 +92,7 @@ PUBLIC int do_write()
if (state.read_only) if (state.read_only)
return EROFS; return EROFS;
if ((ino = find_inode(m_in.REQ_INODE_NR)) == NIL_INODE) if ((ino = find_inode(m_in.REQ_INODE_NR)) == NULL)
return EINVAL; return EINVAL;
if (IS_DIR(ino)) return EISDIR; if (IS_DIR(ino)) return EISDIR;
@ -130,7 +130,7 @@ PUBLIC int do_ftrunc()
if (state.read_only) if (state.read_only)
return EROFS; return EROFS;
if ((ino = find_inode(m_in.REQ_INODE_NR)) == NIL_INODE) if ((ino = find_inode(m_in.REQ_INODE_NR)) == NULL)
return EINVAL; return EINVAL;
if (IS_DIR(ino)) return EISDIR; if (IS_DIR(ino)) return EISDIR;

View file

@ -13,7 +13,6 @@ PUBLIC struct buf {
/* A block is free if b_dev == NO_DEV. */ /* A block is free if b_dev == NO_DEV. */
#define NIL_BUF ((struct buf *) 0) /* indicates absence of a buffer */
/* These defs make it possible to use to bp->b_data instead of bp->b.b__data */ /* These defs make it possible to use to bp->b_data instead of bp->b.b__data */
#define b_data b.b__data #define b_data b.b__data

View file

@ -30,7 +30,7 @@ register block_t block; /* which block is wanted? */
{ {
register struct buf *bp, *free_bp; register struct buf *bp, *free_bp;
free_bp = NIL_BUF; free_bp = NULL;
/* Find if the block is already loaded */ /* Find if the block is already loaded */
for (bp = &buf[0]; bp < &buf[NR_BUFS]; bp++) for (bp = &buf[0]; bp < &buf[NR_BUFS]; bp++)
@ -49,15 +49,15 @@ register block_t block; /* which block is wanted? */
bp_to_pickup = buf; bp_to_pickup = buf;
} }
if (free_bp == NIL_BUF && if (free_bp == NULL &&
bp_to_pickup == buf && bp_to_pickup == buf &&
bp_to_pickup->b_count == 0) bp_to_pickup->b_count == 0)
free_bp = bp_to_pickup; free_bp = bp_to_pickup;
if (free_bp != NIL_BUF) { if (free_bp != NULL) {
/* Set fields of data structure */ /* Set fields of data structure */
free_bp->b_blocknr = block; free_bp->b_blocknr = block;
if (read_block(free_bp) != OK) return NIL_BUF; if (read_block(free_bp) != OK) return NULL;
free_bp->b_count = 1; free_bp->b_count = 1;
if (bp_to_pickup < &buf[NR_BUFS] - 1) if (bp_to_pickup < &buf[NR_BUFS] - 1)
@ -67,8 +67,8 @@ register block_t block; /* which block is wanted? */
return free_bp; return free_bp;
} else { } else {
/* No free blocks. Return NIL_BUF */ /* No free blocks. Return NULL */
return NIL_BUF; return NULL;
} }
} }
@ -78,7 +78,7 @@ register block_t block; /* which block is wanted? */
PUBLIC void put_block(bp) PUBLIC void put_block(bp)
register struct buf *bp; /* pointer to the buffer to be released */ register struct buf *bp; /* pointer to the buffer to be released */
{ {
if (bp == NIL_BUF) return; /* it is easier to check here than in caller */ if (bp == NULL) return; /* it is easier to check here than in caller */
bp->b_count--; /* there is one use fewer now */ bp->b_count--; /* there is one use fewer now */
} }

View file

@ -236,7 +236,7 @@ u32_t address;
offset = address % block_size; /* Offset starting from the block */ offset = address % block_size; /* Offset starting from the block */
bp = get_block(block_nr); /* Read the block from the device */ bp = get_block(block_nr); /* Read the block from the device */
if (bp == NIL_BUF) if (bp == NULL)
return(NULL); return(NULL);
dir = get_free_dir_record(); /* Get a free record */ dir = get_free_dir_record(); /* Get a free record */

View file

@ -117,7 +117,7 @@ PUBLIC int search_dir(ldir_ptr,string,numb)
pos = ldir_ptr->ext_attr_rec_length; pos = ldir_ptr->ext_attr_rec_length;
bp = get_block(ldir_ptr->loc_extent_l); bp = get_block(ldir_ptr->loc_extent_l);
if (bp == NIL_BUF) if (bp == NULL)
return EINVAL; return EINVAL;
while (pos < v_pri.logical_block_size_l) { while (pos < v_pri.logical_block_size_l) {

View file

@ -169,7 +169,7 @@ PUBLIC int fs_getdents(void) {
while (cur_pos<dir->d_file_size) { while (cur_pos<dir->d_file_size) {
bp = get_block(block); /* Get physical block */ bp = get_block(block); /* Get physical block */
if (bp == NIL_BUF) { if (bp == NULL) {
release_dir_record(dir); release_dir_record(dir);
return(EINVAL); return(EINVAL);
} }
@ -318,7 +318,7 @@ int *completed; /* number of bytes copied */
bp = get_block(b); bp = get_block(b);
/* In all cases, bp now points to a valid buffer. */ /* In all cases, bp now points to a valid buffer. */
if (bp == NIL_BUF) { if (bp == NULL) {
panic("bp not valid in rw_chunk; this can't happen"); panic("bp not valid in rw_chunk; this can't happen");
} }

View file

@ -32,7 +32,6 @@ union fsdata_u {
/* A block is free if b_dev == NO_DEV. */ /* A block is free if b_dev == NO_DEV. */
#define NIL_BUF ((struct buf *) 0) /* indicates absence of a buffer */
/* These defs make it possible to use to bp->b_data instead of bp->b.b__data */ /* These defs make it possible to use to bp->b_data instead of bp->b.b__data */
#define b_data bp->b__data #define b_data bp->b__data

View file

@ -88,7 +88,7 @@ PUBLIC struct buf *get_block(
if (dev != NO_DEV) { if (dev != NO_DEV) {
b = BUFHASH(block); b = BUFHASH(block);
bp = buf_hash[b]; bp = buf_hash[b];
while (bp != NIL_BUF) { while (bp != NULL) {
if (bp->b_blocknr == block && bp->b_dev == dev) { if (bp->b_blocknr == block && bp->b_dev == dev) {
/* Block needed has been found. */ /* Block needed has been found. */
if (bp->b_count == 0) rm_lru(bp); if (bp->b_count == 0) rm_lru(bp);
@ -106,7 +106,7 @@ PUBLIC struct buf *get_block(
} }
/* Desired block is not on available chain. Take oldest block ('front'). */ /* Desired block is not on available chain. Take oldest block ('front'). */
if ((bp = front) == NIL_BUF) panic("all buffers in use: %d", nr_bufs); if ((bp = front) == NULL) panic("all buffers in use: %d", nr_bufs);
if(bp->b_bytes < fs_block_size) { if(bp->b_bytes < fs_block_size) {
ASSERT(!bp->bp); ASSERT(!bp->bp);
@ -138,7 +138,7 @@ PUBLIC struct buf *get_block(
buf_hash[b] = bp->b_hash; buf_hash[b] = bp->b_hash;
} else { } else {
/* The block just taken is not on the front of its hash chain. */ /* The block just taken is not on the front of its hash chain. */
while (prev_ptr->b_hash != NIL_BUF) while (prev_ptr->b_hash != NULL)
if (prev_ptr->b_hash == bp) { if (prev_ptr->b_hash == bp) {
prev_ptr->b_hash = bp->b_hash; /* found it */ prev_ptr->b_hash = bp->b_hash; /* found it */
break; break;
@ -230,7 +230,7 @@ int block_type; /* INODE_BLOCK, DIRECTORY_BLOCK, or whatever */
* the integrity of the file system (e.g., inode blocks) are written to * the integrity of the file system (e.g., inode blocks) are written to
* disk immediately if they are dirty. * disk immediately if they are dirty.
*/ */
if (bp == NIL_BUF) return; /* it is easier to check here than in caller */ if (bp == NULL) return; /* it is easier to check here than in caller */
bp->b_count--; /* there is one use fewer now */ bp->b_count--; /* there is one use fewer now */
if (bp->b_count != 0) return; /* block is still in use */ if (bp->b_count != 0) return; /* block is still in use */
@ -246,9 +246,9 @@ int block_type; /* INODE_BLOCK, DIRECTORY_BLOCK, or whatever */
/* Block probably won't be needed quickly. Put it on front of chain. /* Block probably won't be needed quickly. Put it on front of chain.
* It will be the next block to be evicted from the cache. * It will be the next block to be evicted from the cache.
*/ */
bp->b_prev = NIL_BUF; bp->b_prev = NULL;
bp->b_next = front; bp->b_next = front;
if (front == NIL_BUF) if (front == NULL)
rear = bp; /* LRU chain was empty */ rear = bp; /* LRU chain was empty */
else else
front->b_prev = bp; front->b_prev = bp;
@ -259,8 +259,8 @@ int block_type; /* INODE_BLOCK, DIRECTORY_BLOCK, or whatever */
* It will not be evicted from the cache for a long time. * It will not be evicted from the cache for a long time.
*/ */
bp->b_prev = rear; bp->b_prev = rear;
bp->b_next = NIL_BUF; bp->b_next = NULL;
if (rear == NIL_BUF) if (rear == NULL)
front = bp; front = bp;
else else
rear->b_next = bp; rear->b_next = bp;
@ -532,12 +532,12 @@ struct buf *bp;
bufs_in_use++; bufs_in_use++;
next_ptr = bp->b_next; /* successor on LRU chain */ next_ptr = bp->b_next; /* successor on LRU chain */
prev_ptr = bp->b_prev; /* predecessor on LRU chain */ prev_ptr = bp->b_prev; /* predecessor on LRU chain */
if (prev_ptr != NIL_BUF) if (prev_ptr != NULL)
prev_ptr->b_next = next_ptr; prev_ptr->b_next = next_ptr;
else else
front = next_ptr; /* this block was at front of chain */ front = next_ptr; /* this block was at front of chain */
if (next_ptr != NIL_BUF) if (next_ptr != NULL)
next_ptr->b_prev = prev_ptr; next_ptr->b_prev = prev_ptr;
else else
rear = prev_ptr; /* this block was at rear of chain */ rear = prev_ptr; /* this block was at rear of chain */
@ -611,8 +611,8 @@ PUBLIC void buf_pool(int new_nr_bufs)
bp->bp = NULL; bp->bp = NULL;
bp->b_bytes = 0; bp->b_bytes = 0;
} }
buf[0].b_prev = NIL_BUF; buf[0].b_prev = NULL;
buf[nr_bufs - 1].b_next = NIL_BUF; buf[nr_bufs - 1].b_next = NULL;
for (bp = &buf[0]; bp < &buf[nr_bufs]; bp++) bp->b_hash = bp->b_next; for (bp = &buf[0]; bp < &buf[nr_bufs]; bp++) bp->b_hash = bp->b_next;
buf_hash[0] = front; buf_hash[0] = front;

View file

@ -152,7 +152,7 @@ PUBLIC struct inode *get_inode(
/* Inode is not on the hash, get a free one */ /* Inode is not on the hash, get a free one */
if (TAILQ_EMPTY(&unused_inodes)) { if (TAILQ_EMPTY(&unused_inodes)) {
err_code = ENFILE; err_code = ENFILE;
return(NIL_INODE); return(NULL);
} }
rip = TAILQ_FIRST(&unused_inodes); rip = TAILQ_FIRST(&unused_inodes);
@ -201,7 +201,7 @@ PUBLIC struct inode *find_inode(
} }
} }
return(NIL_INODE); return(NULL);
} }
@ -216,7 +216,7 @@ register struct inode *rip; /* pointer to inode to be released */
* return it to the pool of available inodes. * return it to the pool of available inodes.
*/ */
if (rip == NIL_INODE) return; /* checking here is easier than in caller */ if (rip == NULL) return; /* checking here is easier than in caller */
if (rip->i_count < 1) if (rip->i_count < 1)
panic("put_inode: i_count already below 1: %d", rip->i_count); panic("put_inode: i_count already below 1: %d", rip->i_count);
@ -261,7 +261,7 @@ PUBLIC struct inode *alloc_inode(dev_t dev, mode_t bits)
sp = get_super(dev); /* get pointer to super_block */ sp = get_super(dev); /* get pointer to super_block */
if (sp->s_rd_only) { /* can't allocate an inode on a read only device. */ if (sp->s_rd_only) { /* can't allocate an inode on a read only device. */
err_code = EROFS; err_code = EROFS;
return(NIL_INODE); return(NULL);
} }
/* Acquire an inode from the bit map. */ /* Acquire an inode from the bit map. */
@ -271,13 +271,13 @@ PUBLIC struct inode *alloc_inode(dev_t dev, mode_t bits)
major = (int) (sp->s_dev >> MAJOR) & BYTE; major = (int) (sp->s_dev >> MAJOR) & BYTE;
minor = (int) (sp->s_dev >> MINOR) & BYTE; minor = (int) (sp->s_dev >> MINOR) & BYTE;
printf("Out of i-nodes on device %d/%d\n", major, minor); printf("Out of i-nodes on device %d/%d\n", major, minor);
return(NIL_INODE); return(NULL);
} }
sp->s_isearch = b; /* next time start here */ sp->s_isearch = b; /* next time start here */
inumb = (int) b; /* be careful not to pass unshort as param */ inumb = (int) b; /* be careful not to pass unshort as param */
/* Try to acquire a slot in the inode table. */ /* Try to acquire a slot in the inode table. */
if ((rip = get_inode(NO_DEV, inumb)) == NIL_INODE) { if ((rip = get_inode(NO_DEV, inumb)) == NULL) {
/* No inode table slots available. Free the inode just allocated. */ /* No inode table slots available. Free the inode just allocated. */
free_bit(sp, IMAP, b); free_bit(sp, IMAP, b);
} else { } else {

View file

@ -53,7 +53,6 @@ EXTERN LIST_HEAD(inodelist, inode) hash_inodes[INODE_HASH_SIZE];
EXTERN unsigned int inode_cache_hit; EXTERN unsigned int inode_cache_hit;
EXTERN unsigned int inode_cache_miss; EXTERN unsigned int inode_cache_miss;
#define NIL_INODE (struct inode *) 0 /* indicates absence of inode slot */
/* Field values. Note that CLEAN and DIRTY are defined in "const.h" */ /* Field values. Note that CLEAN and DIRTY are defined in "const.h" */
#define NO_SEEK 0 /* i_seek = NO_SEEK if last op was not SEEK */ #define NO_SEEK 0 /* i_seek = NO_SEEK if last op was not SEEK */

View file

@ -46,7 +46,7 @@ PUBLIC int fs_link()
MFS_NUL(string, len, sizeof(string)); MFS_NUL(string, len, sizeof(string));
/* Temporarily open the file. */ /* Temporarily open the file. */
if( (rip = get_inode(fs_dev, fs_m_in.REQ_INODE_NR)) == NIL_INODE) if( (rip = get_inode(fs_dev, fs_m_in.REQ_INODE_NR)) == NULL)
return(EINVAL); return(EINVAL);
/* Check to see if the file has maximum number of links already. */ /* Check to see if the file has maximum number of links already. */
@ -66,12 +66,12 @@ PUBLIC int fs_link()
} }
/* Temporarily open the last dir */ /* Temporarily open the last dir */
if( (ip = get_inode(fs_dev, fs_m_in.REQ_DIR_INO)) == NIL_INODE) if( (ip = get_inode(fs_dev, fs_m_in.REQ_DIR_INO)) == NULL)
return(EINVAL); return(EINVAL);
/* If 'name2' exists in full (even if no space) set 'r' to error. */ /* If 'name2' exists in full (even if no space) set 'r' to error. */
if (r == OK) { if (r == OK) {
if((new_ip = advance(ip, string, IGN_PERM)) == NIL_INODE) { if((new_ip = advance(ip, string, IGN_PERM)) == NULL) {
r = err_code; r = err_code;
if(r == ENOENT) if(r == ENOENT)
r = OK; r = OK;
@ -122,7 +122,7 @@ PUBLIC int fs_unlink()
MFS_NUL(string, len, sizeof(string)); MFS_NUL(string, len, sizeof(string));
/* Temporarily open the dir. */ /* Temporarily open the dir. */
if( (rldirp = get_inode(fs_dev, fs_m_in.REQ_INODE_NR)) == NIL_INODE) if( (rldirp = get_inode(fs_dev, fs_m_in.REQ_INODE_NR)) == NULL)
return(EINVAL); return(EINVAL);
/* The last directory exists. Does the file also exist? */ /* The last directory exists. Does the file also exist? */
@ -175,7 +175,7 @@ PUBLIC int fs_rdlink()
if (copylen <= 0) return(EINVAL); if (copylen <= 0) return(EINVAL);
/* Temporarily open the file. */ /* Temporarily open the file. */
if( (rip = get_inode(fs_dev, fs_m_in.REQ_INODE_NR)) == NIL_INODE) if( (rip = get_inode(fs_dev, fs_m_in.REQ_INODE_NR)) == NULL)
return(EINVAL); return(EINVAL);
if(!S_ISLNK(rip->i_mode)) if(!S_ISLNK(rip->i_mode))
@ -229,8 +229,8 @@ char dir_name[NAME_MAX]; /* name of directory to be removed */
/* Unlink . and .. from the dir. The super user can link and unlink any dir, /* Unlink . and .. from the dir. The super user can link and unlink any dir,
* so don't make too many assumptions about them. * so don't make too many assumptions about them.
*/ */
(void) unlink_file(rip, NIL_INODE, dot1); (void) unlink_file(rip, NULL, dot1);
(void) unlink_file(rip, NIL_INODE, dot2); (void) unlink_file(rip, NULL, dot2);
return(OK); return(OK);
} }
@ -240,20 +240,20 @@ char dir_name[NAME_MAX]; /* name of directory to be removed */
*===========================================================================*/ *===========================================================================*/
PRIVATE int unlink_file(dirp, rip, file_name) PRIVATE int unlink_file(dirp, rip, file_name)
struct inode *dirp; /* parent directory of file */ struct inode *dirp; /* parent directory of file */
struct inode *rip; /* inode of file, may be NIL_INODE too. */ struct inode *rip; /* inode of file, may be NULL too. */
char file_name[NAME_MAX]; /* name of file to be removed */ char file_name[NAME_MAX]; /* name of file to be removed */
{ {
/* Unlink 'file_name'; rip must be the inode of 'file_name' or NIL_INODE. */ /* Unlink 'file_name'; rip must be the inode of 'file_name' or NULL. */
ino_t numb; /* inode number */ ino_t numb; /* inode number */
int r; int r;
/* If rip is not NIL_INODE, it is used to get faster access to the inode. */ /* If rip is not NULL, it is used to get faster access to the inode. */
if (rip == NIL_INODE) { if (rip == NULL) {
/* Search for file in directory and try to get its inode. */ /* Search for file in directory and try to get its inode. */
err_code = search_dir(dirp, file_name, &numb, LOOK_UP, IGN_PERM); err_code = search_dir(dirp, file_name, &numb, LOOK_UP, IGN_PERM);
if (err_code == OK) rip = get_inode(dirp->i_dev, (int) numb); if (err_code == OK) rip = get_inode(dirp->i_dev, (int) numb);
if (err_code != OK || rip == NIL_INODE) return(err_code); if (err_code != OK || rip == NULL) return(err_code);
} else { } else {
dup_inode(rip); /* inode will be returned with put_inode */ dup_inode(rip); /* inode will be returned with put_inode */
} }
@ -302,7 +302,7 @@ PUBLIC int fs_rename()
MFS_NUL(new_name, len, sizeof(new_name)); MFS_NUL(new_name, len, sizeof(new_name));
/* Get old dir inode */ /* Get old dir inode */
if( (old_dirp = get_inode(fs_dev, fs_m_in.REQ_REN_OLD_DIR)) == NIL_INODE) if( (old_dirp = get_inode(fs_dev, fs_m_in.REQ_REN_OLD_DIR)) == NULL)
return(err_code); return(err_code);
old_ip = advance(old_dirp, old_name, IGN_PERM); old_ip = advance(old_dirp, old_name, IGN_PERM);
@ -315,7 +315,7 @@ PUBLIC int fs_rename()
} }
/* Get new dir inode */ /* Get new dir inode */
if( (new_dirp = get_inode(fs_dev, fs_m_in.REQ_REN_NEW_DIR)) == NIL_INODE) if( (new_dirp = get_inode(fs_dev, fs_m_in.REQ_REN_NEW_DIR)) == NULL)
r = err_code; r = err_code;
new_ip = advance(new_dirp, new_name, IGN_PERM); /* not required to exist */ new_ip = advance(new_dirp, new_name, IGN_PERM); /* not required to exist */
@ -326,7 +326,7 @@ PUBLIC int fs_rename()
r = EBUSY; r = EBUSY;
} }
if(old_ip != NIL_INODE) if(old_ip != NULL)
odir = ((old_ip->i_mode & I_TYPE) == I_DIRECTORY); /* TRUE iff dir */ odir = ((old_ip->i_mode & I_TYPE) == I_DIRECTORY); /* TRUE iff dir */
else else
odir = FALSE; /* FIXME: is this a safe default? */ odir = FALSE; /* FIXME: is this a safe default? */
@ -360,7 +360,7 @@ PUBLIC int fs_rename()
break; break;
} }
new_superdirp = next_new_superdirp; new_superdirp = next_new_superdirp;
if(new_superdirp == NIL_INODE) { if(new_superdirp == NULL) {
/* Missing ".." entry. Assume the worst. */ /* Missing ".." entry. Assume the worst. */
r = EINVAL; r = EINVAL;
break; break;
@ -377,7 +377,7 @@ PUBLIC int fs_rename()
if(old_dirp->i_dev != new_dirp->i_dev) r = EXDEV; */ if(old_dirp->i_dev != new_dirp->i_dev) r = EXDEV; */
/* Some tests apply only if the new path exists. */ /* Some tests apply only if the new path exists. */
if(new_ip == NIL_INODE) { if(new_ip == NULL) {
/* don't rename a file with a file system mounted on it. /* don't rename a file with a file system mounted on it.
if (old_ip->i_dev != old_dirp->i_dev) r = EXDEV;*/ if (old_ip->i_dev != old_dirp->i_dev) r = EXDEV;*/
if(odir && new_dirp->i_nlinks >= if(odir && new_dirp->i_nlinks >=
@ -407,7 +407,7 @@ PUBLIC int fs_rename()
* is completely full]. * is completely full].
*/ */
if(r == OK) { if(r == OK) {
if(new_ip != NIL_INODE) { if(new_ip != NULL) {
/* There is already an entry for 'new'. Try to remove it. */ /* There is already an entry for 'new'. Try to remove it. */
if(odir) if(odir)
r = remove_dir(new_dirp, new_ip, new_name); r = remove_dir(new_dirp, new_ip, new_name);
@ -444,7 +444,7 @@ PUBLIC int fs_rename()
if(r == OK && odir && !same_pdir) { if(r == OK && odir && !same_pdir) {
/* Update the .. entry in the directory (still points to old_dirp).*/ /* Update the .. entry in the directory (still points to old_dirp).*/
numb = new_dirp->i_num; numb = new_dirp->i_num;
(void) unlink_file(old_ip, NIL_INODE, dot2); (void) unlink_file(old_ip, NULL, dot2);
if(search_dir(old_ip, dot2, &numb, ENTER, IGN_PERM) == OK) { if(search_dir(old_ip, dot2, &numb, ENTER, IGN_PERM) == OK) {
/* New link created. */ /* New link created. */
new_dirp->i_nlinks++; new_dirp->i_nlinks++;
@ -470,7 +470,7 @@ PUBLIC int fs_ftrunc(void)
off_t start, end; off_t start, end;
int r; int r;
if( (rip = find_inode(fs_dev, fs_m_in.REQ_INODE_NR)) == NIL_INODE) if( (rip = find_inode(fs_dev, fs_m_in.REQ_INODE_NR)) == NULL)
return(EINVAL); return(EINVAL);
start = fs_m_in.REQ_TRC_START_LO; start = fs_m_in.REQ_TRC_START_LO;
@ -655,7 +655,7 @@ off_t len;
if(!len) return; /* no zeroing to be done. */ if(!len) return; /* no zeroing to be done. */
if( (b = read_map(rip, pos)) == NO_BLOCK) return; if( (b = read_map(rip, pos)) == NO_BLOCK) return;
while (len > 0) { while (len > 0) {
if( (bp = get_block(rip->i_dev, b, NORMAL)) == NIL_BUF) if( (bp = get_block(rip->i_dev, b, NORMAL)) == NULL)
panic("zerozone_range: no block"); panic("zerozone_range: no block");
offset = pos % block_size; offset = pos % block_size;
bytes = block_size - offset; bytes = block_size - offset;

View file

@ -63,7 +63,7 @@ PUBLIC int main(int argc, char *argv[])
fs_m_out.m_type = error; fs_m_out.m_type = error;
reply(src, &fs_m_out); reply(src, &fs_m_out);
if (error == OK && rdahed_inode != NIL_INODE) if (error == OK && rdahed_inode != NULL)
read_ahead(); /* do block read ahead */ read_ahead(); /* do block read ahead */
} }

View file

@ -82,14 +82,14 @@ PUBLIC int fs_readsuper()
set_blocksize(superblock.s_block_size); set_blocksize(superblock.s_block_size);
/* Get the root inode of the mounted file system. */ /* Get the root inode of the mounted file system. */
if( (root_ip = get_inode(fs_dev, ROOT_INODE)) == NIL_INODE) { if( (root_ip = get_inode(fs_dev, ROOT_INODE)) == NULL) {
printf("MFS: couldn't get root inode\n"); printf("MFS: couldn't get root inode\n");
superblock.s_dev = NO_DEV; superblock.s_dev = NO_DEV;
dev_close(driver_e, fs_dev); dev_close(driver_e, fs_dev);
return(EINVAL); return(EINVAL);
} }
if(root_ip != NIL_INODE && root_ip->i_mode == 0) { if(root_ip != NULL && root_ip->i_mode == 0) {
printf("%s:%d zero mode for root inode?\n", __FILE__, __LINE__); printf("%s:%d zero mode for root inode?\n", __FILE__, __LINE__);
put_inode(root_ip); put_inode(root_ip);
superblock.s_dev = NO_DEV; superblock.s_dev = NO_DEV;
@ -124,7 +124,7 @@ PUBLIC int fs_mountpoint()
mode_t bits; mode_t bits;
/* Temporarily open the file. */ /* Temporarily open the file. */
if( (rip = get_inode(fs_dev, fs_m_in.REQ_INODE_NR)) == NIL_INODE) if( (rip = get_inode(fs_dev, fs_m_in.REQ_INODE_NR)) == NULL)
return(EINVAL); return(EINVAL);
@ -159,7 +159,7 @@ PUBLIC int fs_unmount()
for (rip = &inode[0]; rip < &inode[NR_INODES]; rip++) for (rip = &inode[0]; rip < &inode[NR_INODES]; rip++)
if (rip->i_count > 0 && rip->i_dev == fs_dev) count += rip->i_count; if (rip->i_count > 0 && rip->i_dev == fs_dev) count += rip->i_count;
if ((root_ip = find_inode(fs_dev, ROOT_INODE)) == NIL_INODE) { if ((root_ip = find_inode(fs_dev, ROOT_INODE)) == NULL) {
printf("MFS: couldn't find root inode. Unmount failed.\n"); printf("MFS: couldn't find root inode. Unmount failed.\n");
panic("MFS: couldn't find root inode: %d", EINVAL); panic("MFS: couldn't find root inode: %d", EINVAL);
return(EINVAL); return(EINVAL);

View file

@ -42,7 +42,7 @@ PUBLIC int fs_create()
MFS_NUL(lastc, len, sizeof(lastc)); MFS_NUL(lastc, len, sizeof(lastc));
/* Get last directory inode (i.e., directory that will hold the new inode) */ /* Get last directory inode (i.e., directory that will hold the new inode) */
if ((ldirp = get_inode(fs_dev, fs_m_in.REQ_INODE_NR)) == NIL_INODE) if ((ldirp = get_inode(fs_dev, fs_m_in.REQ_INODE_NR)) == NULL)
return(ENOENT); return(ENOENT);
/* Create a new inode by calling new_node(). */ /* Create a new inode by calling new_node(). */
@ -93,7 +93,7 @@ PUBLIC int fs_mknod()
caller_gid = fs_m_in.REQ_GID; caller_gid = fs_m_in.REQ_GID;
/* Get last directory inode */ /* Get last directory inode */
if((ldirp = get_inode(fs_dev, fs_m_in.REQ_INODE_NR)) == NIL_INODE) if((ldirp = get_inode(fs_dev, fs_m_in.REQ_INODE_NR)) == NULL)
return(ENOENT); return(ENOENT);
/* Try to create the new node */ /* Try to create the new node */
@ -127,13 +127,13 @@ PUBLIC int fs_mkdir()
caller_gid = fs_m_in.REQ_GID; caller_gid = fs_m_in.REQ_GID;
/* Get last directory inode */ /* Get last directory inode */
if((ldirp = get_inode(fs_dev, fs_m_in.REQ_INODE_NR)) == NIL_INODE) if((ldirp = get_inode(fs_dev, fs_m_in.REQ_INODE_NR)) == NULL)
return(ENOENT); return(ENOENT);
/* Next make the inode. If that fails, return error code. */ /* Next make the inode. If that fails, return error code. */
rip = new_node(ldirp, lastc, fs_m_in.REQ_MODE, (zone_t) 0); rip = new_node(ldirp, lastc, fs_m_in.REQ_MODE, (zone_t) 0);
if(rip == NIL_INODE || err_code == EEXIST) { if(rip == NULL || err_code == EEXIST) {
put_inode(rip); /* can't make dir: it already exists */ put_inode(rip); /* can't make dir: it already exists */
put_inode(ldirp); put_inode(ldirp);
return(err_code); return(err_code);
@ -194,7 +194,7 @@ PUBLIC int fs_slink()
MFS_NUL(string, len, sizeof(string)); MFS_NUL(string, len, sizeof(string));
/* Temporarily open the dir. */ /* Temporarily open the dir. */
if( (ldirp = get_inode(fs_dev, fs_m_in.REQ_INODE_NR)) == NIL_INODE) if( (ldirp = get_inode(fs_dev, fs_m_in.REQ_INODE_NR)) == NULL)
return(EINVAL); return(EINVAL);
/* Create the inode for the symlink. */ /* Create the inode for the symlink. */
@ -204,7 +204,7 @@ PUBLIC int fs_slink()
/* Allocate a disk block for the contents of the symlink. /* Allocate a disk block for the contents of the symlink.
* Copy contents of symlink (the name pointed to) into first disk block. */ * Copy contents of symlink (the name pointed to) into first disk block. */
if( (r = err_code) == OK) { if( (r = err_code) == OK) {
r = (bp = new_block(sip, (off_t) 0)) == NIL_BUF ? err_code : r = (bp = new_block(sip, (off_t) 0)) == NULL ? err_code :
sys_safecopyfrom(FS_PROC_NR, fs_m_in.REQ_GRANT3, 0, sys_safecopyfrom(FS_PROC_NR, fs_m_in.REQ_GRANT3, 0,
(vir_bytes) bp->b_data, (vir_bytes) bp->b_data,
(vir_bytes) fs_m_in.REQ_MEM_SIZE, D); (vir_bytes) fs_m_in.REQ_MEM_SIZE, D);
@ -225,7 +225,7 @@ PUBLIC int fs_slink()
} }
} }
put_block(bp, DIRECTORY_BLOCK); /* put_block() accepts NIL_BUF. */ put_block(bp, DIRECTORY_BLOCK); /* put_block() accepts NULL. */
if(r != OK) { if(r != OK) {
sip->i_nlinks = 0; sip->i_nlinks = 0;
@ -236,7 +236,7 @@ PUBLIC int fs_slink()
} }
} }
/* put_inode() accepts NIL_INODE as a noop, so the below are safe. */ /* put_inode() accepts NULL as a noop, so the below are safe. */
put_inode(sip); put_inode(sip);
put_inode(ldirp); put_inode(ldirp);
@ -253,7 +253,7 @@ PRIVATE struct inode *new_node(struct inode *ldirp,
* In all cases it allocates a new inode, makes a directory entry for it in * In all cases it allocates a new inode, makes a directory entry for it in
* the ldirp directory with string name, and initializes it. * the ldirp directory with string name, and initializes it.
* It returns a pointer to the inode if it can do this; * It returns a pointer to the inode if it can do this;
* otherwise it returns NIL_INODE. It always sets 'err_code' * otherwise it returns NULL. It always sets 'err_code'
* to an appropriate value (OK or an error code). * to an appropriate value (OK or an error code).
* *
* The parsed path rest is returned in 'parsed' if parsed is nonzero. It * The parsed path rest is returned in 'parsed' if parsed is nonzero. It
@ -272,14 +272,14 @@ PRIVATE struct inode *new_node(struct inode *ldirp,
/* New entry is a directory, alas we can't give it a ".." */ /* New entry is a directory, alas we can't give it a ".." */
put_inode(rip); put_inode(rip);
err_code = EMLINK; err_code = EMLINK;
return(NIL_INODE); return(NULL);
} }
if ( rip == NIL_INODE && err_code == ENOENT) { if ( rip == NULL && err_code == ENOENT) {
/* Last path component does not exist. Make new directory entry. */ /* Last path component does not exist. Make new directory entry. */
if ( (rip = alloc_inode((ldirp)->i_dev, bits)) == NIL_INODE) { if ( (rip = alloc_inode((ldirp)->i_dev, bits)) == NULL) {
/* Can't creat new inode: out of inodes. */ /* Can't creat new inode: out of inodes. */
return(NIL_INODE); return(NULL);
} }
/* Force inode to the disk before making directory entry to make /* Force inode to the disk before making directory entry to make
@ -296,14 +296,14 @@ PRIVATE struct inode *new_node(struct inode *ldirp,
rip->i_dirt = DIRTY; /* dirty inodes are written out */ rip->i_dirt = DIRTY; /* dirty inodes are written out */
put_inode(rip); /* this call frees the inode */ put_inode(rip); /* this call frees the inode */
err_code = r; err_code = r;
return(NIL_INODE); return(NULL);
} }
} else if (err_code == EENTERMOUNT || err_code == ELEAVEMOUNT) { } else if (err_code == EENTERMOUNT || err_code == ELEAVEMOUNT) {
r = EEXIST; r = EEXIST;
} else { } else {
/* Either last component exists, or there is some problem. */ /* Either last component exists, or there is some problem. */
if (rip != NIL_INODE) if (rip != NULL)
r = EEXIST; r = EEXIST;
else else
r = err_code; r = err_code;
@ -322,7 +322,7 @@ PUBLIC int fs_inhibread()
{ {
struct inode *rip; struct inode *rip;
if((rip = find_inode(fs_dev, fs_m_in.REQ_INODE_NR)) == NIL_INODE) if((rip = find_inode(fs_dev, fs_m_in.REQ_INODE_NR)) == NULL)
return(EINVAL); return(EINVAL);
/* inhibit read ahead */ /* inhibit read ahead */

View file

@ -163,7 +163,7 @@ int *symlinkp;
*symlinkp = 0; *symlinkp = 0;
/* Find starting inode inode according to the request message */ /* Find starting inode inode according to the request message */
if((rip = find_inode(fs_dev, dir_ino)) == NIL_INODE) if((rip = find_inode(fs_dev, dir_ino)) == NULL)
return(ENOENT); return(ENOENT);
/* If dir has been removed return ENOENT. */ /* If dir has been removed return ENOENT. */
@ -310,7 +310,7 @@ char *suffix; /* current remaining path. Has to point in the
struct buf *bp; /* buffer containing link text */ struct buf *bp; /* buffer containing link text */
char *sp; /* start of link text */ char *sp; /* start of link text */
bp = NIL_BUF; bp = NULL;
if ((blink = read_map(rip, (off_t) 0)) == NO_BLOCK) if ((blink = read_map(rip, (off_t) 0)) == NO_BLOCK)
return(EIO); return(EIO);
@ -379,20 +379,20 @@ int chk_perm; /* check permissions when string is looked up*/
/* If 'string' is empty, return an error. */ /* If 'string' is empty, return an error. */
if (string[0] == '\0') { if (string[0] == '\0') {
err_code = ENOENT; err_code = ENOENT;
return(NIL_INODE); return(NULL);
} }
/* Check for NIL_INODE. */ /* Check for NULL. */
if (dirp == NIL_INODE) return(NIL_INODE); if (dirp == NULL) return(NULL);
/* If 'string' is not present in the directory, signal error. */ /* If 'string' is not present in the directory, signal error. */
if ( (err_code = search_dir(dirp, string, &numb, LOOK_UP, chk_perm)) != OK) { if ( (err_code = search_dir(dirp, string, &numb, LOOK_UP, chk_perm)) != OK) {
return(NIL_INODE); return(NULL);
} }
/* The component has been found in the directory. Get inode. */ /* The component has been found in the directory. Get inode. */
if ( (rip = get_inode(dirp->i_dev, (int) numb)) == NIL_INODE) { if ( (rip = get_inode(dirp->i_dev, (int) numb)) == NULL) {
return(NIL_INODE); return(NULL);
} }
/* The following test is for "mountpoint/.." where mountpoint is a /* The following test is for "mountpoint/.." where mountpoint is a
@ -420,7 +420,7 @@ int chk_perm; /* check permissions when string is looked up*/
* mounted file system. The super_block provides the linkage between the * mounted file system. The super_block provides the linkage between the
* inode mounted on and the root directory of the mounted file system. * inode mounted on and the root directory of the mounted file system.
*/ */
if (rip != NIL_INODE && rip->i_mountpoint) { if (rip != NULL && rip->i_mountpoint) {
/* Mountpoint encountered, report it */ /* Mountpoint encountered, report it */
err_code = EENTERMOUNT; err_code = EENTERMOUNT;
} }
@ -604,7 +604,7 @@ int check_permissions; /* check permissions when flag is !IS_EMPTY */
if (e_hit == FALSE) { /* directory is full and no room left in last block */ if (e_hit == FALSE) { /* directory is full and no room left in last block */
new_slots++; /* increase directory size by 1 entry */ new_slots++; /* increase directory size by 1 entry */
if (new_slots == 0) return(EFBIG); /* dir size limited by slot count */ if (new_slots == 0) return(EFBIG); /* dir size limited by slot count */
if ( (bp = new_block(ldir_ptr, ldir_ptr->i_size)) == NIL_BUF) if ( (bp = new_block(ldir_ptr, ldir_ptr->i_size)) == NULL)
return(err_code); return(err_code);
dp = &bp->b_dir[0]; dp = &bp->b_dir[0];
extended = 1; extended = 1;

View file

@ -19,7 +19,7 @@ PUBLIC int fs_chmod()
register struct inode *rip; register struct inode *rip;
/* Temporarily open the file. */ /* Temporarily open the file. */
if( (rip = get_inode(fs_dev, fs_m_in.REQ_INODE_NR)) == NIL_INODE) if( (rip = get_inode(fs_dev, fs_m_in.REQ_INODE_NR)) == NULL)
return(EINVAL); return(EINVAL);
/* Now make the change. Clear setgid bit if file is not in caller's grp */ /* Now make the change. Clear setgid bit if file is not in caller's grp */
@ -44,7 +44,7 @@ PUBLIC int fs_chown()
register int r; register int r;
/* Temporarily open the file. */ /* Temporarily open the file. */
if( (rip = get_inode(fs_dev, fs_m_in.REQ_INODE_NR)) == NIL_INODE) if( (rip = get_inode(fs_dev, fs_m_in.REQ_INODE_NR)) == NULL)
return(EINVAL); return(EINVAL);
/* Not permitted to change the owner of a file on a read-only file sys. */ /* Not permitted to change the owner of a file on a read-only file sys. */

View file

@ -34,7 +34,7 @@ PUBLIC int fs_readwrite(void)
r = OK; r = OK;
/* Find the inode referred */ /* Find the inode referred */
if ((rip = find_inode(fs_dev, fs_m_in.REQ_INODE_NR)) == NIL_INODE) if ((rip = find_inode(fs_dev, fs_m_in.REQ_INODE_NR)) == NULL)
return(EINVAL); return(EINVAL);
mode_word = rip->i_mode & I_TYPE; mode_word = rip->i_mode & I_TYPE;
@ -240,7 +240,7 @@ int *completed; /* number of bytes copied */
zero_block(bp); zero_block(bp);
} else { } else {
/* Writing to a nonexistent block. Create and enter in inode.*/ /* Writing to a nonexistent block. Create and enter in inode.*/
if ((bp= new_block(rip, ex64lo(position))) == NIL_BUF) if ((bp= new_block(rip, ex64lo(position))) == NULL)
return(err_code); return(err_code);
} }
} else if (rw_flag == READING) { } else if (rw_flag == READING) {
@ -258,7 +258,7 @@ int *completed; /* number of bytes copied */
} }
/* In all cases, bp now points to a valid buffer. */ /* In all cases, bp now points to a valid buffer. */
if (bp == NIL_BUF) if (bp == NULL)
panic("bp not valid in rw_chunk; this can't happen"); panic("bp not valid in rw_chunk; this can't happen");
if (rw_flag == WRITING && chunk != block_size && !block_spec && if (rw_flag == WRITING && chunk != block_size && !block_spec &&
@ -366,8 +366,8 @@ int index; /* index into *bp */
struct super_block *sp; struct super_block *sp;
zone_t zone; /* V2 zones are longs (shorts in V1) */ zone_t zone; /* V2 zones are longs (shorts in V1) */
if(bp == NIL_BUF) if(bp == NULL)
panic("rd_indir() on NIL_BUF"); panic("rd_indir() on NULL");
sp = get_super(bp->b_dev); /* need super block to find file sys type */ sp = get_super(bp->b_dev); /* need super block to find file sys type */
@ -401,7 +401,7 @@ PUBLIC void read_ahead()
rip = rdahed_inode; /* pointer to inode to read ahead from */ rip = rdahed_inode; /* pointer to inode to read ahead from */
block_size = get_block_size(rip->i_dev); block_size = get_block_size(rip->i_dev);
rdahed_inode = NIL_INODE; /* turn off read ahead */ rdahed_inode = NULL; /* turn off read ahead */
if ( (b = read_map(rip, rdahedpos)) == NO_BLOCK) return; /* at EOF */ if ( (b = read_map(rip, rdahedpos)) == NO_BLOCK) return; /* at EOF */
bp = rahead(rip, b, cvul64(rdahedpos), block_size); bp = rahead(rip, b, cvul64(rdahedpos), block_size);
put_block(bp, PARTIAL_DATA_BLOCK); put_block(bp, PARTIAL_DATA_BLOCK);
@ -560,7 +560,7 @@ PUBLIC int fs_getdents(void)
if(pos % DIR_ENTRY_SIZE) if(pos % DIR_ENTRY_SIZE)
return(ENOENT); return(ENOENT);
if( (rip = get_inode(fs_dev, ino)) == NIL_INODE) if( (rip = get_inode(fs_dev, ino)) == NULL)
return(EINVAL); return(EINVAL);
block_size = rip->i_sp->s_block_size; block_size = rip->i_sp->s_block_size;

View file

@ -62,7 +62,7 @@ PUBLIC int fs_fstatfs()
struct inode *rip; struct inode *rip;
int r; int r;
if((rip = find_inode(fs_dev, ROOT_INODE)) == NIL_INODE) if((rip = find_inode(fs_dev, ROOT_INODE)) == NULL)
return(EINVAL); return(EINVAL);
st.f_bsize = rip->i_sp->s_block_size; st.f_bsize = rip->i_sp->s_block_size;
@ -83,7 +83,7 @@ PUBLIC int fs_stat()
register int r; /* return value */ register int r; /* return value */
register struct inode *rip; /* target inode */ register struct inode *rip; /* target inode */
if ((rip = get_inode(fs_dev, fs_m_in.REQ_INODE_NR)) == NIL_INODE) if ((rip = get_inode(fs_dev, fs_m_in.REQ_INODE_NR)) == NULL)
return(EINVAL); return(EINVAL);
r = stat_inode(rip, fs_m_in.m_source, fs_m_in.REQ_GRANT); r = stat_inode(rip, fs_m_in.m_source, fs_m_in.REQ_GRANT);

View file

@ -57,6 +57,5 @@ EXTERN struct super_block {
char s_is_root; char s_is_root;
} superblock; } superblock;
#define NIL_SUPER (struct super_block *) 0
#define IMAP 0 /* operating on the inode bit map */ #define IMAP 0 /* operating on the inode bit map */
#define ZMAP 1 /* operating on the zone bit map */ #define ZMAP 1 /* operating on the zone bit map */

View file

@ -14,7 +14,7 @@ PUBLIC int fs_utime()
register int r; register int r;
/* Temporarily open the file. */ /* Temporarily open the file. */
if( (rip = get_inode(fs_dev, fs_m_in.REQ_INODE_NR)) == NIL_INODE) if( (rip = get_inode(fs_dev, fs_m_in.REQ_INODE_NR)) == NULL)
return(EINVAL); return(EINVAL);
/* Only the owner of a file or the super_user can change its time. */ /* Only the owner of a file or the super_user can change its time. */

View file

@ -42,7 +42,7 @@ int op; /* special actions */
zone_t z, z1, z2 = NO_ZONE, old_zone; zone_t z, z1, z2 = NO_ZONE, old_zone;
register block_t b; register block_t b;
long excess, zone; long excess, zone;
struct buf *bp_dindir = NIL_BUF, *bp = NIL_BUF; struct buf *bp_dindir = NULL, *bp = NULL;
rip->i_dirt = DIRTY; /* inode will be changed */ rip->i_dirt = DIRTY; /* inode will be changed */
scale = rip->i_sp->s_log_zone_size; /* for zone-block conversion */ scale = rip->i_sp->s_log_zone_size; /* for zone-block conversion */
@ -119,7 +119,7 @@ int op; /* special actions */
new_ind = TRUE; new_ind = TRUE;
/* If double ind, it is dirty. */ /* If double ind, it is dirty. */
if (bp_dindir != NIL_BUF) bp_dindir->b_dirt = DIRTY; if (bp_dindir != NULL) bp_dindir->b_dirt = DIRTY;
if (z1 == NO_ZONE) { if (z1 == NO_ZONE) {
/* Release dbl indirect blk. */ /* Release dbl indirect blk. */
put_block(bp_dindir, INDIRECT_BLOCK); put_block(bp_dindir, INDIRECT_BLOCK);
@ -195,8 +195,8 @@ zone_t zone; /* zone to write */
struct super_block *sp; struct super_block *sp;
if(bp == NIL_BUF) if(bp == NULL)
panic("wr_indir() on NIL_BUF"); panic("wr_indir() on NULL");
sp = get_super(bp->b_dev); /* need super block to find file sys type */ sp = get_super(bp->b_dev); /* need super block to find file sys type */
@ -306,12 +306,12 @@ off_t position; /* file pointer */
/* searched before, start from last find */ /* searched before, start from last find */
z = rip->i_zsearch; z = rip->i_zsearch;
} }
if ( (z = alloc_zone(rip->i_dev, z)) == NO_ZONE) return(NIL_BUF); if ( (z = alloc_zone(rip->i_dev, z)) == NO_ZONE) return(NULL);
rip->i_zsearch = z; /* store for next lookup */ rip->i_zsearch = z; /* store for next lookup */
if ( (r = write_map(rip, position, z, 0)) != OK) { if ( (r = write_map(rip, position, z, 0)) != OK) {
free_zone(rip->i_dev, z); free_zone(rip->i_dev, z);
err_code = r; err_code = r;
return(NIL_BUF); return(NULL);
} }
/* If we are not writing at EOF, clear the zone, just to be safe. */ /* If we are not writing at EOF, clear the zone, just to be safe. */

View file

@ -16,7 +16,6 @@ struct buf {
/* A block is free if b_dev == NO_DEV. */ /* A block is free if b_dev == NO_DEV. */
#define NIL_BUF ((struct buf *) 0) /* indicates absence of a buffer */
#define BUFHASH(b) ((b) % NR_BUFS) #define BUFHASH(b) ((b) % NR_BUFS)

View file

@ -14,8 +14,8 @@ PUBLIC void buf_pool(void)
{ {
/* Initialize the buffer pool. */ /* Initialize the buffer pool. */
front = NIL_BUF; front = NULL;
rear = NIL_BUF; rear = NULL;
} }
@ -27,7 +27,7 @@ PUBLIC struct buf *get_block(dev_t dev, ino_t inum)
{ {
struct buf *bp = front; struct buf *bp = front;
while(bp != NIL_BUF) { while(bp != NULL) {
if (bp->b_dev == dev && bp->b_num == inum) { if (bp->b_dev == dev && bp->b_num == inum) {
bp->b_count++; bp->b_count++;
return(bp); return(bp);
@ -51,7 +51,7 @@ PUBLIC struct buf *new_block(dev_t dev, ino_t inum)
bp = malloc(sizeof(struct buf)); bp = malloc(sizeof(struct buf));
if (bp == NULL) { if (bp == NULL) {
err_code = ENOSPC; err_code = ENOSPC;
return(NIL_BUF); return(NULL);
} }
bp->b_num = inum; bp->b_num = inum;
bp->b_dev = dev; bp->b_dev = dev;
@ -60,14 +60,14 @@ PUBLIC struct buf *new_block(dev_t dev, ino_t inum)
memset(bp->b_data, 0 , PIPE_BUF); memset(bp->b_data, 0 , PIPE_BUF);
/* Add at the end of the buffer */ /* Add at the end of the buffer */
if (front == NIL_BUF) { /* Empty list? */ if (front == NULL) { /* Empty list? */
front = bp; front = bp;
bp->b_prev = NIL_BUF; bp->b_prev = NULL;
} else { } else {
rear->b_next = bp; rear->b_next = bp;
bp->b_prev = rear; bp->b_prev = rear;
} }
bp->b_next = NIL_BUF; bp->b_next = NULL;
rear = bp; rear = bp;
return(bp); return(bp);
@ -82,18 +82,18 @@ PUBLIC void put_block(dev_t dev, ino_t inum)
struct buf *bp; struct buf *bp;
bp = get_block(dev, inum); bp = get_block(dev, inum);
if (bp == NIL_BUF) return; /* We didn't find the block. Nothing to put. */ if (bp == NULL) return; /* We didn't find the block. Nothing to put. */
bp->b_count--; /* Compensate for above 'get_block'. */ bp->b_count--; /* Compensate for above 'get_block'. */
if (--bp->b_count > 0) return; if (--bp->b_count > 0) return;
/* Cut bp out of the loop */ /* Cut bp out of the loop */
if (bp->b_prev == NIL_BUF) if (bp->b_prev == NULL)
front = bp->b_next; front = bp->b_next;
else else
bp->b_prev->b_next = bp->b_next; bp->b_prev->b_next = bp->b_next;
if (bp->b_next == NIL_BUF) if (bp->b_next == NULL)
rear = bp->b_prev; rear = bp->b_prev;
else else
bp->b_next->b_prev = bp->b_prev; bp->b_next->b_prev = bp->b_prev;

View file

@ -148,7 +148,7 @@ PUBLIC struct inode *get_inode(
/* Inode is not on the hash, get a free one */ /* Inode is not on the hash, get a free one */
if (TAILQ_EMPTY(&unused_inodes)) { if (TAILQ_EMPTY(&unused_inodes)) {
err_code = ENFILE; err_code = ENFILE;
return(NIL_INODE); return(NULL);
} }
rip = TAILQ_FIRST(&unused_inodes); rip = TAILQ_FIRST(&unused_inodes);
@ -192,7 +192,7 @@ int numb; /* inode number (ANSI: may not be unshort) */
} }
} }
return(NIL_INODE); return(NULL);
} }
@ -207,7 +207,7 @@ register struct inode *rip; /* pointer to inode to be released */
* return it to the pool of available inodes. * return it to the pool of available inodes.
*/ */
if (rip == NIL_INODE) return; /* checking here is easier than in caller */ if (rip == NULL) return; /* checking here is easier than in caller */
if (rip->i_count < 1) if (rip->i_count < 1)
panic("put_inode: i_count already below 1: %d", rip->i_count); panic("put_inode: i_count already below 1: %d", rip->i_count);
@ -252,13 +252,13 @@ PUBLIC struct inode *alloc_inode(dev_t dev, mode_t bits)
if (b == NO_BIT) { if (b == NO_BIT) {
err_code = ENOSPC; err_code = ENOSPC;
printf("PipeFS is out of inodes\n"); printf("PipeFS is out of inodes\n");
return(NIL_INODE); return(NULL);
} }
i_num = (ino_t) b; i_num = (ino_t) b;
/* Try to acquire a slot in the inode table. */ /* Try to acquire a slot in the inode table. */
if ((rip = get_inode(dev, i_num)) == NIL_INODE) { if ((rip = get_inode(dev, i_num)) == NULL) {
/* No inode table slots available. Free the inode if just allocated.*/ /* No inode table slots available. Free the inode if just allocated.*/
if (dev == NO_DEV) free_bit(b); if (dev == NO_DEV) free_bit(b);
} else { } else {

View file

@ -32,5 +32,4 @@ EXTERN TAILQ_HEAD(unused_inodes_t, inode) unused_inodes;
/* inode hashtable */ /* inode hashtable */
EXTERN LIST_HEAD(inodelist, inode) hash_inodes[INODE_HASH_SIZE]; EXTERN LIST_HEAD(inodelist, inode) hash_inodes[INODE_HASH_SIZE];
#define NIL_INODE (struct inode *) 0 /* indicates absence of inode slot */

View file

@ -15,7 +15,7 @@ PUBLIC int fs_ftrunc(void)
inumb = fs_m_in.REQ_INODE_NR; inumb = fs_m_in.REQ_INODE_NR;
if( (rip = find_inode(inumb)) == NIL_INODE) return(EINVAL); if( (rip = find_inode(inumb)) == NULL) return(EINVAL);
start = fs_m_in.REQ_TRC_START_LO; start = fs_m_in.REQ_TRC_START_LO;
end = fs_m_in.REQ_TRC_END_LO; end = fs_m_in.REQ_TRC_END_LO;

View file

@ -24,7 +24,7 @@ PUBLIC int fs_newnode()
dev = fs_m_in.REQ_DEV; dev = fs_m_in.REQ_DEV;
/* Try to allocate the inode */ /* Try to allocate the inode */
if( (rip = alloc_inode(dev, bits) ) == NIL_INODE) return(err_code); if( (rip = alloc_inode(dev, bits) ) == NULL) return(err_code);
switch (bits & S_IFMT) { switch (bits & S_IFMT) {
case S_IFBLK: case S_IFBLK:
@ -32,7 +32,7 @@ PUBLIC int fs_newnode()
rip->i_rdev = dev; /* Major/minor dev numbers */ rip->i_rdev = dev; /* Major/minor dev numbers */
break; break;
case S_IFIFO: case S_IFIFO:
if ((get_block(dev, rip->i_num)) == NIL_BUF) if ((get_block(dev, rip->i_num)) == NULL)
r = EIO; r = EIO;
break; break;
default: default:

View file

@ -26,7 +26,7 @@ PUBLIC int fs_readwrite(void)
rw_flag = (fs_m_in.m_type == REQ_READ ? READING : WRITING); rw_flag = (fs_m_in.m_type == REQ_READ ? READING : WRITING);
/* Find the inode referred */ /* Find the inode referred */
if ((rip = find_inode(inumb)) == NIL_INODE) return(EINVAL); if ((rip = find_inode(inumb)) == NULL) return(EINVAL);
mode_word = rip->i_mode & I_TYPE; mode_word = rip->i_mode & I_TYPE;
if (mode_word != I_NAMED_PIPE) return(EIO); if (mode_word != I_NAMED_PIPE) return(EIO);
@ -44,8 +44,8 @@ PUBLIC int fs_readwrite(void)
} }
/* Mark inode in use */ /* Mark inode in use */
if ((get_inode(rip->i_dev, rip->i_num)) == NIL_INODE) return(err_code); if ((get_inode(rip->i_dev, rip->i_num)) == NULL) return(err_code);
if ((bp = get_block(rip->i_dev, rip->i_num)) == NIL_BUF) return(err_code); if ((bp = get_block(rip->i_dev, rip->i_num)) == NULL) return(err_code);
if (rw_flag == READING) { if (rw_flag == READING) {
/* Copy a chunk from the block buffer to user space. */ /* Copy a chunk from the block buffer to user space. */

View file

@ -52,7 +52,7 @@ PUBLIC int fs_stat()
register int r; /* return value */ register int r; /* return value */
register struct inode *rip; /* target inode */ register struct inode *rip; /* target inode */
if( (rip = find_inode(fs_m_in.REQ_INODE_NR)) == NIL_INODE) return(EINVAL); if( (rip = find_inode(fs_m_in.REQ_INODE_NR)) == NULL) return(EINVAL);
get_inode(rip->i_dev, rip->i_num); /* mark inode in use */ get_inode(rip->i_dev, rip->i_num); /* mark inode in use */
r = stat_inode(rip, fs_m_in.m_source, fs_m_in.REQ_GRANT); r = stat_inode(rip, fs_m_in.m_source, fs_m_in.REQ_GRANT);
put_inode(rip); /* release the inode */ put_inode(rip); /* release the inode */

View file

@ -296,7 +296,7 @@ PUBLIC int do_getprocnr()
#endif #endif
if (m_in.pid >= 0) { /* lookup process by pid */ if (m_in.pid >= 0) { /* lookup process by pid */
if ((rmp = find_proc(m_in.pid)) != NIL_MPROC) { if ((rmp = find_proc(m_in.pid)) != NULL) {
mp->mp_reply.PM_ENDPT = rmp->mp_endpoint; mp->mp_reply.PM_ENDPT = rmp->mp_endpoint;
#if 0 #if 0
printf("PM: pid result: %d\n", rmp->mp_endpoint); printf("PM: pid result: %d\n", rmp->mp_endpoint);
@ -422,7 +422,7 @@ PUBLIC int do_getsetpriority()
if (arg_who == 0) if (arg_who == 0)
rmp = mp; rmp = mp;
else else
if ((rmp = find_proc(arg_who)) == NIL_MPROC) if ((rmp = find_proc(arg_who)) == NULL)
return(ESRCH); return(ESRCH);
if (mp->mp_effuid != SUPER_USER && if (mp->mp_effuid != SUPER_USER &&

View file

@ -84,5 +84,4 @@ EXTERN struct mproc {
#define DELAY_CALL 0x20000 /* waiting for call before sending signal */ #define DELAY_CALL 0x20000 /* waiting for call before sending signal */
#define PM_SCHEDULED 0x40000 /* this process is scheduled by PM */ #define PM_SCHEDULED 0x40000 /* this process is scheduled by PM */
#define NIL_MPROC ((struct mproc *) 0)

View file

@ -58,7 +58,7 @@ PUBLIC int do_trace()
return(OK); return(OK);
case T_ATTACH: /* attach to an existing process */ case T_ATTACH: /* attach to an existing process */
if ((child = find_proc(m_in.pid)) == NIL_MPROC) return(ESRCH); if ((child = find_proc(m_in.pid)) == NULL) return(ESRCH);
if (child->mp_flags & EXITING) return(ESRCH); if (child->mp_flags & EXITING) return(ESRCH);
/* For non-root processes, user and group ID must match. */ /* For non-root processes, user and group ID must match. */
@ -98,7 +98,7 @@ PUBLIC int do_trace()
case T_READB_INS: /* special hack for reading text segments */ case T_READB_INS: /* special hack for reading text segments */
if (mp->mp_effuid != SUPER_USER) return(EPERM); if (mp->mp_effuid != SUPER_USER) return(EPERM);
if ((child = find_proc(m_in.pid)) == NIL_MPROC) return(ESRCH); if ((child = find_proc(m_in.pid)) == NULL) return(ESRCH);
if (child->mp_flags & EXITING) return(ESRCH); if (child->mp_flags & EXITING) return(ESRCH);
r = sys_trace(req, child->mp_endpoint, m_in.PMTRACE_ADDR, &m_in.data); r = sys_trace(req, child->mp_endpoint, m_in.PMTRACE_ADDR, &m_in.data);
@ -109,7 +109,7 @@ PUBLIC int do_trace()
case T_WRITEB_INS: /* special hack for patching text segments */ case T_WRITEB_INS: /* special hack for patching text segments */
if (mp->mp_effuid != SUPER_USER) return(EPERM); if (mp->mp_effuid != SUPER_USER) return(EPERM);
if ((child = find_proc(m_in.pid)) == NIL_MPROC) return(ESRCH); if ((child = find_proc(m_in.pid)) == NULL) return(ESRCH);
if (child->mp_flags & EXITING) return(ESRCH); if (child->mp_flags & EXITING) return(ESRCH);
#if 0 #if 0
@ -133,7 +133,7 @@ PUBLIC int do_trace()
/* All the other calls are made by the tracing process to control execution /* All the other calls are made by the tracing process to control execution
* of the child. For all these calls, the child must be stopped. * of the child. For all these calls, the child must be stopped.
*/ */
if ((child = find_proc(m_in.pid)) == NIL_MPROC) return(ESRCH); if ((child = find_proc(m_in.pid)) == NULL) return(ESRCH);
if (child->mp_flags & EXITING) return(ESRCH); if (child->mp_flags & EXITING) return(ESRCH);
if (child->mp_tracer != who_p) return(ESRCH); if (child->mp_tracer != who_p) return(ESRCH);
if (!(child->mp_flags & STOPPED)) return(EBUSY); if (!(child->mp_flags & STOPPED)) return(EBUSY);

View file

@ -99,7 +99,7 @@ pid_t lpid;
if ((rmp->mp_flags & IN_USE) && rmp->mp_pid == lpid) if ((rmp->mp_flags & IN_USE) && rmp->mp_pid == lpid)
return(rmp); return(rmp);
return(NIL_MPROC); return(NULL);
} }
/*===========================================================================* /*===========================================================================*

View file

@ -46,7 +46,6 @@
/* Magic process table addresses. */ /* Magic process table addresses. */
#define BEG_RPROC_ADDR (&rproc[0]) #define BEG_RPROC_ADDR (&rproc[0])
#define END_RPROC_ADDR (&rproc[NR_SYS_PROCS]) #define END_RPROC_ADDR (&rproc[NR_SYS_PROCS])
#define NIL_RPROC ((struct mproc *) 0)
/* Constants for live update. */ /* Constants for live update. */
#define RS_DEFAULT_PREPARE_MAXTIME 2*RS_DELTA_T /* default prepare max time */ #define RS_DEFAULT_PREPARE_MAXTIME 2*RS_DELTA_T /* default prepare max time */

View file

@ -596,7 +596,7 @@ PUBLIC int do_ioctl()
register struct vnode *vp; register struct vnode *vp;
dev_t dev; dev_t dev;
if ((f = get_filp(m_in.ls_fd)) == NIL_FILP) return(err_code); if ((f = get_filp(m_in.ls_fd)) == NULL) return(err_code);
vp = f->filp_vno; /* get vnode pointer */ vp = f->filp_vno; /* get vnode pointer */
if ((vp->v_mode & I_TYPE) != I_CHAR_SPECIAL && if ((vp->v_mode & I_TYPE) != I_CHAR_SPECIAL &&
(vp->v_mode & I_TYPE) != I_BLOCK_SPECIAL) return(ENOTTY); (vp->v_mode & I_TYPE) != I_BLOCK_SPECIAL) return(ENOTTY);
@ -804,11 +804,11 @@ PUBLIC int clone_opcl(
vp = fp->fp_filp[m_in.fd]->filp_vno; vp = fp->fp_filp[m_in.fd]->filp_vno;
put_vnode(vp); put_vnode(vp);
if ((vp = get_free_vnode()) == NIL_VNODE) if ((vp = get_free_vnode()) == NULL)
vp = fp->fp_filp[m_in.fd]->filp_vno; vp = fp->fp_filp[m_in.fd]->filp_vno;
vp->v_fs_e = res.fs_e; vp->v_fs_e = res.fs_e;
vp->v_vmnt = NIL_VMNT; vp->v_vmnt = NULL;
vp->v_dev = NO_DEV; vp->v_dev = NO_DEV;
vp->v_fs_e = res.fs_e; vp->v_fs_e = res.fs_e;
vp->v_inode_nr = res.inode_nr; vp->v_inode_nr = res.inode_nr;

View file

@ -114,7 +114,7 @@ vir_bytes frame_len;
progname[PROC_NAME_LEN-1] = '\0'; progname[PROC_NAME_LEN-1] = '\0';
/* Open executable */ /* Open executable */
if ((vp = eat_path(PATH_NOFLAGS)) == NIL_VNODE) return(err_code); if ((vp = eat_path(PATH_NOFLAGS)) == NULL) return(err_code);
if ((vp->v_mode & I_TYPE) != I_REGULAR) if ((vp->v_mode & I_TYPE) != I_REGULAR)
r = ENOEXEC; r = ENOEXEC;

View file

@ -39,4 +39,3 @@ EXTERN struct filp {
* keep state. * keep state.
*/ */
#define NIL_FILP (struct filp *) 0 /* indicates absence of a filp slot */

View file

@ -31,7 +31,7 @@ PUBLIC int get_fd(int start, mode_t bits, int *k, struct filp **fpt)
/* Search the fproc fp_filp table for a free file descriptor. */ /* Search the fproc fp_filp table for a free file descriptor. */
for (i = start; i < OPEN_MAX; i++) { for (i = start; i < OPEN_MAX; i++) {
if (fp->fp_filp[i] == NIL_FILP && !FD_ISSET(i, &fp->fp_filp_inuse)) { if (fp->fp_filp[i] == NULL && !FD_ISSET(i, &fp->fp_filp_inuse)) {
/* A file descriptor has been located. */ /* A file descriptor has been located. */
*k = i; *k = i;
break; break;
@ -85,12 +85,12 @@ int fild; /* file descriptor */
/* See if 'fild' refers to a valid file descr. If so, return its filp ptr. */ /* See if 'fild' refers to a valid file descr. If so, return its filp ptr. */
err_code = EBADF; err_code = EBADF;
if (fild < 0 || fild >= OPEN_MAX ) return(NIL_FILP); if (fild < 0 || fild >= OPEN_MAX ) return(NULL);
if (rfp->fp_filp[fild] == NIL_FILP && FD_ISSET(fild, &rfp->fp_filp_inuse)) if (rfp->fp_filp[fild] == NULL && FD_ISSET(fild, &rfp->fp_filp_inuse))
err_code = EIO; /* The filedes is not there, but is not closed either. err_code = EIO; /* The filedes is not there, but is not closed either.
*/ */
return(rfp->fp_filp[fild]); /* may also be NIL_FILP */ return(rfp->fp_filp[fild]); /* may also be NULL */
} }
@ -115,7 +115,7 @@ PUBLIC struct filp *find_filp(register struct vnode *vp, mode_t bits)
} }
/* If control passes here, the filp wasn't there. Report that back. */ /* If control passes here, the filp wasn't there. Report that back. */
return(NIL_FILP); return(NULL);
} }
/*===========================================================================* /*===========================================================================*
@ -131,7 +131,7 @@ PUBLIC int invalidate(struct filp *fp)
if(fproc[f].fp_pid == PID_FREE) continue; if(fproc[f].fp_pid == PID_FREE) continue;
for(fd = 0; fd < OPEN_MAX; fd++) { for(fd = 0; fd < OPEN_MAX; fd++) {
if(fproc[f].fp_filp[fd] && fproc[f].fp_filp[fd] == fp) { if(fproc[f].fp_filp[fd] && fproc[f].fp_filp[fd] == fp) {
fproc[f].fp_filp[fd] = NIL_FILP; fproc[f].fp_filp[fd] = NULL;
n++; n++;
} }
} }

View file

@ -34,12 +34,12 @@ PUBLIC int do_link()
/* See if 'name1' (file to be linked to) exists. */ /* See if 'name1' (file to be linked to) exists. */
if(fetch_name(m_in.name1, m_in.name1_length, M1) != OK) return(err_code); if(fetch_name(m_in.name1, m_in.name1_length, M1) != OK) return(err_code);
if ((vp = eat_path(PATH_NOFLAGS)) == NIL_VNODE) return(err_code); if ((vp = eat_path(PATH_NOFLAGS)) == NULL) return(err_code);
/* Does the final directory of 'name2' exist? */ /* Does the final directory of 'name2' exist? */
if (fetch_name(m_in.name2, m_in.name2_length, M1) != OK) if (fetch_name(m_in.name2, m_in.name2_length, M1) != OK)
r = err_code; r = err_code;
else if ((vp_d = last_dir()) == NIL_VNODE) else if ((vp_d = last_dir()) == NULL)
r = err_code; r = err_code;
if (r != OK) { if (r != OK) {
put_vnode(vp); put_vnode(vp);
@ -76,7 +76,7 @@ PUBLIC int do_unlink()
/* Get the last directory in the path. */ /* Get the last directory in the path. */
if(fetch_name(m_in.name, m_in.name_length, M3) != OK) return(err_code); if(fetch_name(m_in.name, m_in.name_length, M3) != OK) return(err_code);
if ((vldirp = last_dir()) == NIL_VNODE) return(err_code); if ((vldirp = last_dir()) == NULL) return(err_code);
/* Make sure that the object is a directory */ /* Make sure that the object is a directory */
if((vldirp->v_mode & I_TYPE) != I_DIRECTORY) { if((vldirp->v_mode & I_TYPE) != I_DIRECTORY) {
@ -95,7 +95,7 @@ PUBLIC int do_unlink()
if ((vldirp->v_mode & S_ISVTX) == S_ISVTX) { if ((vldirp->v_mode & S_ISVTX) == S_ISVTX) {
/* Look up inode of file to unlink to retrieve owner */ /* Look up inode of file to unlink to retrieve owner */
vp = advance(vldirp, PATH_RET_SYMLINK); vp = advance(vldirp, PATH_RET_SYMLINK);
if (vp != NIL_VNODE) { if (vp != NULL) {
if(vp->v_uid != fp->fp_effuid && fp->fp_effuid != SU_UID) if(vp->v_uid != fp->fp_effuid && fp->fp_effuid != SU_UID)
r = EPERM; r = EPERM;
put_vnode(vp); put_vnode(vp);
@ -129,14 +129,14 @@ PUBLIC int do_rename()
/* See if 'name1' (existing file) exists. Get dir and file inodes. */ /* See if 'name1' (existing file) exists. Get dir and file inodes. */
if(fetch_name(m_in.name1, m_in.name1_length, M1) != OK) return(err_code); if(fetch_name(m_in.name1, m_in.name1_length, M1) != OK) return(err_code);
if ((old_dirp = last_dir()) == NIL_VNODE) return(err_code); if ((old_dirp = last_dir()) == NULL) return(err_code);
/* If the sticky bit is set, only the owner of the file or a privileged /* If the sticky bit is set, only the owner of the file or a privileged
user is allowed to rename */ user is allowed to rename */
if((old_dirp->v_mode & S_ISVTX) == S_ISVTX) { if((old_dirp->v_mode & S_ISVTX) == S_ISVTX) {
/* Look up inode of file to unlink to retrieve owner */ /* Look up inode of file to unlink to retrieve owner */
vp = advance(old_dirp, PATH_RET_SYMLINK); vp = advance(old_dirp, PATH_RET_SYMLINK);
if (vp != NIL_VNODE) { if (vp != NULL) {
if(vp->v_uid != fp->fp_effuid && fp->fp_effuid != SU_UID) if(vp->v_uid != fp->fp_effuid && fp->fp_effuid != SU_UID)
r = EPERM; r = EPERM;
put_vnode(vp); put_vnode(vp);
@ -158,7 +158,7 @@ PUBLIC int do_rename()
/* See if 'name2' (new name) exists. Get dir inode */ /* See if 'name2' (new name) exists. Get dir inode */
if(fetch_name(m_in.name2, m_in.name2_length, M1) != OK) if(fetch_name(m_in.name2, m_in.name2_length, M1) != OK)
r = err_code; r = err_code;
else if ((new_dirp = last_dir()) == NIL_VNODE) else if ((new_dirp = last_dir()) == NULL)
r = err_code; r = err_code;
if (r != OK) { if (r != OK) {
put_vnode(old_dirp); put_vnode(old_dirp);
@ -198,7 +198,7 @@ PUBLIC int do_truncate()
/* Temporarily open file */ /* Temporarily open file */
if (fetch_name(m_in.m2_p1, m_in.m2_i1, M1) != OK) return(err_code); if (fetch_name(m_in.m2_p1, m_in.m2_i1, M1) != OK) return(err_code);
if ((vp = eat_path(PATH_NOFLAGS)) == NIL_VNODE) return(err_code); if ((vp = eat_path(PATH_NOFLAGS)) == NULL) return(err_code);
/* Ask FS to truncate the file */ /* Ask FS to truncate the file */
if ((r = forbidden(vp, W_BIT)) == OK) if ((r = forbidden(vp, W_BIT)) == OK)
@ -220,7 +220,7 @@ PUBLIC int do_ftruncate()
if ((off_t) m_in.flength < 0) return(EINVAL); if ((off_t) m_in.flength < 0) return(EINVAL);
/* File is already opened; get a vnode pointer from filp */ /* File is already opened; get a vnode pointer from filp */
if ((rfilp = get_filp(m_in.m2_i1)) == NIL_FILP) return(err_code); if ((rfilp = get_filp(m_in.m2_i1)) == NULL) return(err_code);
if (!(rfilp->filp_mode & W_BIT)) return(EBADF); if (!(rfilp->filp_mode & W_BIT)) return(EBADF);
return truncate_vnode(rfilp->filp_vno, m_in.flength); return truncate_vnode(rfilp->filp_vno, m_in.flength);
} }
@ -259,7 +259,7 @@ PUBLIC int do_slink()
/* Get dir inode of 'name2' */ /* Get dir inode of 'name2' */
if(fetch_name(m_in.name2, m_in.name2_length, M1) != OK) return(err_code); if(fetch_name(m_in.name2, m_in.name2_length, M1) != OK) return(err_code);
if ((vp = last_dir()) == NIL_VNODE) return(err_code); if ((vp = last_dir()) == NULL) return(err_code);
if ((r = forbidden(vp, W_BIT|X_BIT)) == OK) { if ((r = forbidden(vp, W_BIT|X_BIT)) == OK) {
r = req_slink(vp->v_fs_e, vp->v_inode_nr, user_fullpath, who_e, r = req_slink(vp->v_fs_e, vp->v_inode_nr, user_fullpath, who_e,
@ -286,7 +286,7 @@ PUBLIC int do_rdlink()
/* Temporarily open the file containing the symbolic link */ /* Temporarily open the file containing the symbolic link */
if(fetch_name(m_in.name1, m_in.name1_length, M1) != OK) return(err_code); if(fetch_name(m_in.name1, m_in.name1_length, M1) != OK) return(err_code);
if ((vp = eat_path(PATH_RET_SYMLINK)) == NIL_VNODE) return(err_code); if ((vp = eat_path(PATH_RET_SYMLINK)) == NULL) return(err_code);
/* Make sure this is a symbolic link */ /* Make sure this is a symbolic link */
if((vp->v_mode & I_TYPE) != I_SYMBOLIC_LINK) if((vp->v_mode & I_TYPE) != I_SYMBOLIC_LINK)

View file

@ -70,10 +70,10 @@ int req; /* either F_SETLK or F_SETLKW */
if (last < first) return(EINVAL); if (last < first) return(EINVAL);
/* Check if this region conflicts with any existing lock. */ /* Check if this region conflicts with any existing lock. */
empty = NIL_LOCK; empty = NULL;
for (flp = &file_lock[0]; flp < &file_lock[NR_LOCKS]; flp++) { for (flp = &file_lock[0]; flp < &file_lock[NR_LOCKS]; flp++) {
if (flp->lock_type == 0) { if (flp->lock_type == 0) {
if (empty == NIL_LOCK) empty = flp; if (empty == NULL) empty = flp;
continue; /* 0 means unused slot */ continue; /* 0 means unused slot */
} }
if (flp->lock_vnode != f->filp_vno) continue; /* different file */ if (flp->lock_vnode != f->filp_vno) continue; /* different file */
@ -155,7 +155,7 @@ int req; /* either F_SETLK or F_SETLKW */
if (ltype == F_UNLCK) return(OK); /* unlocked a region with no locks */ if (ltype == F_UNLCK) return(OK); /* unlocked a region with no locks */
/* There is no conflict. If space exists, store new lock in the table. */ /* There is no conflict. If space exists, store new lock in the table. */
if (empty == NIL_LOCK) return(ENOLCK); /* table full */ if (empty == NULL) return(ENOLCK); /* table full */
empty->lock_type = ltype; empty->lock_type = ltype;
empty->lock_pid = fp->fp_pid; empty->lock_pid = fp->fp_pid;
empty->lock_vnode = f->filp_vno; empty->lock_vnode = f->filp_vno;

View file

@ -9,5 +9,4 @@ EXTERN struct file_lock {
off_t lock_last; /* offset of last byte locked */ off_t lock_last; /* offset of last byte locked */
} file_lock[NR_LOCKS]; } file_lock[NR_LOCKS];
#define NIL_LOCK (struct file_lock *) 0

View file

@ -472,7 +472,7 @@ PRIVATE void init_root()
vmp = &vmnt[0]; vmp = &vmnt[0];
/* We'll need a vnode for the root inode, check whether there is one */ /* We'll need a vnode for the root inode, check whether there is one */
if ((root_node = get_free_vnode()) == NIL_VNODE) if ((root_node = get_free_vnode()) == NULL)
panic("Cannot get free vnode: %d", r); panic("Cannot get free vnode: %d", r);

View file

@ -120,7 +120,7 @@ PUBLIC int do_dup()
/* Is the file descriptor valid? */ /* Is the file descriptor valid? */
rfd = m_in.fd & ~DUP_MASK; /* kill off dup2 bit, if on */ rfd = m_in.fd & ~DUP_MASK; /* kill off dup2 bit, if on */
if ((f = get_filp(rfd)) == NIL_FILP) return(err_code); if ((f = get_filp(rfd)) == NULL) return(err_code);
/* Distinguish between dup and dup2. */ /* Distinguish between dup and dup2. */
if (m_in.fd == rfd) { /* bit not on */ if (m_in.fd == rfd) { /* bit not on */
@ -154,7 +154,7 @@ PUBLIC int do_fcntl()
struct filp *dummy; struct filp *dummy;
/* Is the file descriptor valid? */ /* Is the file descriptor valid? */
if ((f = get_filp(m_in.fd)) == NIL_FILP) return(err_code); if ((f = get_filp(m_in.fd)) == NULL) return(err_code);
switch (m_in.request) { switch (m_in.request) {
case F_DUPFD: case F_DUPFD:
@ -374,7 +374,7 @@ int cpid; /* Child process id */
fp = &fproc[parentno]; fp = &fproc[parentno];
for (i = 0; i < OPEN_MAX; i++) for (i = 0; i < OPEN_MAX; i++)
if (cp->fp_filp[i] != NIL_FILP) cp->fp_filp[i]->filp_count++; if (cp->fp_filp[i] != NULL) cp->fp_filp[i]->filp_count++;
/* Fill in new process and endpoint id. */ /* Fill in new process and endpoint id. */
cp->fp_pid = cpid; cp->fp_pid = cpid;
@ -443,8 +443,8 @@ PRIVATE void free_proc(struct fproc *exiter, int flags)
unsuspend_by_endpt(fp->fp_endpoint); unsuspend_by_endpt(fp->fp_endpoint);
/* Release root and working directories. */ /* Release root and working directories. */
if(fp->fp_rd) { put_vnode(fp->fp_rd); fp->fp_rd = NIL_VNODE; } if(fp->fp_rd) { put_vnode(fp->fp_rd); fp->fp_rd = NULL; }
if(fp->fp_wd) { put_vnode(fp->fp_wd); fp->fp_wd = NIL_VNODE; } if(fp->fp_wd) { put_vnode(fp->fp_wd); fp->fp_wd = NULL; }
/* The rest of these actions is only done when processes actually /* The rest of these actions is only done when processes actually
* exit. * exit.
@ -469,7 +469,7 @@ PRIVATE void free_proc(struct fproc *exiter, int flags)
if (rfp->fp_tty == dev) rfp->fp_tty = 0; if (rfp->fp_tty == dev) rfp->fp_tty = 0;
for (i = 0; i < OPEN_MAX; i++) { for (i = 0; i < OPEN_MAX; i++) {
if ((rfilp = rfp->fp_filp[i]) == NIL_FILP) continue; if ((rfilp = rfp->fp_filp[i]) == NULL) continue;
if (rfilp->filp_mode == FILP_CLOSED) continue; if (rfilp->filp_mode == FILP_CLOSED) continue;
vp = rfilp->filp_vno; vp = rfilp->filp_vno;
if ((vp->v_mode & I_TYPE) != I_CHAR_SPECIAL) continue; if ((vp->v_mode & I_TYPE) != I_CHAR_SPECIAL) continue;

View file

@ -190,7 +190,7 @@ PRIVATE int mount_fs(endpoint_t fs_e)
/* Scan vmnt table to see if dev already mounted. If not, find a free slot.*/ /* Scan vmnt table to see if dev already mounted. If not, find a free slot.*/
found = FALSE; found = FALSE;
vmp = NIL_VMNT; vmp = NULL;
for (i = 0; i < NR_MNTS; ++i) { for (i = 0; i < NR_MNTS; ++i) {
if (vmnt[i].m_dev == dev) { if (vmnt[i].m_dev == dev) {
vmp = &vmnt[i]; vmp = &vmnt[i];
@ -213,7 +213,7 @@ PRIVATE int mount_fs(endpoint_t fs_e)
/* Now get the inode of the file to be mounted on. */ /* Now get the inode of the file to be mounted on. */
if (fetch_name(m_in.name2, m_in.name2_length, M1)!=OK) return(err_code); if (fetch_name(m_in.name2, m_in.name2_length, M1)!=OK) return(err_code);
if ((vp = eat_path(PATH_NOFLAGS)) == NIL_VNODE) return(err_code); if ((vp = eat_path(PATH_NOFLAGS)) == NULL) return(err_code);
if (vp->v_ref_count != 1) { if (vp->v_ref_count != 1) {
put_vnode(vp); put_vnode(vp);
return(EBUSY); return(EBUSY);
@ -251,7 +251,7 @@ PRIVATE int mount_fs(endpoint_t fs_e)
if(!replace_root) { if(!replace_root) {
/* Get vnode of mountpoint */ /* Get vnode of mountpoint */
if ((vp = eat_path(PATH_NOFLAGS)) == NIL_VNODE) return(err_code); if ((vp = eat_path(PATH_NOFLAGS)) == NULL) return(err_code);
/* Tell FS on which vnode it is mounted (glue into mount tree) */ /* Tell FS on which vnode it is mounted (glue into mount tree) */
if ((r = req_mountpoint(vp->v_fs_e, vp->v_inode_nr)) != OK) { if ((r = req_mountpoint(vp->v_fs_e, vp->v_inode_nr)) != OK) {
@ -261,8 +261,8 @@ PRIVATE int mount_fs(endpoint_t fs_e)
} }
/* We'll need a vnode for the root inode, check whether there is one */ /* We'll need a vnode for the root inode, check whether there is one */
if ((root_node = get_free_vnode()) == NIL_VNODE) { if ((root_node = get_free_vnode()) == NULL) {
if (vp != NIL_VNODE) put_vnode(vp); if (vp != NULL) put_vnode(vp);
return(ENFILE); return(ENFILE);
} }
@ -272,7 +272,7 @@ PRIVATE int mount_fs(endpoint_t fs_e)
dp = &dmap[(dev >> MAJOR) & BYTE]; dp = &dmap[(dev >> MAJOR) & BYTE];
if (dp->dmap_driver == NONE) { if (dp->dmap_driver == NONE) {
printf("VFS: no driver for dev %x\n", dev); printf("VFS: no driver for dev %x\n", dev);
if (vp != NIL_VNODE) put_vnode(vp); if (vp != NULL) put_vnode(vp);
return(EINVAL); return(EINVAL);
} }
@ -283,7 +283,7 @@ PRIVATE int mount_fs(endpoint_t fs_e)
/* Tell FS which device to mount */ /* Tell FS which device to mount */
if ((r = req_readsuper(fs_e, label, dev, rdonly, isroot, &res)) != OK) { if ((r = req_readsuper(fs_e, label, dev, rdonly, isroot, &res)) != OK) {
if (vp != NIL_VNODE) put_vnode(vp); if (vp != NULL) put_vnode(vp);
return(r); return(r);
} }
@ -434,7 +434,7 @@ PUBLIC int unmount(
if (vmp->m_mounted_on) { if (vmp->m_mounted_on) {
put_vnode(vmp->m_mounted_on); put_vnode(vmp->m_mounted_on);
vmp->m_mounted_on = NIL_VNODE; vmp->m_mounted_on = NULL;
} }
/* Tell FS to unmount */ /* Tell FS to unmount */
@ -453,7 +453,7 @@ PUBLIC int unmount(
vmp->m_root_node->v_ref_count = 0; vmp->m_root_node->v_ref_count = 0;
vmp->m_root_node->v_fs_count = 0; vmp->m_root_node->v_fs_count = 0;
vmp->m_root_node->v_sdev = NO_DEV; vmp->m_root_node->v_sdev = NO_DEV;
vmp->m_root_node = NIL_VNODE; vmp->m_root_node = NULL;
vmp->m_dev = NO_DEV; vmp->m_dev = NO_DEV;
vmp->m_fs_e = NONE; vmp->m_fs_e = NONE;
@ -498,7 +498,7 @@ PRIVATE dev_t name_to_dev(int allow_mountpt)
struct vnode *vp; struct vnode *vp;
/* Request lookup */ /* Request lookup */
if ((vp = eat_path(PATH_NOFLAGS)) == NIL_VNODE) { if ((vp = eat_path(PATH_NOFLAGS)) == NULL) {
return(NO_DEV); return(NO_DEV);
} }

View file

@ -104,7 +104,7 @@ PRIVATE int common_open(register int oflags, mode_t omode)
flag is set this is an error */ flag is set this is an error */
} else { } else {
/* Scan path name */ /* Scan path name */
if ((vp = eat_path(PATH_NOFLAGS)) == NIL_VNODE) return(err_code); if ((vp = eat_path(PATH_NOFLAGS)) == NULL) return(err_code);
} }
/* Claim the file descriptor and filp slot and fill them in. */ /* Claim the file descriptor and filp slot and fill them in. */
@ -194,7 +194,7 @@ PRIVATE int common_open(register int oflags, mode_t omode)
*/ */
b = (bits & R_BIT ? R_BIT : W_BIT); b = (bits & R_BIT ? R_BIT : W_BIT);
fil_ptr->filp_count = 0; /* don't find self */ fil_ptr->filp_count = 0; /* don't find self */
if ((filp2 = find_filp(vp, b)) != NIL_FILP) { if ((filp2 = find_filp(vp, b)) != NULL) {
/* Co-reader or writer found. Use it.*/ /* Co-reader or writer found. Use it.*/
fp->fp_filp[m_in.fd] = filp2; fp->fp_filp[m_in.fd] = filp2;
filp2->filp_count++; filp2->filp_count++;
@ -222,11 +222,11 @@ PRIVATE int common_open(register int oflags, mode_t omode)
/* If error, release inode. */ /* If error, release inode. */
if (r != OK) { if (r != OK) {
if (r == SUSPEND) return(r); /* Oops, just suspended */ if (r == SUSPEND) return(r); /* Oops, just suspended */
fp->fp_filp[m_in.fd] = NIL_FILP; fp->fp_filp[m_in.fd] = NULL;
FD_CLR(m_in.fd, &fp->fp_filp_inuse); FD_CLR(m_in.fd, &fp->fp_filp_inuse);
fil_ptr->filp_count= 0; fil_ptr->filp_count= 0;
put_vnode(vp); put_vnode(vp);
fil_ptr->filp_vno = NIL_VNODE; fil_ptr->filp_vno = NULL;
return(r); return(r);
} }
@ -241,7 +241,7 @@ PRIVATE struct vnode *new_node(int oflags, mode_t bits)
{ {
/* Try to create a new inode and return a pointer to it. If the inode already /* Try to create a new inode and return a pointer to it. If the inode already
exists, return a pointer to it as well, but set err_code accordingly. exists, return a pointer to it as well, but set err_code accordingly.
NIL_VNODE is returned if the path cannot be resolved up to the last NULL is returned if the path cannot be resolved up to the last
directory, or when the inode cannot be created due to permissions or directory, or when the inode cannot be created due to permissions or
otherwise. */ otherwise. */
struct vnode *dirp, *vp; struct vnode *dirp, *vp;
@ -254,7 +254,7 @@ PRIVATE struct vnode *new_node(int oflags, mode_t bits)
if (oflags & O_EXCL) flags |= PATH_RET_SYMLINK; if (oflags & O_EXCL) flags |= PATH_RET_SYMLINK;
/* See if the path can be opened down to the last directory. */ /* See if the path can be opened down to the last directory. */
if ((dirp = last_dir()) == NIL_VNODE) return(NIL_VNODE); if ((dirp = last_dir()) == NULL) return(NULL);
/* The final directory is accessible. Get final component of the path. */ /* The final directory is accessible. Get final component of the path. */
vp = advance(dirp, flags); vp = advance(dirp, flags);
@ -263,12 +263,12 @@ PRIVATE struct vnode *new_node(int oflags, mode_t bits)
* symlink results in a new path that needs to be re-resolved entirely. */ * symlink results in a new path that needs to be re-resolved entirely. */
if (user_fullpath[0] == '/') return new_node(oflags, bits); if (user_fullpath[0] == '/') return new_node(oflags, bits);
if (vp == NIL_VNODE && err_code == ENOENT) { if (vp == NULL && err_code == ENOENT) {
/* Last path component does not exist. Make a new directory entry. */ /* Last path component does not exist. Make a new directory entry. */
if ((vp = get_free_vnode()) == NIL_VNODE) { if ((vp = get_free_vnode()) == NULL) {
/* Can't create new vnode: out of vnodes. */ /* Can't create new vnode: out of vnodes. */
put_vnode(dirp); put_vnode(dirp);
return(NIL_VNODE); return(NULL);
} }
if ((r = forbidden(dirp, W_BIT|X_BIT)) != OK || if ((r = forbidden(dirp, W_BIT|X_BIT)) != OK ||
(r = req_create(dirp->v_fs_e, dirp->v_inode_nr,bits, fp->fp_effuid, (r = req_create(dirp->v_fs_e, dirp->v_inode_nr,bits, fp->fp_effuid,
@ -281,7 +281,7 @@ PRIVATE struct vnode *new_node(int oflags, mode_t bits)
/* Resolve path up to symlink */ /* Resolve path up to symlink */
slp = advance(dirp, PATH_RET_SYMLINK); slp = advance(dirp, PATH_RET_SYMLINK);
if (slp != NIL_VNODE) { if (slp != NULL) {
if (S_ISLNK(slp->v_mode)) { if (S_ISLNK(slp->v_mode)) {
/* Get contents of link */ /* Get contents of link */
@ -297,7 +297,7 @@ PRIVATE struct vnode *new_node(int oflags, mode_t bits)
put_vnode(slp); put_vnode(slp);
put_vnode(dirp); put_vnode(dirp);
err_code = r; err_code = r;
return(NIL_VNODE); return(NULL);
} }
user_fullpath[r] = '\0';/* Term. path*/ user_fullpath[r] = '\0';/* Term. path*/
} }
@ -313,7 +313,7 @@ PRIVATE struct vnode *new_node(int oflags, mode_t bits)
vp = new_node(oflags, bits); vp = new_node(oflags, bits);
fp->fp_wd = old_wd; /* Restore */ fp->fp_wd = old_wd; /* Restore */
if (vp != NIL_VNODE) { if (vp != NULL) {
put_vnode(dirp); put_vnode(dirp);
return(vp); return(vp);
} }
@ -328,7 +328,7 @@ PRIVATE struct vnode *new_node(int oflags, mode_t bits)
err_code = r; err_code = r;
put_vnode(dirp); put_vnode(dirp);
return(NIL_VNODE); return(NULL);
} }
/* Store results and mark vnode in use */ /* Store results and mark vnode in use */
@ -345,7 +345,7 @@ PRIVATE struct vnode *new_node(int oflags, mode_t bits)
vp->v_ref_count = 1; vp->v_ref_count = 1;
} else { } else {
/* Either last component exists, or there is some other problem. */ /* Either last component exists, or there is some other problem. */
if (vp != NIL_VNODE) if (vp != NULL)
r = EEXIST; /* File exists or a symlink names a file while r = EEXIST; /* File exists or a symlink names a file while
* O_EXCL is set. */ * O_EXCL is set. */
else else
@ -374,7 +374,7 @@ PRIVATE int pipe_open(register struct vnode *vp, register mode_t bits,
if((bits & (R_BIT|W_BIT)) == (R_BIT|W_BIT)) return(ENXIO); if((bits & (R_BIT|W_BIT)) == (R_BIT|W_BIT)) return(ENXIO);
if (find_filp(vp, bits & W_BIT ? R_BIT : W_BIT) == NIL_FILP) { if (find_filp(vp, bits & W_BIT ? R_BIT : W_BIT) == NULL) {
if (oflags & O_NONBLOCK) { if (oflags & O_NONBLOCK) {
if (bits & W_BIT) return(ENXIO); if (bits & W_BIT) return(ENXIO);
} else { } else {
@ -406,7 +406,7 @@ PUBLIC int do_mknod()
/* Open directory that's going to hold the new node. */ /* Open directory that's going to hold the new node. */
if(fetch_name(m_in.name1, m_in.name1_length, M1) != OK) return(err_code); if(fetch_name(m_in.name1, m_in.name1_length, M1) != OK) return(err_code);
if((vp = last_dir()) == NIL_VNODE) return(err_code); if((vp = last_dir()) == NULL) return(err_code);
/* Make sure that the object is a directory */ /* Make sure that the object is a directory */
if((vp->v_mode & I_TYPE) != I_DIRECTORY) { if((vp->v_mode & I_TYPE) != I_DIRECTORY) {
@ -439,7 +439,7 @@ PUBLIC int do_mkdir()
bits = I_DIRECTORY | (m_in.mode & RWX_MODES & fp->fp_umask); bits = I_DIRECTORY | (m_in.mode & RWX_MODES & fp->fp_umask);
/* Request lookup */ /* Request lookup */
if((vp = last_dir()) == NIL_VNODE) return(err_code); if((vp = last_dir()) == NULL) return(err_code);
/* Make sure that the object is a directory */ /* Make sure that the object is a directory */
if ((vp->v_mode & I_TYPE) != I_DIRECTORY) { if ((vp->v_mode & I_TYPE) != I_DIRECTORY) {
@ -469,7 +469,7 @@ PUBLIC int do_lseek()
u64_t pos, newpos; u64_t pos, newpos;
/* Check to see if the file descriptor is valid. */ /* Check to see if the file descriptor is valid. */
if ( (rfilp = get_filp(m_in.ls_fd)) == NIL_FILP) return(err_code); if ( (rfilp = get_filp(m_in.ls_fd)) == NULL) return(err_code);
/* No lseek on pipes. */ /* No lseek on pipes. */
if (rfilp->filp_vno->v_pipe == I_PIPE) return(ESPIPE); if (rfilp->filp_vno->v_pipe == I_PIPE) return(ESPIPE);
@ -517,7 +517,7 @@ PUBLIC int do_llseek()
int r; int r;
/* Check to see if the file descriptor is valid. */ /* Check to see if the file descriptor is valid. */
if ( (rfilp = get_filp(m_in.ls_fd)) == NIL_FILP) return(err_code); if ( (rfilp = get_filp(m_in.ls_fd)) == NULL) return(err_code);
/* No lseek on pipes. */ /* No lseek on pipes. */
if (rfilp->filp_vno->v_pipe == I_PIPE) return(ESPIPE); if (rfilp->filp_vno->v_pipe == I_PIPE) return(ESPIPE);
@ -574,12 +574,12 @@ int fd_nr;
int lock_count; int lock_count;
/* First locate the vnode that belongs to the file descriptor. */ /* First locate the vnode that belongs to the file descriptor. */
if ( (rfilp = get_filp2(rfp, fd_nr)) == NIL_FILP) return(err_code); if ( (rfilp = get_filp2(rfp, fd_nr)) == NULL) return(err_code);
vp = rfilp->filp_vno; vp = rfilp->filp_vno;
close_filp(rfilp); close_filp(rfilp);
FD_CLR(fd_nr, &rfp->fp_cloexec_set); FD_CLR(fd_nr, &rfp->fp_cloexec_set);
rfp->fp_filp[fd_nr] = NIL_FILP; rfp->fp_filp[fd_nr] = NULL;
FD_CLR(fd_nr, &rfp->fp_filp_inuse); FD_CLR(fd_nr, &rfp->fp_filp_inuse);
/* Check to see if the file is locked. If so, release all locks. */ /* Check to see if the file is locked. If so, release all locks. */

View file

@ -47,16 +47,16 @@ int flags;
assert(dirp); assert(dirp);
/* Get a free vnode */ /* Get a free vnode */
if((new_vp = get_free_vnode()) == NIL_VNODE) return(NIL_VNODE); if((new_vp = get_free_vnode()) == NULL) return(NULL);
/* Lookup vnode belonging to the file. */ /* Lookup vnode belonging to the file. */
if ((r = lookup(dirp, flags, &res)) != OK) { if ((r = lookup(dirp, flags, &res)) != OK) {
err_code = r; err_code = r;
return(NIL_VNODE); return(NULL);
} }
/* Check whether vnode is already in use or not */ /* Check whether vnode is already in use or not */
if ((vp = find_vnode(res.fs_e, res.inode_nr)) != NIL_VNODE) { if ((vp = find_vnode(res.fs_e, res.inode_nr)) != NULL) {
dup_vnode(vp); dup_vnode(vp);
vp->v_fs_count++; /* We got a reference from the FS */ vp->v_fs_count++; /* We got a reference from the FS */
return(vp); return(vp);
@ -71,7 +71,7 @@ int flags;
new_vp->v_gid = res.gid; new_vp->v_gid = res.gid;
new_vp->v_sdev = res.dev; new_vp->v_sdev = res.dev;
if( (vmp = find_vmnt(new_vp->v_fs_e)) == NIL_VMNT) if( (vmp = find_vmnt(new_vp->v_fs_e)) == NULL)
panic("VFS advance: vmnt not found"); panic("VFS advance: vmnt not found");
new_vp->v_vmnt = vmp; new_vp->v_vmnt = vmp;
@ -105,7 +105,7 @@ PUBLIC struct vnode *last_dir(void)
/* Parse a path, 'user_fullpath', as far as the last directory, fetch the vnode /* Parse a path, 'user_fullpath', as far as the last directory, fetch the vnode
* for the last directory into the vnode table, and return a pointer to the * for the last directory into the vnode table, and return a pointer to the
* vnode. In addition, return the final component of the path in 'string'. If * vnode. In addition, return the final component of the path in 'string'. If
* the last directory can't be opened, return NIL_VNODE and the reason for * the last directory can't be opened, return NULL and the reason for
* failure in 'err_code'. We can't parse component by component as that would * failure in 'err_code'. We can't parse component by component as that would
* be too expensive. Alternatively, we cut off the last component of the path, * be too expensive. Alternatively, we cut off the last component of the path,
* and parse the path up to the penultimate component. * and parse the path up to the penultimate component.
@ -124,7 +124,7 @@ PUBLIC struct vnode *last_dir(void)
/* If path is empty, return ENOENT. */ /* If path is empty, return ENOENT. */
if (len == 0) { if (len == 0) {
err_code = ENOENT; err_code = ENOENT;
return(NIL_VNODE); return(NULL);
} }
#if !DO_POSIX_PATHNAME_RES #if !DO_POSIX_PATHNAME_RES
@ -156,7 +156,7 @@ PUBLIC struct vnode *last_dir(void)
} }
res = advance(vp, PATH_NOFLAGS); res = advance(vp, PATH_NOFLAGS);
if (res == NIL_VNODE) return(NIL_VNODE); if (res == NULL) return(NULL);
/* Copy the directory entry back to user_fullpath */ /* Copy the directory entry back to user_fullpath */
strcpy(user_fullpath, dir_entry); strcpy(user_fullpath, dir_entry);
@ -253,7 +253,7 @@ node_details_t *node;
/* Climbing up mount */ /* Climbing up mount */
/* Find the vmnt that represents the partition on /* Find the vmnt that represents the partition on
* which we "climb up". */ * which we "climb up". */
if ((vmp = find_vmnt(res.fs_e)) == NIL_VMNT) { if ((vmp = find_vmnt(res.fs_e)) == NULL) {
panic("VFS lookup: can't find parent vmnt"); panic("VFS lookup: can't find parent vmnt");
} }

View file

@ -49,7 +49,7 @@ PUBLIC int do_pipe()
struct node_details res; struct node_details res;
/* See if a free vnode is available */ /* See if a free vnode is available */
if ( (vp = get_free_vnode()) == NIL_VNODE) return(err_code); if ( (vp = get_free_vnode()) == NULL) return(err_code);
/* Acquire two file descriptors. */ /* Acquire two file descriptors. */
rfp = fp; rfp = fp;
@ -58,7 +58,7 @@ PUBLIC int do_pipe()
FD_SET(fil_des[0], &rfp->fp_filp_inuse); FD_SET(fil_des[0], &rfp->fp_filp_inuse);
fil_ptr0->filp_count = 1; fil_ptr0->filp_count = 1;
if ((r = get_fd(0, W_BIT, &fil_des[1], &fil_ptr1)) != OK) { if ((r = get_fd(0, W_BIT, &fil_des[1], &fil_ptr1)) != OK) {
rfp->fp_filp[fil_des[0]] = NIL_FILP; rfp->fp_filp[fil_des[0]] = NULL;
FD_CLR(fil_des[0], &rfp->fp_filp_inuse); FD_CLR(fil_des[0], &rfp->fp_filp_inuse);
fil_ptr0->filp_count = 0; fil_ptr0->filp_count = 0;
return(r); return(r);
@ -72,10 +72,10 @@ PUBLIC int do_pipe()
NO_DEV, &res); NO_DEV, &res);
if (r != OK) { if (r != OK) {
rfp->fp_filp[fil_des[0]] = NIL_FILP; rfp->fp_filp[fil_des[0]] = NULL;
FD_CLR(fil_des[0], &rfp->fp_filp_inuse); FD_CLR(fil_des[0], &rfp->fp_filp_inuse);
fil_ptr0->filp_count = 0; fil_ptr0->filp_count = 0;
rfp->fp_filp[fil_des[1]] = NIL_FILP; rfp->fp_filp[fil_des[1]] = NULL;
FD_CLR(fil_des[1], &rfp->fp_filp_inuse); FD_CLR(fil_des[1], &rfp->fp_filp_inuse);
fil_ptr1->filp_count = 0; fil_ptr1->filp_count = 0;
return(r); return(r);
@ -94,7 +94,7 @@ PUBLIC int do_pipe()
vp->v_mapfs_count = 1; vp->v_mapfs_count = 1;
vp->v_ref_count = 1; vp->v_ref_count = 1;
vp->v_size = 0; vp->v_size = 0;
vp->v_vmnt = NIL_VMNT; vp->v_vmnt = NULL;
vp->v_dev = NO_DEV; vp->v_dev = NO_DEV;
/* Fill in filp objects */ /* Fill in filp objects */
@ -163,7 +163,7 @@ int notouch; /* check only */
if (rw_flag == READING) { if (rw_flag == READING) {
if (pos >= vp->v_size) { if (pos >= vp->v_size) {
/* Process is reading from an empty pipe. */ /* Process is reading from an empty pipe. */
if (find_filp(vp, W_BIT) != NIL_FILP) { if (find_filp(vp, W_BIT) != NULL) {
/* Writer exists */ /* Writer exists */
if (oflags & O_NONBLOCK) if (oflags & O_NONBLOCK)
r = EAGAIN; r = EAGAIN;
@ -180,7 +180,7 @@ int notouch; /* check only */
} }
/* Process is writing to a pipe. */ /* Process is writing to a pipe. */
if (find_filp(vp, R_BIT) == NIL_FILP) { if (find_filp(vp, R_BIT) == NULL) {
/* Process is writing, but there is no reader. Tell kernel to generate /* Process is writing, but there is no reader. Tell kernel to generate
* a SIGPIPE signal. */ * a SIGPIPE signal. */
if (!notouch) sys_kill(fp->fp_endpoint, SIGPIPE); if (!notouch) sys_kill(fp->fp_endpoint, SIGPIPE);
@ -430,7 +430,7 @@ int returned; /* if hanging on task, how many bytes read */
fd_nr = rfp->fp_fd>>8; fd_nr = rfp->fp_fd>>8;
if (returned < 0) { if (returned < 0) {
fil_ptr = rfp->fp_filp[fd_nr]; fil_ptr = rfp->fp_filp[fd_nr];
rfp->fp_filp[fd_nr] = NIL_FILP; rfp->fp_filp[fd_nr] = NULL;
FD_CLR(fd_nr, &rfp->fp_filp_inuse); FD_CLR(fd_nr, &rfp->fp_filp_inuse);
if (fil_ptr->filp_count != 1) { if (fil_ptr->filp_count != 1) {
panic("revive: bad count in filp: %d", panic("revive: bad count in filp: %d",
@ -438,7 +438,7 @@ int returned; /* if hanging on task, how many bytes read */
} }
fil_ptr->filp_count = 0; fil_ptr->filp_count = 0;
put_vnode(fil_ptr->filp_vno); put_vnode(fil_ptr->filp_vno);
fil_ptr->filp_vno = NIL_VNODE; fil_ptr->filp_vno = NULL;
reply(proc_nr_e, returned); reply(proc_nr_e, returned);
} else } else
reply(proc_nr_e, fd_nr); reply(proc_nr_e, fd_nr);

View file

@ -35,7 +35,7 @@ PUBLIC int do_chmod()
if (call_nr == CHMOD) { if (call_nr == CHMOD) {
/* Temporarily open the file */ /* Temporarily open the file */
if(fetch_name(m_in.name, m_in.name_length, M3) != OK) return(err_code); if(fetch_name(m_in.name, m_in.name_length, M3) != OK) return(err_code);
if ((vp = eat_path(PATH_NOFLAGS)) == NIL_VNODE) return(err_code); if ((vp = eat_path(PATH_NOFLAGS)) == NULL) return(err_code);
} else { /* call_nr == FCHMOD */ } else { /* call_nr == FCHMOD */
/* File is already opened; get a pointer to vnode from filp. */ /* File is already opened; get a pointer to vnode from filp. */
if (!(flp = get_filp(m_in.fd))) return(err_code); if (!(flp = get_filp(m_in.fd))) return(err_code);
@ -85,7 +85,7 @@ PUBLIC int do_chown()
if (call_nr == CHOWN) { if (call_nr == CHOWN) {
/* Temporarily open the file. */ /* Temporarily open the file. */
if(fetch_name(m_in.name1, m_in.name1_length, M1) != OK) return(err_code); if(fetch_name(m_in.name1, m_in.name1_length, M1) != OK) return(err_code);
if ((vp = eat_path(PATH_NOFLAGS)) == NIL_VNODE) return(err_code); if ((vp = eat_path(PATH_NOFLAGS)) == NULL) return(err_code);
} else { /* call_nr == FCHOWN */ } else { /* call_nr == FCHOWN */
/* File is already opened; get a pointer to the vnode from filp. */ /* File is already opened; get a pointer to the vnode from filp. */
if (!(flp = get_filp(m_in.fd))) return(err_code); if (!(flp = get_filp(m_in.fd))) return(err_code);
@ -152,7 +152,7 @@ PUBLIC int do_access()
/* Temporarily open the file. */ /* Temporarily open the file. */
if (fetch_name(m_in.name, m_in.name_length, M3) != OK) return(err_code); if (fetch_name(m_in.name, m_in.name_length, M3) != OK) return(err_code);
if ((vp = eat_path(PATH_NOFLAGS)) == NIL_VNODE) return(err_code); if ((vp = eat_path(PATH_NOFLAGS)) == NULL) return(err_code);
r = forbidden(vp, m_in.mode); r = forbidden(vp, m_in.mode);
put_vnode(vp); put_vnode(vp);

View file

@ -51,7 +51,7 @@ int rw_flag; /* READING or WRITING */
/* If the file descriptor is valid, get the vnode, size and mode. */ /* If the file descriptor is valid, get the vnode, size and mode. */
if (m_in.nbytes < 0) return(EINVAL); if (m_in.nbytes < 0) return(EINVAL);
if ((f = get_filp(m_in.fd)) == NIL_FILP) return(err_code); if ((f = get_filp(m_in.fd)) == NULL) return(err_code);
if (((f->filp_mode) & (rw_flag == READING ? R_BIT : W_BIT)) == 0) { if (((f->filp_mode) & (rw_flag == READING ? R_BIT : W_BIT)) == 0) {
return(f->filp_mode == FILP_CLOSED ? EIO : EBADF); return(f->filp_mode == FILP_CLOSED ? EIO : EBADF);
} }
@ -154,7 +154,7 @@ PUBLIC int do_getdents()
register struct filp *rfilp; register struct filp *rfilp;
/* Is the file descriptor valid? */ /* Is the file descriptor valid? */
if ( (rfilp = get_filp(m_in.fd)) == NIL_FILP) { if ( (rfilp = get_filp(m_in.fd)) == NULL) {
return(err_code); return(err_code);
} }

View file

@ -146,7 +146,7 @@ PUBLIC int do_select(void)
/* Get filp belonging to this fd */ /* Get filp belonging to this fd */
filp = se->filps[fd] = get_filp(fd); filp = se->filps[fd] = get_filp(fd);
if (filp == NIL_FILP) { if (filp == NULL) {
if (err_code == EBADF) { if (err_code == EBADF) {
select_cancel_all(se); select_cancel_all(se);
return(EBADF); return(EBADF);
@ -695,8 +695,8 @@ PUBLIC void select_unsuspend_by_endpt(endpoint_t proc_e)
if (selecttab[s].requestor == NULL) continue; if (selecttab[s].requestor == NULL) continue;
for(fd = 0; fd < selecttab[s].nfds; fd++) { for(fd = 0; fd < selecttab[s].nfds; fd++) {
if (selecttab[s].filps[fd] == NIL_FILP || if (selecttab[s].filps[fd] == NULL ||
selecttab[s].filps[fd]->filp_vno == NIL_VNODE) { selecttab[s].filps[fd]->filp_vno == NULL) {
continue; continue;
} }

View file

@ -36,7 +36,7 @@ PUBLIC int do_fchdir()
struct filp *rfilp; struct filp *rfilp;
/* Is the file descriptor valid? */ /* Is the file descriptor valid? */
if ((rfilp = get_filp(m_in.fd)) == NIL_FILP) return(err_code); if ((rfilp = get_filp(m_in.fd)) == NULL) return(err_code);
dup_vnode(rfilp->filp_vno); /* Change into expects a reference. */ dup_vnode(rfilp->filp_vno); /* Change into expects a reference. */
return change_into(&fp->fp_wd, rfilp->filp_vno); return change_into(&fp->fp_wd, rfilp->filp_vno);
} }
@ -78,7 +78,7 @@ int len; /* length of the directory name string */
/* Try to open the directory */ /* Try to open the directory */
if (fetch_name(name_ptr, len, M3) != OK) return(err_code); if (fetch_name(name_ptr, len, M3) != OK) return(err_code);
if ((vp = eat_path(PATH_NOFLAGS)) == NIL_VNODE) return(err_code); if ((vp = eat_path(PATH_NOFLAGS)) == NULL) return(err_code);
return change_into(iip, vp); return change_into(iip, vp);
} }
@ -121,7 +121,7 @@ PUBLIC int do_stat()
struct vnode *vp; struct vnode *vp;
if (fetch_name(m_in.name1, m_in.name1_length, M1) != OK) return(err_code); if (fetch_name(m_in.name1, m_in.name1_length, M1) != OK) return(err_code);
if ((vp = eat_path(PATH_NOFLAGS)) == NIL_VNODE) return(err_code); if ((vp = eat_path(PATH_NOFLAGS)) == NULL) return(err_code);
r = req_stat(vp->v_fs_e, vp->v_inode_nr, who_e, m_in.name2, 0); r = req_stat(vp->v_fs_e, vp->v_inode_nr, who_e, m_in.name2, 0);
put_vnode(vp); put_vnode(vp);
@ -139,7 +139,7 @@ PUBLIC int do_fstat()
int pipe_pos = 0; int pipe_pos = 0;
/* Is the file descriptor valid? */ /* Is the file descriptor valid? */
if ((rfilp = get_filp(m_in.fd)) == NIL_FILP) return(err_code); if ((rfilp = get_filp(m_in.fd)) == NULL) return(err_code);
/* If we read from a pipe, send position too */ /* If we read from a pipe, send position too */
if (rfilp->filp_vno->v_pipe == I_PIPE) { if (rfilp->filp_vno->v_pipe == I_PIPE) {
@ -164,7 +164,7 @@ PUBLIC int do_fstatfs()
struct filp *rfilp; struct filp *rfilp;
/* Is the file descriptor valid? */ /* Is the file descriptor valid? */
if( (rfilp = get_filp(m_in.fd)) == NIL_FILP) return(err_code); if( (rfilp = get_filp(m_in.fd)) == NULL) return(err_code);
return req_fstatfs(rfilp->filp_vno->v_fs_e, who_e, m_in.buffer); return req_fstatfs(rfilp->filp_vno->v_fs_e, who_e, m_in.buffer);
} }
@ -180,7 +180,7 @@ PUBLIC int do_lstat()
int r; int r;
if (fetch_name(m_in.name1, m_in.name1_length, M1) != OK) return(err_code); if (fetch_name(m_in.name1, m_in.name1_length, M1) != OK) return(err_code);
if ((vp = eat_path(PATH_RET_SYMLINK)) == NIL_VNODE) return(err_code); if ((vp = eat_path(PATH_RET_SYMLINK)) == NULL) return(err_code);
r = req_stat(vp->v_fs_e, vp->v_inode_nr, who_e, m_in.name2, 0); r = req_stat(vp->v_fs_e, vp->v_inode_nr, who_e, m_in.name2, 0);
put_vnode(vp); put_vnode(vp);

View file

@ -32,7 +32,7 @@ PUBLIC int do_utime()
/* Temporarily open the file */ /* Temporarily open the file */
if (fetch_name(m_in.utime_file, len, M1) != OK) return(err_code); if (fetch_name(m_in.utime_file, len, M1) != OK) return(err_code);
if ((vp = eat_path(PATH_NOFLAGS)) == NIL_VNODE) return(err_code); if ((vp = eat_path(PATH_NOFLAGS)) == NULL) return(err_code);
/* Only the owner of a file or the super user can change its name. */ /* Only the owner of a file or the super user can change its name. */
r = OK; r = OK;

View file

@ -16,7 +16,7 @@ PUBLIC struct vmnt *get_free_vmnt(short *index)
for (vp = &vmnt[0]; vp < &vmnt[NR_MNTS]; ++vp, ++(*index)) for (vp = &vmnt[0]; vp < &vmnt[NR_MNTS]; ++vp, ++(*index))
if (vp->m_dev == NO_DEV) return(vp); if (vp->m_dev == NO_DEV) return(vp);
return(NIL_VMNT); return(NULL);
} }
@ -29,7 +29,7 @@ PUBLIC struct vmnt *find_vmnt(int fs_e)
for (vp = &vmnt[0]; vp < &vmnt[NR_MNTS]; ++vp) for (vp = &vmnt[0]; vp < &vmnt[NR_MNTS]; ++vp)
if (vp->m_fs_e == fs_e) return(vp); if (vp->m_fs_e == fs_e) return(vp);
return(NIL_VMNT); return(NULL);
} }

View file

@ -9,4 +9,3 @@ EXTERN struct vmnt {
char m_label[LABEL_MAX]; /* label of the file system process */ char m_label[LABEL_MAX]; /* label of the file system process */
} vmnt[NR_MNTS]; } vmnt[NR_MNTS];
#define NIL_VMNT (struct vmnt *) 0

View file

@ -51,7 +51,7 @@ PUBLIC struct vnode *get_free_vnode()
} }
err_code = ENFILE; err_code = ENFILE;
return(NIL_VNODE); return(NULL);
} }
@ -68,7 +68,7 @@ PUBLIC struct vnode *find_vnode(int fs_e, int numb)
if (vp->v_ref_count > 0 && vp->v_inode_nr == numb && vp->v_fs_e == fs_e) if (vp->v_ref_count > 0 && vp->v_inode_nr == numb && vp->v_fs_e == fs_e)
return(vp); return(vp);
return(NIL_VNODE); return(NULL);
} }
@ -147,7 +147,7 @@ PUBLIC void vnode_clean_refs(struct vnode *vp)
{ {
/* Tell the underlying FS to drop all reference but one. */ /* Tell the underlying FS to drop all reference but one. */
if (vp == NIL_VNODE) return; if (vp == NULL) return;
if (vp->v_fs_count <= 1) return; /* Nothing to do */ if (vp->v_fs_count <= 1) return; /* Nothing to do */
/* Drop all references except one */ /* Drop all references except one */

View file

@ -26,7 +26,6 @@ EXTERN struct vnode {
struct vmnt *v_vmnt; /* vmnt object of the partition */ struct vmnt *v_vmnt; /* vmnt object of the partition */
} vnode[NR_VNODES]; } vnode[NR_VNODES];
#define NIL_VNODE (struct vnode *) 0 /* indicates absence of vnode slot */
/* Field values. */ /* Field values. */
#define NO_PIPE 0 /* i_pipe is NO_PIPE if inode is not a pipe */ #define NO_PIPE 0 /* i_pipe is NO_PIPE if inode is not a pipe */

View file

@ -62,7 +62,6 @@ struct hole {
static int startpages; static int startpages;
#define NIL_HOLE (struct hole *) 0
#define _NR_HOLES (_NR_PROCS*2) /* No. of memory holes maintained by VM */ #define _NR_HOLES (_NR_PROCS*2) /* No. of memory holes maintained by VM */
@ -190,9 +189,9 @@ PUBLIC phys_clicks alloc_mem(phys_clicks clicks, u32_t memflags)
} }
} else { } else {
CHECKHOLES; CHECKHOLES;
prev_ptr = NIL_HOLE; prev_ptr = NULL;
hp = hole_head; hp = hole_head;
while (hp != NIL_HOLE) { while (hp != NULL) {
if (hp->h_len >= clicks) { if (hp->h_len >= clicks) {
/* We found a hole that is big enough. Use it. */ /* We found a hole that is big enough. Use it. */
old_base = hp->h_base; /* remember where it started */ old_base = hp->h_base; /* remember where it started */
@ -262,7 +261,7 @@ CHECKHOLES;
return; return;
} }
if ( (new_ptr = free_slots) == NIL_HOLE) if ( (new_ptr = free_slots) == NULL)
panic("hole table full"); panic("hole table full");
new_ptr->h_base = base; new_ptr->h_base = base;
new_ptr->h_len = clicks; new_ptr->h_len = clicks;
@ -273,7 +272,7 @@ CHECKHOLES;
* available, or if no holes are currently available, put this hole on the * available, or if no holes are currently available, put this hole on the
* front of the hole list. * front of the hole list.
*/ */
if (hp == NIL_HOLE || base <= hp->h_base) { if (hp == NULL || base <= hp->h_base) {
/* Block to be freed goes on front of the hole list. */ /* Block to be freed goes on front of the hole list. */
new_ptr->h_next = hp; new_ptr->h_next = hp;
hole_head = new_ptr; hole_head = new_ptr;
@ -283,8 +282,8 @@ CHECKHOLES;
} }
/* Block to be returned does not go on front of hole list. */ /* Block to be returned does not go on front of hole list. */
prev_ptr = NIL_HOLE; prev_ptr = NULL;
while (hp != NIL_HOLE && base > hp->h_base) { while (hp != NULL && base > hp->h_base) {
prev_ptr = hp; prev_ptr = hp;
hp = hp->h_next; hp = hp->h_next;
} }
@ -336,7 +335,7 @@ register struct hole *hp; /* ptr to hole to merge with its successors */
/* If 'hp' points to the last hole, no merging is possible. If it does not, /* If 'hp' points to the last hole, no merging is possible. If it does not,
* try to absorb its successor into it and free the successor's table entry. * try to absorb its successor into it and free the successor's table entry.
*/ */
if ( (next_ptr = hp->h_next) == NIL_HOLE) return; if ( (next_ptr = hp->h_next) == NULL) return;
if (hp->h_base + hp->h_len == next_ptr->h_base) { if (hp->h_base + hp->h_len == next_ptr->h_base) {
hp->h_len += next_ptr->h_len; /* first one gets second one's mem */ hp->h_len += next_ptr->h_len; /* first one gets second one's mem */
del_slot(hp, next_ptr); del_slot(hp, next_ptr);
@ -347,7 +346,7 @@ register struct hole *hp; /* ptr to hole to merge with its successors */
/* If 'hp' now points to the last hole, return; otherwise, try to absorb its /* If 'hp' now points to the last hole, return; otherwise, try to absorb its
* successor into it. * successor into it.
*/ */
if ( (next_ptr = hp->h_next) == NIL_HOLE) return; if ( (next_ptr = hp->h_next) == NULL) return;
if (hp->h_base + hp->h_len == next_ptr->h_base) { if (hp->h_base + hp->h_len == next_ptr->h_base) {
hp->h_len += next_ptr->h_len; hp->h_len += next_ptr->h_len;
del_slot(hp, next_ptr); del_slot(hp, next_ptr);
@ -378,8 +377,8 @@ struct memory *chunks; /* list of free memory chunks */
hp->h_next = hp + 1; hp->h_next = hp + 1;
hp->h_base = hp->h_len = 0; hp->h_base = hp->h_len = 0;
} }
hole[_NR_HOLES-1].h_next = NIL_HOLE; hole[_NR_HOLES-1].h_next = NULL;
hole_head = NIL_HOLE; hole_head = NULL;
free_slots = &hole[0]; free_slots = &hole[0];
addr_init(&addravl); addr_init(&addravl);