From: Richard Sailer Date: Mon, 3 Oct 2016 22:27:02 +0000 (+0200) Subject: VFS: Convert K&R C -> ANSI C X-Git-Url: http://zhaoyanbai.com/repos/named.html?a=commitdiff_plain;h=a0814afb2e128f52ed10c9a5d4c91bf6abc22290;p=minix.git VFS: Convert K&R C -> ANSI C Aditionally this removes all trailing whitespaces using: sed -i 's/[[:space:]]*$//' *.c Change-Id: I88451fdb6f6e79e61f8aae5bd5a7f2e3538f9944 --- diff --git a/minix/servers/vfs/exec.c b/minix/servers/vfs/exec.c index 9f67a0e1d..24704f08a 100644 --- a/minix/servers/vfs/exec.c +++ b/minix/servers/vfs/exec.c @@ -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 - * 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. */ 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; } - /* 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)); aux_vec = (AuxInfo *) (frame + (vap - *vsp)); aux_vec_end = aux_vec + PMEF_AUXVECTORS; - if (((char *)aux_vec < frame) || + if (((char *)aux_vec < frame) || ((char *)aux_vec > (frame + *frame_size))) { printf("VFS: malformed stack for exec(), first AuxVector is" " not on the stack.\n"); diff --git a/minix/servers/vfs/filedes.c b/minix/servers/vfs/filedes.c index 13bd6c8b6..1233dd9dd 100644 --- a/minix/servers/vfs/filedes.c +++ b/minix/servers/vfs/filedes.c @@ -137,9 +137,11 @@ int get_fd(struct fproc *rfp, int start, mode_t bits, int *k, struct filp **fpt) /*===========================================================================* * get_filp * *===========================================================================*/ -struct filp *get_filp(fild, locktype) -int fild; /* file descriptor */ -tll_access_t locktype; +struct filp * +get_filp( + int fild, /* file descriptor */ + tll_access_t locktype +) { /* 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 * *===========================================================================*/ -struct filp *get_filp2(rfp, fild, locktype) -register struct fproc *rfp; -int fild; /* file descriptor */ -tll_access_t locktype; +struct filp * +get_filp2( + register struct fproc *rfp, + int fild, /* file descriptor */ + tll_access_t locktype +) { /* See if 'fild' refers to a valid file descr. If so, return its filp ptr. */ struct filp *filp; @@ -242,9 +246,8 @@ void invalidate_filp_by_endpt(endpoint_t proc_e) /*===========================================================================* * lock_filp * *===========================================================================*/ -void lock_filp(filp, locktype) -struct filp *filp; -tll_access_t locktype; +void +lock_filp(struct filp *filp, tll_access_t locktype) { struct worker_thread *org_self; struct vnode *vp; @@ -287,8 +290,8 @@ tll_access_t locktype; /*===========================================================================* * unlock_filp * *===========================================================================*/ -void unlock_filp(filp) -struct filp *filp; +void +unlock_filp(struct filp *filp) { /* If this filp holds a soft lock on the vnode, we must be the owner */ if (filp->filp_softlock != NULL) @@ -312,9 +315,8 @@ struct filp *filp; /*===========================================================================* * unlock_filps * *===========================================================================*/ -void unlock_filps(filp1, filp2) -struct filp *filp1; -struct filp *filp2; +void +unlock_filps(struct filp *filp1, struct filp *filp2) { /* 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. */ @@ -344,8 +346,8 @@ struct filp *filp2; /*===========================================================================* * close_filp * *===========================================================================*/ -void close_filp(f) -struct filp *f; +void +close_filp(struct filp *f) { /* Close a file. Will also unlock filp when done */ diff --git a/minix/servers/vfs/link.c b/minix/servers/vfs/link.c index ea6124c39..129a80595 100644 --- a/minix/servers/vfs/link.c +++ b/minix/servers/vfs/link.c @@ -362,9 +362,8 @@ int do_ftruncate(void) /*===========================================================================* * truncate_vnode * *===========================================================================*/ -int truncate_vnode(vp, newsize) -struct vnode *vp; -off_t newsize; +int +truncate_vnode(struct vnode *vp, off_t newsize) { /* Truncate a regular file or a pipe */ int r; @@ -427,10 +426,12 @@ int do_slink(void) /*===========================================================================* * rdlink_direct * *===========================================================================*/ -int rdlink_direct(orig_path, link_path, rfp) -char *orig_path; -char link_path[PATH_MAX]; /* should have length PATH_MAX */ -struct fproc *rfp; +int +rdlink_direct( + char *orig_path, + char link_path[PATH_MAX], /* should have length PATH_MAX */ + struct fproc *rfp +) { /* Perform a readlink()-like call from within the VFS */ int r; diff --git a/minix/servers/vfs/lock.c b/minix/servers/vfs/lock.c index 8cf341934..20d410265 100644 --- a/minix/servers/vfs/lock.c +++ b/minix/servers/vfs/lock.c @@ -169,7 +169,8 @@ int lock_op(int fd, int req, vir_bytes arg) /*===========================================================================* * lock_revive * *===========================================================================*/ -void lock_revive() +void +lock_revive(void) { /* 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 diff --git a/minix/servers/vfs/main.c b/minix/servers/vfs/main.c index b690ffd33..9be33245e 100644 --- a/minix/servers/vfs/main.c +++ b/minix/servers/vfs/main.c @@ -915,8 +915,8 @@ static void service_pm(void) /*===========================================================================* * unblock * *===========================================================================*/ -static int unblock(rfp) -struct fproc *rfp; +static int +unblock(struct fproc *rfp) { /* 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. diff --git a/minix/servers/vfs/misc.c b/minix/servers/vfs/misc.c index d7e30bb94..54ed7ad0f 100644 --- a/minix/servers/vfs/misc.c +++ b/minix/servers/vfs/misc.c @@ -496,7 +496,8 @@ reqdone: /*===========================================================================* * pm_reboot * *===========================================================================*/ -void pm_reboot() +void +pm_reboot(void) { /* Perform the VFS side of the reboot call. This call is performed from the PM * process context. @@ -709,10 +710,8 @@ void pm_exit(void) /*===========================================================================* * pm_setgid * *===========================================================================*/ -void pm_setgid(proc_e, egid, rgid) -endpoint_t proc_e; -int egid; -int rgid; +void +pm_setgid(endpoint_t proc_e, int egid, int rgid) { register struct fproc *tfp; int slot; @@ -728,10 +727,8 @@ int rgid; /*===========================================================================* * pm_setgroups * *===========================================================================*/ -void pm_setgroups(proc_e, ngroups, groups) -endpoint_t proc_e; -int ngroups; -gid_t *groups; +void +pm_setgroups(endpoint_t proc_e, int ngroups, gid_t *groups) { struct fproc *rfp; int slot; @@ -751,10 +748,8 @@ gid_t *groups; /*===========================================================================* * pm_setuid * *===========================================================================*/ -void pm_setuid(proc_e, euid, ruid) -endpoint_t proc_e; -int euid; -int ruid; +void +pm_setuid(endpoint_t proc_e, int euid, int ruid) { struct fproc *tfp; int slot; @@ -973,11 +968,11 @@ ds_event(void) } /* A function to be called on panic(). */ -void panic_hook(void) -{ +void panic_hook(void) +{ printf("VFS mthread stacktraces:\n"); - mthread_stacktraces(); -} + mthread_stacktraces(); +} /*===========================================================================* * do_getrusage * diff --git a/minix/servers/vfs/open.c b/minix/servers/vfs/open.c index 4ace3b985..b5e3f8513 100644 --- a/minix/servers/vfs/open.c +++ b/minix/servers/vfs/open.c @@ -682,9 +682,8 @@ int do_close(void) /*===========================================================================* * close_fd * *===========================================================================*/ -int close_fd(rfp, fd_nr) -struct fproc *rfp; -int fd_nr; +int +close_fd(struct fproc *rfp, int fd_nr) { /* Perform the close(fd) system call. */ register struct filp *rfilp; diff --git a/minix/servers/vfs/path.c b/minix/servers/vfs/path.c index ffbc67d3d..21fab6f1a 100644 --- a/minix/servers/vfs/path.c +++ b/minix/servers/vfs/path.c @@ -39,10 +39,8 @@ static int check_perms(endpoint_t ep, cp_grant_id_t io_gr, size_t /*===========================================================================* * advance * *===========================================================================*/ -struct vnode *advance(dirp, resolve, rfp) -struct vnode *dirp; -struct lookup *resolve; -struct fproc *rfp; +struct vnode * +advance(struct vnode *dirp, struct lookup *resolve, struct fproc *rfp) { /* Resolve a path name starting at dirp to a vnode. */ int r; @@ -134,9 +132,8 @@ struct fproc *rfp; /*===========================================================================* * eat_path * *===========================================================================*/ -struct vnode *eat_path(resolve, rfp) -struct lookup *resolve; -struct fproc *rfp; +struct vnode * +eat_path(struct lookup *resolve, struct fproc *rfp) { /* Resolve path to a vnode. advance does the actual work. */ struct vnode *start_dir; @@ -148,9 +145,8 @@ struct fproc *rfp; /*===========================================================================* * last_dir * *===========================================================================*/ -struct vnode *last_dir(resolve, rfp) -struct lookup *resolve; -struct fproc *rfp; +struct vnode * +last_dir(struct lookup *resolve, struct fproc *rfp) { /* 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 @@ -387,11 +383,8 @@ struct fproc *rfp; /*===========================================================================* * lookup * *===========================================================================*/ -static int lookup(start_node, resolve, result_node, rfp) -struct vnode *start_node; -struct lookup *resolve; -node_details_t *result_node; -struct fproc *rfp; +static int +lookup(struct vnode *start_node, struct lookup *resolve, node_details_t *result_node, struct fproc *rfp) { /* Resolve a path name relative to start_node. */ @@ -581,12 +574,8 @@ struct fproc *rfp; /*===========================================================================* * lookup_init * *===========================================================================*/ -void lookup_init(resolve, path, flags, vmp, vp) -struct lookup *resolve; -char *path; -int flags; -struct vmnt **vmp; -struct vnode **vp; +void +lookup_init(struct lookup *resolve, char *path, int flags, struct vmnt **vmp, struct vnode **vp) { assert(vmp != NULL); assert(vp != NULL); @@ -604,10 +593,8 @@ struct vnode **vp; /*===========================================================================* * get_name * *===========================================================================*/ -int get_name(dirp, entry, ename) -struct vnode *dirp; -struct vnode *entry; -char ename[NAME_MAX + 1]; +int +get_name(struct vnode *dirp, struct vnode *entry, char ename[NAME_MAX + 1]) { #define DIR_ENTRIES 8 #define DIR_ENTRY_SIZE (sizeof(struct dirent) + NAME_MAX) @@ -660,9 +647,8 @@ char ename[NAME_MAX + 1]; /*===========================================================================* * canonical_path * *===========================================================================*/ -int canonical_path(orig_path, rfp) -char orig_path[PATH_MAX]; -struct fproc *rfp; +int +canonical_path(char orig_path[PATH_MAX], struct fproc *rfp) { /* Find canonical path of a given path */ int len = 0; diff --git a/minix/servers/vfs/pipe.c b/minix/servers/vfs/pipe.c index 0b50c838a..bd89fedaa 100644 --- a/minix/servers/vfs/pipe.c +++ b/minix/servers/vfs/pipe.c @@ -147,9 +147,8 @@ static int create_pipe(int fil_des[2], int flags) /*===========================================================================* * map_vnode * *===========================================================================*/ -int map_vnode(vp, map_to_fs_e) -struct vnode *vp; -endpoint_t map_to_fs_e; +int +map_vnode(struct vnode *vp, endpoint_t map_to_fs_e) { int r; struct vmnt *vmp; diff --git a/minix/servers/vfs/protect.c b/minix/servers/vfs/protect.c index f36b71800..d94b98d5d 100644 --- a/minix/servers/vfs/protect.c +++ b/minix/servers/vfs/protect.c @@ -289,8 +289,10 @@ int forbidden(struct fproc *rfp, struct vnode *vp, mode_t access_desired) /*===========================================================================* * read_only * *===========================================================================*/ -int read_only(vp) -struct vnode *vp; /* ptr to inode whose file sys is to be cked */ +int +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 * read only. If so, return EROFS, else return OK. diff --git a/minix/servers/vfs/request.c b/minix/servers/vfs/request.c index e34874d35..19ae609b2 100644 --- a/minix/servers/vfs/request.c +++ b/minix/servers/vfs/request.c @@ -696,10 +696,8 @@ int req_newdriver( /*===========================================================================* * req_putnode * *===========================================================================*/ -int req_putnode(fs_e, inode_nr, count) -int fs_e; -ino_t inode_nr; -int count; +int +req_putnode(int fs_e, ino_t inode_nr, int count) { 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 * *===========================================================================*/ -int req_rename(fs_e, old_dir, old_name, new_dir, new_name) -endpoint_t fs_e; -ino_t old_dir; -char *old_name; -ino_t new_dir; -char *new_name; +int +req_rename(endpoint_t fs_e, ino_t old_dir, char *old_name, ino_t new_dir, char *new_name) { int r; cp_grant_id_t gid_old, gid_new; @@ -969,10 +963,8 @@ char *new_name; /*===========================================================================* * req_rmdir * *===========================================================================*/ -int req_rmdir(fs_e, inode_nr, lastc) -endpoint_t fs_e; -ino_t inode_nr; -char *lastc; +int +req_rmdir(endpoint_t fs_e, ino_t inode_nr, char *lastc) { int r; 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 * *===========================================================================*/ -int req_sync(fs_e) -endpoint_t fs_e; +int +req_sync(endpoint_t fs_e) { message m; @@ -1154,10 +1146,8 @@ endpoint_t fs_e; /*===========================================================================* * req_unlink * *===========================================================================*/ -int req_unlink(fs_e, inode_nr, lastc) -endpoint_t fs_e; -ino_t inode_nr; -char *lastc; +int +req_unlink(endpoint_t fs_e, ino_t inode_nr, char *lastc) { cp_grant_id_t grant_id; size_t len; @@ -1186,8 +1176,8 @@ char *lastc; /*===========================================================================* * req_unmount * *===========================================================================*/ -int req_unmount(fs_e) -endpoint_t fs_e; +int +req_unmount(endpoint_t fs_e) { message m; diff --git a/minix/servers/vfs/select.c b/minix/servers/vfs/select.c index 92b852b54..c8347d0bb 100644 --- a/minix/servers/vfs/select.c +++ b/minix/servers/vfs/select.c @@ -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; dst_fds = (direction == FROM_PROC) ? &se->readfds : 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); 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; dst_fds = (direction == FROM_PROC) ? &se->writefds : 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); 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; dst_fds = (direction == FROM_PROC) ? &se->errorfds : 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); if (r != OK) return(r); } @@ -1034,9 +1034,8 @@ static void select_restart_filps(void) /*===========================================================================* * filp_status * *===========================================================================*/ -static void filp_status(f, status) -struct filp *f; -int status; +static void +filp_status(struct filp *f, int status) { /* Tell processes that need to know about the status of this filp. This * function MUST NOT block its calling thread. @@ -1065,8 +1064,8 @@ int status; /*===========================================================================* * restart_proc * *===========================================================================*/ -static void restart_proc(se) -struct selectentry *se; +static void +restart_proc(struct selectentry *se) { /* Tell process about select results (if any) unless there are still results * pending. This function MUST NOT block its calling thread. diff --git a/minix/servers/vfs/vmnt.c b/minix/servers/vfs/vmnt.c index 7e17d204f..a262de167 100644 --- a/minix/servers/vfs/vmnt.c +++ b/minix/servers/vfs/vmnt.c @@ -41,7 +41,8 @@ void check_vmnt_locks_by_me(struct fproc *rfp) /*===========================================================================* * check_vmnt_locks * *===========================================================================*/ -void check_vmnt_locks() +void +check_vmnt_locks(void) { struct vmnt *vmp; int count = 0; diff --git a/minix/servers/vfs/vnode.c b/minix/servers/vfs/vnode.c index a45b3d885..73d63d2a5 100644 --- a/minix/servers/vfs/vnode.c +++ b/minix/servers/vfs/vnode.c @@ -61,7 +61,8 @@ void check_vnode_locks_by_me(struct fproc *rfp) /*===========================================================================* * check_vnode_locks * *===========================================================================*/ -void check_vnode_locks() +void +check_vnode_locks(void) { struct vnode *vp; int count = 0; @@ -80,7 +81,8 @@ void check_vnode_locks() /*===========================================================================* * 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) */ struct vnode *vp;