- delete unused .h files

- slight code cleanup
 - neater exit procedure: exit when unmount
   message received and kill signal (from RS 'down' or
   reboot/shutdown) received (speed up unmount, but don't
   confuse VFS by exiting before/during unmount msg)
This commit is contained in:
Ben Gras 2009-04-27 16:13:51 +00:00
parent bb23344283
commit b7e23b70e8
9 changed files with 47 additions and 205 deletions

View File

@ -1,24 +0,0 @@
/* This is the filp table. It is an intermediary between file descriptors and
* inodes. A slot is free if filp_count == 0.
*/
EXTERN struct filp {
mode_t filp_mode; /* RW bits, telling how file is opened */
int filp_flags; /* flags from open and fcntl */
int filp_count; /* how many file descriptors share this slot?*/
struct inode *filp_ino; /* pointer to the inode */
off_t filp_pos; /* file position */
/* the following fields are for select() and are owned by the generic
* select() code (i.e., fd-type-specific select() code can't touch these).
*/
int filp_selectors; /* select()ing processes blocking on this fd */
int filp_select_ops; /* interested in these SEL_* operations */
/* following are for fd-type-specific select() */
int filp_pipe_select_ops;
} filp[NR_FILPS];
#define FILP_CLOSED 0 /* filp_mode: associated device closed */
#define NIL_FILP (struct filp *) 0 /* indicates absence of a filp slot */

View File

@ -1,44 +0,0 @@
#include <sys/select.h>
#include <minix/safecopies.h>
/* This is the per-process information. A slot is reserved for each potential
* process. Thus NR_PROCS must be the same as in the kernel. It is not
* possible or even necessary to tell when a slot is free here.
*/
EXTERN struct fproc {
mode_t fp_umask; /* mask set by umask system call */
struct inode *fp_workdir; /* pointer to working directory's inode */
struct inode *fp_rootdir; /* pointer to current root dir (see chroot) */
struct filp *fp_filp[OPEN_MAX];/* the file descriptor table */
fd_set fp_filp_inuse; /* which fd's are in use? */
uid_t fp_realuid; /* real user id */
uid_t fp_effuid; /* effective user id */
gid_t fp_realgid; /* real group id */
gid_t fp_effgid; /* effective group id */
dev_t fp_tty; /* major/minor of controlling tty */
int fp_fd; /* place to save fd if rd/wr can't finish */
char *fp_buffer; /* place to save buffer if rd/wr can't finish*/
int fp_nbytes; /* place to save bytes if rd/wr can't finish */
int fp_cum_io_partial; /* partial byte count if rd/wr can't finish */
char fp_suspended; /* set to indicate process hanging */
char fp_revived; /* set to indicate process being revived */
int fp_task; /* which task is proc suspended on */
endpoint_t fp_ioproc; /* proc no. in suspended-on i/o message */
cp_grant_id_t fp_grant; /* revoke this grant on unsuspend if > -1 */
char fp_sesldr; /* true if proc is a session leader */
char fp_execced; /* true if proc has exec()ced after fork */
pid_t fp_pid; /* process id */
fd_set fp_cloexec_set; /* bit map for POSIX Table 6-2 FD_CLOEXEC */
endpoint_t fp_endpoint; /* kernel endpoint number of this process */
} fproc[NR_PROCS];
/* Field values. */
#define NOT_SUSPENDED 0 /* process is not suspended on pipe or task */
#define SUSPENDED 1 /* process is suspended on pipe or task */
#define NOT_REVIVING 0 /* process is not being revived */
#define REVIVING 1 /* process is being revived from suspension */
#define PID_FREE 0 /* process slot free */
/* Check is process number is acceptable - includes system processes. */
#define isokprocnr(n) ((unsigned)((n)+NR_TASKS) < NR_PROCS + NR_TASKS)

View File

@ -44,6 +44,8 @@ EXTERN dev_t fs_dev; /* The device that is handled by this FS proc.
EXTERN char fs_dev_label[16]; /* Name of the device driver that is handled
* by this FS proc.
*/
EXTERN int unmountdone;
EXTERN int exitsignaled;
/* our block size. */
EXTERN int fs_block_size;

View File

@ -1,10 +0,0 @@
/* This is the file locking table. Like the filp table, it points to the
* inode table, however, in this case to achieve advisory locking.
*/
EXTERN struct file_lock {
short lock_type; /* F_RDLOCK or F_WRLOCK; 0 means unused slot */
pid_t lock_pid; /* pid of the process holding the lock */
struct inode *lock_inode; /* pointer to the inode locked */
off_t lock_first; /* offset of first byte locked */
off_t lock_last; /* offset of last byte locked */
} file_lock[NR_LOCKS];

View File

@ -1,5 +1,6 @@
#include "inc.h"
#include <assert.h>
#include <minix/dmap.h>
#include <minix/endpoint.h>
@ -16,17 +17,15 @@ FORWARD _PROTOTYPE(void get_work, (message *m_in) );
FORWARD _PROTOTYPE(void cch_check, (void) );
/*===========================================================================*
* main *
*===========================================================================*/
PUBLIC int main(void)
PUBLIC int main(int argc, char *argv[])
{
/* This is the main routine of this service. The main loop consists of
* three major activities: getting new work, processing the work, and
* sending the reply. The loop never terminates, unless a panic occurs.
*/
int who_e; /* caller */
int error, ind;
message m;
@ -40,44 +39,26 @@ PUBLIC int main(void)
return -1;
}
#if 0
if (fs_m_in.m_type != REQ_READSUPER_O && fs_m_in.m_type != REQ_READSUPER_S) {
printf("MFS(%d): Invalid login reply\n", SELF_E);
return -1;
}
else {
if (fs_m_in.m_type == REQ_READSUPER_S)
fs_m_out.m_type = fs_readsuper_s();
else
fs_m_out.m_type = fs_readsuper_o();
reply(FS_PROC_NR, &fs_m_out);
if (fs_m_out.m_type != OK) return -1;
}
#endif
for (;;) {
while(!unmountdone || !exitsignaled) {
endpoint_t src;
/* Wait for request message. */
get_work(&fs_m_in);
src = fs_m_in.m_source;
error = OK;
caller_uid = -1; /* To trap errors */
caller_gid = -1;
who_e = fs_m_in.m_source;
if (who_e != FS_PROC_NR) {
if (who_e == 0) {
if(fs_m_in.m_type == PROC_EVENT) {
/* A signal from PM: this means we're getting killed.
* Exit nicely.
*/
fs_sync();
exit(0);
}
}
continue;
/* Exit request? */
if(src == PM_PROC_NR) {
exitsignaled = 1;
fs_sync();
continue;
}
/* This must be a regular VFS request. */
assert(src == VFS_PROC_NR && !unmountdone);
req_nr = fs_m_in.m_type;
if (req_nr < VFS_BASE)
@ -98,23 +79,11 @@ PUBLIC int main(void)
}
fs_m_out.m_type = error;
reply(who_e, &fs_m_out);
reply(src, &fs_m_out);
if (error == OK && rdahed_inode != NIL_INODE) {
read_ahead(); /* do block read ahead */
}
/*
* VFS asks RS to bring down the FS... */
/*
if (req_nr == REQ_UNMOUNT ||
(req_nr == REQ_READSUPER && error != OK)) {
printf("MFS(%d) exit() cachehit: %d cachemiss: %d\n", SELF_E,
inode_cache_hit, inode_cache_miss);
return 0;
}
*/
}
}
@ -148,9 +117,35 @@ PRIVATE void init_server(void)
PRIVATE void get_work(m_in)
message *m_in; /* pointer to message */
{
int s; /* receive status */
if (OK != (s = receive(ANY, m_in))) /* wait for message */
panic("MFS","receive failed", s);
int srcok = 0;
endpoint_t src;
do {
int s; /* receive status */
if (OK != (s = receive(ANY, m_in))) /* wait for message */
panic("MFS","receive failed", s);
src = fs_m_in.m_source;
if (src != FS_PROC_NR) {
if(src == PM_PROC_NR) {
if(fs_m_in.m_type == PROC_EVENT)
srcok = 1; /* Normal exit request. */
else
printf("MFS: unexpected message from PM\n");
} else
printf("MFS: unexpected source %d\n", src);
} else if(src == FS_PROC_NR) {
if(unmountdone) {
printf("MFS: unmounted: unexpected message from FS\n");
} else {
/* Normal FS request. */
srcok = 1;
}
} else
printf("MFS: unexpected source %d\n", src);
} while(!srcok);
assert((src == FS_PROC_NR && !unmountdone) ||
(src == PM_PROC_NR && fs_m_in.m_type == PROC_EVENT));
}

View File

@ -294,8 +294,6 @@ PUBLIC int fs_unmount()
count = 0;
for (rip = &inode[0]; rip < &inode[NR_INODES]; rip++) {
if (rip->i_count > 0 && rip->i_dev == fs_dev) {
/*printf("FSunmount DEV: %d inode: %d count: %d iaddr: %d\n",
rip->i_dev, rip->i_num, rip->i_count, rip);*/
count += rip->i_count;
}
}
@ -315,6 +313,7 @@ PUBLIC int fs_unmount()
/* Finish off the unmount. */
superblock.s_dev = NO_DEV;
unmountdone = TRUE;
return OK;
}

View File

@ -1,65 +0,0 @@
/* The following names are synonyms for the variables in the input message. */
#define acc_time m2_l1
#define addr m1_i3
#define buffer m1_p1
#define child_endpt m1_i2
#define co_mode m1_i1
#define eff_grp_id m1_i3
#define eff_user_id m1_i3
#define erki m1_p1
#define fd m1_i1
#define fd2 m1_i2
#define ioflags m1_i3
#define group m1_i3
#define real_grp_id m1_i2
#define ls_fd m2_i1
#define mk_mode m1_i2
#define mk_z0 m1_i3
#define mode m3_i2
#define c_mode m1_i3
#define c_name m1_p1
#define name m3_p1
#define name1 m1_p1
#define name2 m1_p2
#define name_length m3_i1
#define name1_length m1_i1
#define name2_length m1_i2
#define nbytes m1_i2
#define owner m1_i2
#define parent_endpt m1_i1
#define pathname m3_ca1
#define pid m1_i3
#define ENDPT m1_i1
#define ctl_req m4_l1
#define driver_nr m4_l2
#define dev_nr m4_l3
#define dev_style m4_l4
#define m_force m4_l5
#define rd_only m1_i3
#define real_user_id m1_i2
#define request m1_i2
#define sig m1_i2
#define endpt1 m1_i1
#define tp m2_l1
#define utime_actime m2_l1
#define utime_modtime m2_l2
#define utime_file m2_p1
#define utime_length m2_i1
#define utime_strlen m2_i2
#define whence m2_i2
#define svrctl_req m2_i1
#define svrctl_argp m2_p1
#define pm_stime m1_i1
#define info_what m1_i1
#define info_where m1_p1
/* The following names are synonyms for the variables in the output message. */
#define reply_type m_type
#define reply_l1 m2_l1
#define reply_i1 m1_i1
#define reply_i2 m1_i2
#define reply_t1 m4_l1
#define reply_t2 m4_l2
#define reply_t3 m4_l3
#define reply_t4 m4_l4
#define reply_t5 m4_l5

View File

@ -81,14 +81,12 @@ _PROTOTYPE( int lock_op, (struct filp *f, int req) );
_PROTOTYPE( void lock_revive, (void) );
/* main.c */
_PROTOTYPE( int main, (void) );
_PROTOTYPE( void reply, (int who, message *m_out) );
/* misc.c */
_PROTOTYPE( int do_dup, (void) );
_PROTOTYPE( int do_exit, (void) );
_PROTOTYPE( int do_fcntl, (void) );
_PROTOTYPE( int do_fork, (void) );
_PROTOTYPE( int do_exec, (void) );
_PROTOTYPE( int do_revive, (void) );
_PROTOTYPE( int do_set, (void) );

View File

@ -1,9 +0,0 @@
#ifndef _FS_SELECT_H
#define _FS_SELECT_H 1
/* return codes for select_request_* and select_cancel_* */
#define SEL_OK 0 /* ready */
#define SEL_ERROR 1 /* failed */
#endif