From: David van Moolenbroek Date: Mon, 10 Aug 2015 16:06:10 +0000 (+0200) Subject: Annotations and tweaks for live update X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/already%20found%20%2A/doxygen-warnings.log?a=commitdiff_plain;h=refs%2Fchanges%2F64%2F3164%2F1;p=minix.git Annotations and tweaks for live update This change is necessary for instrumentation-aided state transfer. Change-Id: I24be938009f02e302a15083f9a7a11824975e42b --- diff --git a/minix/fs/pfs/pfs.c b/minix/fs/pfs/pfs.c index 1ff8977cd..0a5b0ca08 100644 --- a/minix/fs/pfs/pfs.c +++ b/minix/fs/pfs/pfs.c @@ -198,8 +198,10 @@ pfs_putnode(ino_t ino_nr, unsigned int count) return EINVAL; /* For pipes, free the inode data buffer. */ - if (rip->i_data != NULL) + if (rip->i_data != NULL) { free(rip->i_data); + rip->i_data = NULL; + } /* Return the inode to the free list. */ rip->i_free = TRUE; diff --git a/minix/fs/procfs/service.c b/minix/fs/procfs/service.c index a76bf3108..bd695e1dd 100644 --- a/minix/fs/procfs/service.c +++ b/minix/fs/procfs/service.c @@ -19,10 +19,11 @@ struct policies { enum policy supported; }; -static struct { +typedef struct { struct rproc proc[NR_SYS_PROCS]; struct rprocpub pub[NR_SYS_PROCS]; -} rproc; +} ixfer_rproc_t; +static ixfer_rproc_t rproc; static struct policies policies[NR_SYS_PROCS]; diff --git a/minix/lib/libminixfs/cache.c b/minix/lib/libminixfs/cache.c index ffb7aadc5..b54b800af 100644 --- a/minix/lib/libminixfs/cache.c +++ b/minix/lib/libminixfs/cache.c @@ -66,6 +66,8 @@ static fsblkcnt_t fs_btotal = 0, fs_bused = 0; static int quiet = 0; +typedef struct buf *noxfer_buf_ptr_t; /* annotation for temporary buf ptrs */ + void lmfs_setquiet(int q) { quiet = q; } static int fs_bufs_heuristic(int minbufs, fsblkcnt_t btotal, @@ -988,7 +990,7 @@ void lmfs_readahead(dev_t dev, block64_t base_block, unsigned int nblocks, * However, the caller must also not rely on all or even any of the blocks to * be present in the cache afterwards--failures are (deliberately!) ignored. */ - static struct buf *bufq[LMFS_MAX_PREFETCH]; /* static because of size only */ + static noxfer_buf_ptr_t bufq[LMFS_MAX_PREFETCH]; /* static for size only */ struct buf *bp; unsigned int count; int r; @@ -1131,7 +1133,7 @@ void lmfs_flushdev(dev_t dev) /* Flush all dirty blocks for one device. */ register struct buf *bp; - static struct buf **dirty; + static noxfer_buf_ptr_t *dirty; static unsigned int dirtylistsize = 0; unsigned int ndirty; diff --git a/minix/lib/libvtreefs/inode.h b/minix/lib/libvtreefs/inode.h index 3340cca32..d8c84cd66 100644 --- a/minix/lib/libvtreefs/inode.h +++ b/minix/lib/libvtreefs/inode.h @@ -1,6 +1,13 @@ #ifndef _VTREEFS_INODE_H #define _VTREEFS_INODE_H +/* + * Callback data can be a pointer or a (cast) integer value. For now, we + * instruct the state transfer framework that it should translate only + * recognized pointers. + */ +typedef cbdata_t cixfer_cbdata_t; + /* * The inodes that are active, form a fully connected tree. Each node except * the root node has a parent and a tail queue of children, where each child @@ -27,7 +34,7 @@ struct inode { unsigned int i_count; /* reference count */ index_t i_index; /* index number in parent / NO_INDEX */ int i_indexed; /* number of indexed entries */ - cbdata_t i_cbdata; /* callback data */ + cixfer_cbdata_t i_cbdata; /* callback data */ unsigned short i_flags; /* I_DELETED or 0 */ /* Tree structure */ diff --git a/minix/servers/pm/mproc.h b/minix/servers/pm/mproc.h index b99a54cfb..aadc3466f 100644 --- a/minix/servers/pm/mproc.h +++ b/minix/servers/pm/mproc.h @@ -13,6 +13,8 @@ /* Needs to be included here, for 'ps' etc */ #include "const.h" +typedef struct sigaction ixfer_sigaction; + EXTERN struct mproc { char mp_exitstatus; /* storage for status when process exits */ char mp_sigstatus; /* storage for signal # for killed procs */ @@ -45,7 +47,7 @@ EXTERN struct mproc { sigset_t mp_sigpending; /* pending signals to be handled */ sigset_t mp_ksigpending; /* bitmap for pending signals from the kernel */ sigset_t mp_sigtrace; /* signals to hand to tracer first */ - struct sigaction mp_sigact[_NSIG]; /* as in sigaction(2) */ + ixfer_sigaction mp_sigact[_NSIG]; /* as in sigaction(2) */ #ifdef __ACK__ char mp_padding[60]; /* align structure with new libc */ #endif diff --git a/minix/servers/rs/exec.c b/minix/servers/rs/exec.c index 1e2c75d91..feb3df4dc 100644 --- a/minix/servers/rs/exec.c +++ b/minix/servers/rs/exec.c @@ -19,6 +19,8 @@ static struct exec_loaders { { NULL } }; +extern struct minix_kerninfo *_minix_kerninfo; + int srv_execve(int proc_e, char *exec, size_t exec_len, char **argv, char **envp) { @@ -73,7 +75,7 @@ static int do_exec(int proc_e, char *exec, size_t exec_len, char *progname, memset(&execi, 0, sizeof(execi)); - execi.stack_high = kinfo.user_sp; + execi.stack_high = _minix_kerninfo->kinfo->user_sp; execi.stack_size = DEFAULT_STACK_LIMIT; execi.proc_e = proc_e; execi.hdr = exec; diff --git a/minix/servers/rs/glo.h b/minix/servers/rs/glo.h index 938e55f97..da65c1efa 100644 --- a/minix/servers/rs/glo.h +++ b/minix/servers/rs/glo.h @@ -54,7 +54,5 @@ EXTERN unsigned system_hz; EXTERN struct machine machine; /* machine info */ -EXTERN struct kinfo kinfo; /* kernel information */ - #endif /* RS_GLO_H */ diff --git a/minix/servers/rs/main.c b/minix/servers/rs/main.c index 28e491b8d..5805b9fc2 100644 --- a/minix/servers/rs/main.c +++ b/minix/servers/rs/main.c @@ -53,9 +53,6 @@ int main(void) if (OK != (s=sys_getmachine(&machine))) panic("couldn't get machine info: %d", s); - if (OK != (s=sys_getkinfo(&kinfo))) - panic("couldn't get kernel kinfo: %d", s); - /* Main loop - get work and do it, forever. */ while (TRUE) { /* Perform sensitive background operations when RS is idle. */ diff --git a/minix/servers/vfs/exec.c b/minix/servers/vfs/exec.c index 1eef3821d..90e19c057 100644 --- a/minix/servers/vfs/exec.c +++ b/minix/servers/vfs/exec.c @@ -82,6 +82,8 @@ static const struct exec_loaders exec_loaders[] = { #define lock_exec() lock_proc(fproc_addr(VM_PROC_NR)) #define unlock_exec() unlock_proc(fproc_addr(VM_PROC_NR)) +extern struct minix_kerninfo *_minix_kerninfo; + /*===========================================================================* * get_read_vp * *===========================================================================*/ @@ -213,7 +215,7 @@ int pm_exec(vir_bytes path, size_t path_len, vir_bytes frame, size_t frame_len, /* passed from exec() libc code */ execi.userflags = 0; - execi.args.stack_high = kinfo.user_sp; + execi.args.stack_high = _minix_kerninfo->kinfo->user_sp; execi.args.stack_size = DEFAULT_STACK_LIMIT; fp->text_size = 0; diff --git a/minix/servers/vfs/glo.h b/minix/servers/vfs/glo.h index 3fbdb05ea..6be3b66e9 100644 --- a/minix/servers/vfs/glo.h +++ b/minix/servers/vfs/glo.h @@ -43,6 +43,4 @@ EXTERN int err_code; /* temporary storage for error number */ /* Data initialized elsewhere. */ extern int (* const call_vec[])(void); -EXTERN struct kinfo kinfo; /* kernel information */ - #endif diff --git a/minix/servers/vfs/main.c b/minix/servers/vfs/main.c index c8036c830..68db53b6e 100644 --- a/minix/servers/vfs/main.c +++ b/minix/servers/vfs/main.c @@ -65,9 +65,6 @@ int main(void) printf("Started VFS: %d worker thread(s)\n", NR_WTHREADS); - if (OK != (sys_getkinfo(&kinfo))) - panic("couldn't get kernel kinfo"); - /* This is the main loop that gets work, processes it, and sends replies. */ while (TRUE) { yield_all(); /* let other threads run */ diff --git a/minix/servers/vm/glo.h b/minix/servers/vm/glo.h index d808aa213..e5fa4541b 100644 --- a/minix/servers/vm/glo.h +++ b/minix/servers/vm/glo.h @@ -1,3 +1,5 @@ +#ifndef _VM_GLO_H +#define _VM_GLO_H #include #include @@ -19,7 +21,8 @@ EXTERN struct vmproc vmproc[VMP_NR]; long enable_filemap; -EXTERN kinfo_t kernel_boot_info; +typedef kinfo_t ixfer_kinfo_t; +EXTERN ixfer_kinfo_t kernel_boot_info; #if SANITYCHECKS EXTERN int nocheck; @@ -41,3 +44,5 @@ EXTERN mem_type_t mem_type_anon, /* anonymous memory */ /* total number of memory pages */ EXTERN int total_pages; EXTERN int num_vm_instances; + +#endif /* !_VM_GLO_H */ diff --git a/minix/servers/vm/main.c b/minix/servers/vm/main.c index b25a1320f..b6b305698 100644 --- a/minix/servers/vm/main.c +++ b/minix/servers/vm/main.c @@ -262,7 +262,7 @@ static int sef_cb_init_fresh(int type, sef_init_info_t *info) static struct vmproc *init_proc(endpoint_t ep_nr) { - static struct boot_image *ip; + struct boot_image *ip; for (ip = &kernel_boot_info.boot_procs[0]; ip < &kernel_boot_info.boot_procs[NR_BOOT_PROCS]; ip++) { @@ -429,7 +429,7 @@ void init_vm(void) { int s, i; static struct memory mem_chunks[NR_MEMS]; - static struct boot_image *ip; + struct boot_image *ip; extern void __minix_init(void); multiboot_module_t *mod; vir_bytes kern_dyn, kern_static; diff --git a/sys/lib/libsa/subr_prf.c b/sys/lib/libsa/subr_prf.c index d6fc0defc..b43b61146 100644 --- a/sys/lib/libsa/subr_prf.c +++ b/sys/lib/libsa/subr_prf.c @@ -174,6 +174,9 @@ vsnprintf(char *buf, size_t size, const char *fmt, va_list ap) if (sbuf){ /* handle case where sbuf == NULL */ *sbuf = '\0'; } +#if defined(_MINIX_MAGIC) + sbuf = ebuf = NULL; /* leave no dangling pointers */ +#endif return scount; #else /* __minix is not defined */ *sbuf = '\0';