VFS: Convert K&R C -> ANSI C

Aditionally this removes all trailing whitespaces
using: sed -i 's/[[:space:]]*$//' *.c

Change-Id: I88451fdb6f6e79e61f8aae5bd5a7f2e3538f9944
This commit is contained in:
Richard Sailer 2016-10-04 00:27:02 +02:00 committed by David van Moolenbroek
parent 4aa48abab9
commit a0814afb2e
14 changed files with 93 additions and 116 deletions

View File

@ -295,7 +295,7 @@ int pm_exec(vir_bytes path, size_t path_len, vir_bytes frame, size_t frame_len,
} }
/* ld.so is linked at 0, but it can relocate itself; we /* ld.so is linked at 0, but it can relocate itself; we
* want it higher to trap NULL pointer dereferences. * want it higher to trap NULL pointer dereferences.
* Let's put it below the stack, and reserve 10MB for ld.so. * Let's put it below the stack, and reserve 10MB for ld.so.
*/ */
execi.args.load_offset = execi.args.load_offset =
@ -435,12 +435,12 @@ static int stack_prepare_elf(struct vfs_exec_info *execi, char *frame, size_t *f
return ENOEXEC; return ENOEXEC;
} }
/* Find first Aux vector in the stack frame. */ /* Find first Aux vector in the stack frame. */
vap = (vir_bytes)(psp->ps_envstr + (psp->ps_nenvstr + 1)); vap = (vir_bytes)(psp->ps_envstr + (psp->ps_nenvstr + 1));
aux_vec = (AuxInfo *) (frame + (vap - *vsp)); aux_vec = (AuxInfo *) (frame + (vap - *vsp));
aux_vec_end = aux_vec + PMEF_AUXVECTORS; aux_vec_end = aux_vec + PMEF_AUXVECTORS;
if (((char *)aux_vec < frame) || if (((char *)aux_vec < frame) ||
((char *)aux_vec > (frame + *frame_size))) { ((char *)aux_vec > (frame + *frame_size))) {
printf("VFS: malformed stack for exec(), first AuxVector is" printf("VFS: malformed stack for exec(), first AuxVector is"
" not on the stack.\n"); " not on the stack.\n");

View File

@ -137,9 +137,11 @@ int get_fd(struct fproc *rfp, int start, mode_t bits, int *k, struct filp **fpt)
/*===========================================================================* /*===========================================================================*
* get_filp * * get_filp *
*===========================================================================*/ *===========================================================================*/
struct filp *get_filp(fild, locktype) struct filp *
int fild; /* file descriptor */ get_filp(
tll_access_t locktype; int fild, /* file descriptor */
tll_access_t locktype
)
{ {
/* 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. */
@ -150,10 +152,12 @@ tll_access_t locktype;
/*===========================================================================* /*===========================================================================*
* get_filp2 * * get_filp2 *
*===========================================================================*/ *===========================================================================*/
struct filp *get_filp2(rfp, fild, locktype) struct filp *
register struct fproc *rfp; get_filp2(
int fild; /* file descriptor */ register struct fproc *rfp,
tll_access_t locktype; int fild, /* file descriptor */
tll_access_t locktype
)
{ {
/* 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. */
struct filp *filp; struct filp *filp;
@ -242,9 +246,8 @@ void invalidate_filp_by_endpt(endpoint_t proc_e)
/*===========================================================================* /*===========================================================================*
* lock_filp * * lock_filp *
*===========================================================================*/ *===========================================================================*/
void lock_filp(filp, locktype) void
struct filp *filp; lock_filp(struct filp *filp, tll_access_t locktype)
tll_access_t locktype;
{ {
struct worker_thread *org_self; struct worker_thread *org_self;
struct vnode *vp; struct vnode *vp;
@ -287,8 +290,8 @@ tll_access_t locktype;
/*===========================================================================* /*===========================================================================*
* unlock_filp * * unlock_filp *
*===========================================================================*/ *===========================================================================*/
void unlock_filp(filp) void
struct filp *filp; unlock_filp(struct filp *filp)
{ {
/* If this filp holds a soft lock on the vnode, we must be the owner */ /* If this filp holds a soft lock on the vnode, we must be the owner */
if (filp->filp_softlock != NULL) if (filp->filp_softlock != NULL)
@ -312,9 +315,8 @@ struct filp *filp;
/*===========================================================================* /*===========================================================================*
* unlock_filps * * unlock_filps *
*===========================================================================*/ *===========================================================================*/
void unlock_filps(filp1, filp2) void
struct filp *filp1; unlock_filps(struct filp *filp1, struct filp *filp2)
struct filp *filp2;
{ {
/* Unlock two filps that are tied to the same vnode. As a thread can lock a /* Unlock two filps that are tied to the same vnode. As a thread can lock a
* vnode only once, unlocking the vnode twice would result in an error. */ * vnode only once, unlocking the vnode twice would result in an error. */
@ -344,8 +346,8 @@ struct filp *filp2;
/*===========================================================================* /*===========================================================================*
* close_filp * * close_filp *
*===========================================================================*/ *===========================================================================*/
void close_filp(f) void
struct filp *f; close_filp(struct filp *f)
{ {
/* Close a file. Will also unlock filp when done */ /* Close a file. Will also unlock filp when done */

View File

@ -362,9 +362,8 @@ int do_ftruncate(void)
/*===========================================================================* /*===========================================================================*
* truncate_vnode * * truncate_vnode *
*===========================================================================*/ *===========================================================================*/
int truncate_vnode(vp, newsize) int
struct vnode *vp; truncate_vnode(struct vnode *vp, off_t newsize)
off_t newsize;
{ {
/* Truncate a regular file or a pipe */ /* Truncate a regular file or a pipe */
int r; int r;
@ -427,10 +426,12 @@ int do_slink(void)
/*===========================================================================* /*===========================================================================*
* rdlink_direct * * rdlink_direct *
*===========================================================================*/ *===========================================================================*/
int rdlink_direct(orig_path, link_path, rfp) int
char *orig_path; rdlink_direct(
char link_path[PATH_MAX]; /* should have length PATH_MAX */ char *orig_path,
struct fproc *rfp; char link_path[PATH_MAX], /* should have length PATH_MAX */
struct fproc *rfp
)
{ {
/* Perform a readlink()-like call from within the VFS */ /* Perform a readlink()-like call from within the VFS */
int r; int r;

View File

@ -169,7 +169,8 @@ int lock_op(int fd, int req, vir_bytes arg)
/*===========================================================================* /*===========================================================================*
* lock_revive * * lock_revive *
*===========================================================================*/ *===========================================================================*/
void lock_revive() void
lock_revive(void)
{ {
/* Go find all the processes that are waiting for any kind of lock and /* Go find all the processes that are waiting for any kind of lock and
* revive them all. The ones that are still blocked will block again when * revive them all. The ones that are still blocked will block again when

View File

@ -915,8 +915,8 @@ static void service_pm(void)
/*===========================================================================* /*===========================================================================*
* unblock * * unblock *
*===========================================================================*/ *===========================================================================*/
static int unblock(rfp) static int
struct fproc *rfp; unblock(struct fproc *rfp)
{ {
/* Unblock a process that was previously blocked on a pipe or a lock. This is /* Unblock a process that was previously blocked on a pipe or a lock. This is
* done by reconstructing the original request and continuing/repeating it. * done by reconstructing the original request and continuing/repeating it.

View File

@ -496,7 +496,8 @@ reqdone:
/*===========================================================================* /*===========================================================================*
* pm_reboot * * pm_reboot *
*===========================================================================*/ *===========================================================================*/
void pm_reboot() void
pm_reboot(void)
{ {
/* Perform the VFS side of the reboot call. This call is performed from the PM /* Perform the VFS side of the reboot call. This call is performed from the PM
* process context. * process context.
@ -709,10 +710,8 @@ void pm_exit(void)
/*===========================================================================* /*===========================================================================*
* pm_setgid * * pm_setgid *
*===========================================================================*/ *===========================================================================*/
void pm_setgid(proc_e, egid, rgid) void
endpoint_t proc_e; pm_setgid(endpoint_t proc_e, int egid, int rgid)
int egid;
int rgid;
{ {
register struct fproc *tfp; register struct fproc *tfp;
int slot; int slot;
@ -728,10 +727,8 @@ int rgid;
/*===========================================================================* /*===========================================================================*
* pm_setgroups * * pm_setgroups *
*===========================================================================*/ *===========================================================================*/
void pm_setgroups(proc_e, ngroups, groups) void
endpoint_t proc_e; pm_setgroups(endpoint_t proc_e, int ngroups, gid_t *groups)
int ngroups;
gid_t *groups;
{ {
struct fproc *rfp; struct fproc *rfp;
int slot; int slot;
@ -751,10 +748,8 @@ gid_t *groups;
/*===========================================================================* /*===========================================================================*
* pm_setuid * * pm_setuid *
*===========================================================================*/ *===========================================================================*/
void pm_setuid(proc_e, euid, ruid) void
endpoint_t proc_e; pm_setuid(endpoint_t proc_e, int euid, int ruid)
int euid;
int ruid;
{ {
struct fproc *tfp; struct fproc *tfp;
int slot; int slot;
@ -973,11 +968,11 @@ ds_event(void)
} }
/* A function to be called on panic(). */ /* A function to be called on panic(). */
void panic_hook(void) void panic_hook(void)
{ {
printf("VFS mthread stacktraces:\n"); printf("VFS mthread stacktraces:\n");
mthread_stacktraces(); mthread_stacktraces();
} }
/*===========================================================================* /*===========================================================================*
* do_getrusage * * do_getrusage *

View File

@ -682,9 +682,8 @@ int do_close(void)
/*===========================================================================* /*===========================================================================*
* close_fd * * close_fd *
*===========================================================================*/ *===========================================================================*/
int close_fd(rfp, fd_nr) int
struct fproc *rfp; close_fd(struct fproc *rfp, int fd_nr)
int fd_nr;
{ {
/* Perform the close(fd) system call. */ /* Perform the close(fd) system call. */
register struct filp *rfilp; register struct filp *rfilp;

View File

@ -39,10 +39,8 @@ static int check_perms(endpoint_t ep, cp_grant_id_t io_gr, size_t
/*===========================================================================* /*===========================================================================*
* advance * * advance *
*===========================================================================*/ *===========================================================================*/
struct vnode *advance(dirp, resolve, rfp) struct vnode *
struct vnode *dirp; advance(struct vnode *dirp, struct lookup *resolve, struct fproc *rfp)
struct lookup *resolve;
struct fproc *rfp;
{ {
/* Resolve a path name starting at dirp to a vnode. */ /* Resolve a path name starting at dirp to a vnode. */
int r; int r;
@ -134,9 +132,8 @@ struct fproc *rfp;
/*===========================================================================* /*===========================================================================*
* eat_path * * eat_path *
*===========================================================================*/ *===========================================================================*/
struct vnode *eat_path(resolve, rfp) struct vnode *
struct lookup *resolve; eat_path(struct lookup *resolve, struct fproc *rfp)
struct fproc *rfp;
{ {
/* Resolve path to a vnode. advance does the actual work. */ /* Resolve path to a vnode. advance does the actual work. */
struct vnode *start_dir; struct vnode *start_dir;
@ -148,9 +145,8 @@ struct fproc *rfp;
/*===========================================================================* /*===========================================================================*
* last_dir * * last_dir *
*===========================================================================*/ *===========================================================================*/
struct vnode *last_dir(resolve, rfp) struct vnode *
struct lookup *resolve; last_dir(struct lookup *resolve, struct fproc *rfp)
struct fproc *rfp;
{ {
/* Parse a path, as far as the last directory, fetch the vnode /* Parse a path, 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
@ -387,11 +383,8 @@ struct fproc *rfp;
/*===========================================================================* /*===========================================================================*
* lookup * * lookup *
*===========================================================================*/ *===========================================================================*/
static int lookup(start_node, resolve, result_node, rfp) static int
struct vnode *start_node; lookup(struct vnode *start_node, struct lookup *resolve, node_details_t *result_node, struct fproc *rfp)
struct lookup *resolve;
node_details_t *result_node;
struct fproc *rfp;
{ {
/* Resolve a path name relative to start_node. */ /* Resolve a path name relative to start_node. */
@ -581,12 +574,8 @@ struct fproc *rfp;
/*===========================================================================* /*===========================================================================*
* lookup_init * * lookup_init *
*===========================================================================*/ *===========================================================================*/
void lookup_init(resolve, path, flags, vmp, vp) void
struct lookup *resolve; lookup_init(struct lookup *resolve, char *path, int flags, struct vmnt **vmp, struct vnode **vp)
char *path;
int flags;
struct vmnt **vmp;
struct vnode **vp;
{ {
assert(vmp != NULL); assert(vmp != NULL);
assert(vp != NULL); assert(vp != NULL);
@ -604,10 +593,8 @@ struct vnode **vp;
/*===========================================================================* /*===========================================================================*
* get_name * * get_name *
*===========================================================================*/ *===========================================================================*/
int get_name(dirp, entry, ename) int
struct vnode *dirp; get_name(struct vnode *dirp, struct vnode *entry, char ename[NAME_MAX + 1])
struct vnode *entry;
char ename[NAME_MAX + 1];
{ {
#define DIR_ENTRIES 8 #define DIR_ENTRIES 8
#define DIR_ENTRY_SIZE (sizeof(struct dirent) + NAME_MAX) #define DIR_ENTRY_SIZE (sizeof(struct dirent) + NAME_MAX)
@ -660,9 +647,8 @@ char ename[NAME_MAX + 1];
/*===========================================================================* /*===========================================================================*
* canonical_path * * canonical_path *
*===========================================================================*/ *===========================================================================*/
int canonical_path(orig_path, rfp) int
char orig_path[PATH_MAX]; canonical_path(char orig_path[PATH_MAX], struct fproc *rfp)
struct fproc *rfp;
{ {
/* Find canonical path of a given path */ /* Find canonical path of a given path */
int len = 0; int len = 0;

View File

@ -147,9 +147,8 @@ static int create_pipe(int fil_des[2], int flags)
/*===========================================================================* /*===========================================================================*
* map_vnode * * map_vnode *
*===========================================================================*/ *===========================================================================*/
int map_vnode(vp, map_to_fs_e) int
struct vnode *vp; map_vnode(struct vnode *vp, endpoint_t map_to_fs_e)
endpoint_t map_to_fs_e;
{ {
int r; int r;
struct vmnt *vmp; struct vmnt *vmp;

View File

@ -289,8 +289,10 @@ int forbidden(struct fproc *rfp, struct vnode *vp, mode_t access_desired)
/*===========================================================================* /*===========================================================================*
* read_only * * read_only *
*===========================================================================*/ *===========================================================================*/
int read_only(vp) int
struct vnode *vp; /* ptr to inode whose file sys is to be cked */ read_only(
struct vnode *vp /* ptr to inode whose file sys is to be cked */
)
{ {
/* Check to see if the file system on which the inode 'ip' resides is mounted /* Check to see if the file system on which the inode 'ip' resides is mounted
* read only. If so, return EROFS, else return OK. * read only. If so, return EROFS, else return OK.

View File

@ -696,10 +696,8 @@ int req_newdriver(
/*===========================================================================* /*===========================================================================*
* req_putnode * * req_putnode *
*===========================================================================*/ *===========================================================================*/
int req_putnode(fs_e, inode_nr, count) int
int fs_e; req_putnode(int fs_e, ino_t inode_nr, int count)
ino_t inode_nr;
int count;
{ {
message m; message m;
@ -925,12 +923,8 @@ int req_peek(endpoint_t fs_e, ino_t inode_nr, off_t pos, unsigned int bytes)
/*===========================================================================* /*===========================================================================*
* req_rename * * req_rename *
*===========================================================================*/ *===========================================================================*/
int req_rename(fs_e, old_dir, old_name, new_dir, new_name) int
endpoint_t fs_e; req_rename(endpoint_t fs_e, ino_t old_dir, char *old_name, ino_t new_dir, char *new_name)
ino_t old_dir;
char *old_name;
ino_t new_dir;
char *new_name;
{ {
int r; int r;
cp_grant_id_t gid_old, gid_new; cp_grant_id_t gid_old, gid_new;
@ -969,10 +963,8 @@ char *new_name;
/*===========================================================================* /*===========================================================================*
* req_rmdir * * req_rmdir *
*===========================================================================*/ *===========================================================================*/
int req_rmdir(fs_e, inode_nr, lastc) int
endpoint_t fs_e; req_rmdir(endpoint_t fs_e, ino_t inode_nr, char *lastc)
ino_t inode_nr;
char *lastc;
{ {
int r; int r;
cp_grant_id_t grant_id; cp_grant_id_t grant_id;
@ -1138,8 +1130,8 @@ int req_stat(endpoint_t fs_e, ino_t inode_nr, endpoint_t proc_e,
/*===========================================================================* /*===========================================================================*
* req_sync * * req_sync *
*===========================================================================*/ *===========================================================================*/
int req_sync(fs_e) int
endpoint_t fs_e; req_sync(endpoint_t fs_e)
{ {
message m; message m;
@ -1154,10 +1146,8 @@ endpoint_t fs_e;
/*===========================================================================* /*===========================================================================*
* req_unlink * * req_unlink *
*===========================================================================*/ *===========================================================================*/
int req_unlink(fs_e, inode_nr, lastc) int
endpoint_t fs_e; req_unlink(endpoint_t fs_e, ino_t inode_nr, char *lastc)
ino_t inode_nr;
char *lastc;
{ {
cp_grant_id_t grant_id; cp_grant_id_t grant_id;
size_t len; size_t len;
@ -1186,8 +1176,8 @@ char *lastc;
/*===========================================================================* /*===========================================================================*
* req_unmount * * req_unmount *
*===========================================================================*/ *===========================================================================*/
int req_unmount(fs_e) int
endpoint_t fs_e; req_unmount(endpoint_t fs_e)
{ {
message m; message m;

View File

@ -582,7 +582,7 @@ static int copy_fdsets(struct selectentry *se, int nfds, int direction)
src_fds = (direction == FROM_PROC) ? se->vir_readfds : &se->ready_readfds; src_fds = (direction == FROM_PROC) ? se->vir_readfds : &se->ready_readfds;
dst_fds = (direction == FROM_PROC) ? &se->readfds : se->vir_readfds; dst_fds = (direction == FROM_PROC) ? &se->readfds : se->vir_readfds;
if (se->vir_readfds) { if (se->vir_readfds) {
r = sys_datacopy_wrapper(src_e, (vir_bytes) src_fds, dst_e, r = sys_datacopy_wrapper(src_e, (vir_bytes) src_fds, dst_e,
(vir_bytes) dst_fds, fd_setsize); (vir_bytes) dst_fds, fd_setsize);
if (r != OK) return(r); if (r != OK) return(r);
} }
@ -591,7 +591,7 @@ static int copy_fdsets(struct selectentry *se, int nfds, int direction)
src_fds = (direction == FROM_PROC) ? se->vir_writefds : &se->ready_writefds; src_fds = (direction == FROM_PROC) ? se->vir_writefds : &se->ready_writefds;
dst_fds = (direction == FROM_PROC) ? &se->writefds : se->vir_writefds; dst_fds = (direction == FROM_PROC) ? &se->writefds : se->vir_writefds;
if (se->vir_writefds) { if (se->vir_writefds) {
r = sys_datacopy_wrapper(src_e, (vir_bytes) src_fds, dst_e, r = sys_datacopy_wrapper(src_e, (vir_bytes) src_fds, dst_e,
(vir_bytes) dst_fds, fd_setsize); (vir_bytes) dst_fds, fd_setsize);
if (r != OK) return(r); if (r != OK) return(r);
} }
@ -600,7 +600,7 @@ static int copy_fdsets(struct selectentry *se, int nfds, int direction)
src_fds = (direction == FROM_PROC) ? se->vir_errorfds : &se->ready_errorfds; src_fds = (direction == FROM_PROC) ? se->vir_errorfds : &se->ready_errorfds;
dst_fds = (direction == FROM_PROC) ? &se->errorfds : se->vir_errorfds; dst_fds = (direction == FROM_PROC) ? &se->errorfds : se->vir_errorfds;
if (se->vir_errorfds) { if (se->vir_errorfds) {
r = sys_datacopy_wrapper(src_e, (vir_bytes) src_fds, dst_e, r = sys_datacopy_wrapper(src_e, (vir_bytes) src_fds, dst_e,
(vir_bytes) dst_fds, fd_setsize); (vir_bytes) dst_fds, fd_setsize);
if (r != OK) return(r); if (r != OK) return(r);
} }
@ -1034,9 +1034,8 @@ static void select_restart_filps(void)
/*===========================================================================* /*===========================================================================*
* filp_status * * filp_status *
*===========================================================================*/ *===========================================================================*/
static void filp_status(f, status) static void
struct filp *f; filp_status(struct filp *f, int status)
int status;
{ {
/* Tell processes that need to know about the status of this filp. This /* Tell processes that need to know about the status of this filp. This
* function MUST NOT block its calling thread. * function MUST NOT block its calling thread.
@ -1065,8 +1064,8 @@ int status;
/*===========================================================================* /*===========================================================================*
* restart_proc * * restart_proc *
*===========================================================================*/ *===========================================================================*/
static void restart_proc(se) static void
struct selectentry *se; restart_proc(struct selectentry *se)
{ {
/* Tell process about select results (if any) unless there are still results /* Tell process about select results (if any) unless there are still results
* pending. This function MUST NOT block its calling thread. * pending. This function MUST NOT block its calling thread.

View File

@ -41,7 +41,8 @@ void check_vmnt_locks_by_me(struct fproc *rfp)
/*===========================================================================* /*===========================================================================*
* check_vmnt_locks * * check_vmnt_locks *
*===========================================================================*/ *===========================================================================*/
void check_vmnt_locks() void
check_vmnt_locks(void)
{ {
struct vmnt *vmp; struct vmnt *vmp;
int count = 0; int count = 0;

View File

@ -61,7 +61,8 @@ void check_vnode_locks_by_me(struct fproc *rfp)
/*===========================================================================* /*===========================================================================*
* check_vnode_locks * * check_vnode_locks *
*===========================================================================*/ *===========================================================================*/
void check_vnode_locks() void
check_vnode_locks(void)
{ {
struct vnode *vp; struct vnode *vp;
int count = 0; int count = 0;
@ -80,7 +81,8 @@ void check_vnode_locks()
/*===========================================================================* /*===========================================================================*
* get_free_vnode * * get_free_vnode *
*===========================================================================*/ *===========================================================================*/
struct vnode *get_free_vnode() struct vnode *
get_free_vnode(void)
{ {
/* Find a free vnode slot in the vnode table (it's not actually allocated) */ /* Find a free vnode slot in the vnode table (it's not actually allocated) */
struct vnode *vp; struct vnode *vp;