panic() cleanup.

this change
   - makes panic() variadic, doing full printf() formatting -
     no more NO_NUM, and no more separate printf() statements
     needed to print extra info (or something in hex) before panicing
   - unifies panic() - same panic() name and usage for everyone -
     vm, kernel and rest have different names/syntax currently
     in order to implement their own luxuries, but no longer
   - throws out the 1st argument, to make source less noisy.
     the panic() in syslib retrieves the server name from the kernel
     so it should be clear enough who is panicing; e.g.
         panic("sigaction failed: %d", errno);
     looks like:
         at_wini(73130): panic: sigaction failed: 0
         syslib:panic.c: stacktrace: 0x74dc 0x2025 0x100a
   - throws out report() - printf() is more convenient and powerful
   - harmonizes/fixes the use of panic() - there were a few places
     that used printf-style formatting (didn't work) and newlines
     (messes up the formatting) in panic()
   - throws out a few per-server panic() functions
   - cleans up a tie-in of tty with panic()

merging printf() and panic() statements to be done incrementally.
This commit is contained in:
Ben Gras
2010-03-05 15:05:11 +00:00
parent 851dc95566
commit 35a108b911
171 changed files with 1381 additions and 1649 deletions
+4 -6
View File
@@ -79,7 +79,7 @@ int only_search; /* if NO_READ, don't read, else act normal */
}
/* Desired block is not on available chain. Take oldest block ('front'). */
if ((bp = front) == NIL_BUF) panic(__FILE__,"all buffers in use", NR_BUFS);
if ((bp = front) == NIL_BUF) panic("all buffers in use: %d", NR_BUFS);
if(bp->b_bytes < fs_block_size) {
ASSERT(!bp->bp);
@@ -90,7 +90,7 @@ int only_search; /* if NO_READ, don't read, else act normal */
bp && bp->b_bytes < fs_block_size; bp = bp->b_next)
;
if(!bp) {
panic("MFS", "no buffer available", NO_NUM);
panic("no buffer available");
}
} else {
bp->b_bytes = fs_block_size;
@@ -475,13 +475,11 @@ PUBLIC void set_blocksize(int blocksize)
for (bp = &buf[0]; bp < &buf[NR_BUFS]; bp++)
if(bp->b_count != 0)
panic("MFS", "change blocksize with buffer in use",
NO_NUM);
panic("change blocksize with buffer in use");
for (rip = &inode[0]; rip < &inode[NR_INODES]; rip++)
if (rip->i_count > 0)
panic("MFS", "change blocksize with inode in use",
NO_NUM);
panic("change blocksize with inode in use");
fs_sync();
+10 -12
View File
@@ -76,7 +76,7 @@ vir_bytes bytes;
if((*gid=cpf_grant_direct(driver, (vir_bytes) *buf, bytes,
*op == DEV_READ_S?CPF_WRITE:CPF_READ))<0) {
panic(__FILE__,"cpf_grant_magic of buffer failed\n", NO_NUM);
panic("cpf_grant_magic of buffer failed");
}
break;
@@ -89,20 +89,19 @@ vir_bytes bytes;
if((*gid = cpf_grant_direct(driver, (vir_bytes) new_iovec,
bytes * sizeof(iovec_t),
CPF_READ | CPF_WRITE)) < 0) {
panic(__FILE__, "cpf_grant_direct of vector failed", NO_NUM);
panic("cpf_grant_direct of vector failed");
}
v = (iovec_t *) *buf;
/* Grant access to i/o buffers. */
for(j = 0; j < bytes; j++) {
if(j >= NR_IOREQS)
panic(__FILE__, "vec too big", bytes);
panic("vec too big: %d", bytes);
new_iovec[j].iov_addr = gids[j] =
cpf_grant_direct(driver, (vir_bytes) v[j].iov_addr,
v[j].iov_size,
*op == DEV_GATHER_S ? CPF_WRITE : CPF_READ);
if(!GRANT_VALID(gids[j])) {
panic(__FILE__, "mfs: grant to iovec buf failed",
NO_NUM);
panic("mfs: grant to iovec buf failed");
}
new_iovec[j].iov_size = v[j].iov_size;
(*vec_grants)++;
@@ -184,7 +183,7 @@ int flags; /* special flags, like O_NONBLOCK */
/* The io vector copying relies on this I/O being for FS itself. */
if(proc_e != SELF_E) {
printf("MFS(%d) doing block_dev_io for non-self %d\n", SELF_E, proc_e);
panic(__FILE__, "doing block_dev_io for non-self", proc_e);
panic("doing block_dev_io for non-self: %d", proc_e);
}
/* By default, these are right. */
@@ -231,7 +230,7 @@ int flags; /* special flags, like O_NONBLOCK */
return r;
}
else
panic(__FILE__,"call_task: can't send/receive", r);
panic("call_task: can't send/receive: %d", r);
}
else {
/* Did the process we did the sendrec() for get a result? */
@@ -243,7 +242,7 @@ int flags; /* special flags, like O_NONBLOCK */
/* Task has completed. See if call completed. */
if (m.REP_STATUS == SUSPEND) {
panic(__FILE__, "MFS block_dev_io: driver returned SUSPEND", NO_NUM);
panic("MFS block_dev_io: driver returned SUSPEND");
}
if(buf != buf_used && r == OK) {
@@ -271,7 +270,7 @@ int flags; /* mode bits and flags */
major = (dev >> MAJOR) & BYTE;
if (major >= NR_DEVICES) major = 0;
r = gen_opcl(driver_e, DEV_OPEN, dev, proc, flags);
if (r == SUSPEND) panic(__FILE__,"suspend on open from", NO_NUM);
if (r == SUSPEND) panic("suspend on open from");
return(r);
}
@@ -331,8 +330,7 @@ message *mess_ptr; /* pointer to message for task */
if (r != OK) {
if (r == EDEADSRCDST) {
printf("fs: dead driver %d\n", task_nr);
panic(__FILE__, "should handle crashed drivers",
NO_NUM);
panic("should handle crashed drivers");
/* dmap_unmap_by_endpt(task_nr); */
return r;
}
@@ -340,7 +338,7 @@ message *mess_ptr; /* pointer to message for task */
printf("fs: ELOCKED talking to %d\n", task_nr);
return r;
}
panic(__FILE__,"call_task: can't send/receive", r);
panic("call_task: can't send/receive: %d", r);
}
/* Did the process we did the sendrec() for get a result? */
+4 -4
View File
@@ -45,18 +45,18 @@ PUBLIC int fs_putnode()
if(!rip) {
printf("%s:%d put_inode: inode #%d dev: %d not found\n", __FILE__,
__LINE__, fs_m_in.REQ_INODE_NR, fs_dev);
panic(__FILE__, "fs_putnode failed", NO_NUM);
panic("fs_putnode failed");
}
count = fs_m_in.REQ_COUNT;
if (count <= 0) {
printf("%s:%d put_inode: bad value for count: %d\n", __FILE__,
__LINE__, count);
panic(__FILE__, "fs_putnode failed", NO_NUM);
panic("fs_putnode failed");
} else if(count > rip->i_count) {
printf("%s:%d put_inode: count too high: %d > %d\n", __FILE__,
__LINE__, count, rip->i_count);
panic(__FILE__, "fs_putnode failed", NO_NUM);
panic("fs_putnode failed");
}
/* Decrease reference counter, but keep one reference; it will be consumed by
@@ -217,7 +217,7 @@ register struct inode *rip; /* pointer to inode to be released */
if (rip == NIL_INODE) return; /* checking here is easier than in caller */
if (rip->i_count < 1)
panic(__FILE__, "put_inode: i_count already below 1", rip->i_count);
panic("put_inode: i_count already below 1: %d", rip->i_count);
if (--rip->i_count == 0) { /* i_count == 0 means no one is using it now */
if (rip->i_nlinks == 0) {
+1 -1
View File
@@ -657,7 +657,7 @@ off_t len;
if( (b = read_map(rip, pos)) == NO_BLOCK) return;
while (len > 0) {
if( (bp = get_block(rip->i_dev, b, NORMAL)) == NIL_BUF)
panic(__FILE__, "zerozone_range: no block", NO_NUM);
panic("zerozone_range: no block");
offset = pos % block_size;
bytes = block_size - offset;
if (bytes > len)
+2 -2
View File
@@ -122,7 +122,7 @@ PRIVATE int sef_cb_init_fresh(int type, sef_init_info_t *info)
fs_m_in.m_type = FS_READY;
if ((r = send(FS_PROC_NR, &fs_m_in)) != OK) {
panic("MFS", "Error sending login to VFS", r);
panic("Error sending login to VFS: %d", r);
}
return(OK);
@@ -140,7 +140,7 @@ message *m_in; /* pointer to message */
do {
if ((r = sef_receive(ANY, m_in)) != OK) /* wait for message */
panic("MFS","sef_receive failed", r);
panic("sef_receive failed: %d", r);
src = fs_m_in.m_source;
if (src != FS_PROC_NR) {
+1 -1
View File
@@ -166,7 +166,7 @@ PUBLIC int fs_unmount()
if ((root_ip = find_inode(fs_dev, ROOT_INODE)) == NIL_INODE) {
printf("MFS: couldn't find root inode. Unmount failed.\n");
panic(__FILE__, "MFS: couldn't find root inode", EINVAL);
panic("MFS: couldn't find root inode: %d", EINVAL);
return(EINVAL);
}
+2 -2
View File
@@ -160,7 +160,7 @@ PUBLIC int fs_mkdir()
/* It was not possible to enter . or .. probably disk was full -
* links counts haven't been touched. */
if(search_dir(ldirp, lastc, (ino_t *) 0, DELETE, IGN_PERM) != OK)
panic(__FILE__, "Dir disappeared ", rip->i_num);
panic("Dir disappeared: %d", rip->i_num);
rip->i_nlinks--; /* undo the increment done in new_node() */
}
rip->i_dirt = DIRTY; /* either way, i_nlinks has changed */
@@ -232,7 +232,7 @@ PUBLIC int fs_slink()
if(search_dir(ldirp, string, (ino_t *) 0, DELETE,
IGN_PERM) != OK)
panic(__FILE__, "Symbolic link vanished", NO_NUM);
panic("Symbolic link vanished");
}
}
+2 -4
View File
@@ -337,9 +337,7 @@ char *suffix; /* current remaining path. Has to point in the
if (slen > 0) { /* Do we have path after the link? */
/* For simplicity we require that suffix starts with a slash */
if (suffix[0] != '/') {
panic(__FILE__,
"ltraverse: suffix does not start with a slash",
NO_NUM);
panic("ltraverse: suffix does not start with a slash");
}
/* To be able to expand the <link>, we have to move the 'suffix'
@@ -540,7 +538,7 @@ int check_permissions; /* check permissions when flag is !IS_EMPTY */
bp = get_block(ldir_ptr->i_dev, b, NORMAL); /* get a dir block */
if (bp == NO_BLOCK)
panic(__FILE__,"get_block returned NO_BLOCK", NO_NUM);
panic("get_block returned NO_BLOCK");
/* Search a directory block. */
for (dp = &bp->b_dir[0];
+7 -9
View File
@@ -228,7 +228,7 @@ int *completed; /* number of bytes copied */
dev = (dev_t) rip->i_zone[0];
} else {
if (ex64hi(position) != 0)
panic(__FILE__, "rw_chunk: position too high", NO_NUM);
panic("rw_chunk: position too high");
b = read_map(rip, ex64lo(position));
dev = rip->i_dev;
}
@@ -259,7 +259,7 @@ int *completed; /* number of bytes copied */
/* In all cases, bp now points to a valid buffer. */
if (bp == NIL_BUF)
panic(__FILE__,"bp not valid in rw_chunk, this can't happen", NO_NUM);
panic("bp not valid in rw_chunk; this can't happen");
if (rw_flag == WRITING && chunk != block_size && !block_spec &&
ex64lo(position) >= rip->i_size && off == 0) {
@@ -367,7 +367,7 @@ int index; /* index into *bp */
zone_t zone; /* V2 zones are longs (shorts in V1) */
if(bp == NIL_BUF)
panic(__FILE__, "rd_indir() on NIL_BUF", NO_NUM);
panic("rd_indir() on NIL_BUF");
sp = get_super(bp->b_dev); /* need super block to find file sys type */
@@ -381,7 +381,7 @@ int index; /* index into *bp */
(zone < (zone_t) sp->s_firstdatazone || zone >= sp->s_zones)) {
printf("Illegal zone number %ld in indirect block, index %d\n",
(long) zone, index);
panic(__FILE__,"check file system", NO_NUM);
panic("check file system");
}
return(zone);
@@ -576,7 +576,7 @@ PUBLIC int fs_getdents(void)
bp = get_block(rip->i_dev, b, NORMAL); /* get a dir block */
if(bp == NO_BLOCK)
panic(__FILE__,"get_block returned NO_BLOCK", NO_NUM);
panic("get_block returned NO_BLOCK");
/* Search a directory block. */
if (block_pos < pos)
@@ -608,9 +608,7 @@ PUBLIC int fs_getdents(void)
(vir_bytes)getdents_buf,
tmpbuf_off, D);
if (r != OK)
panic(__FILE__,
"fs_getdents: sys_safecopyto failed\n",
r);
panic("fs_getdents: sys_safecopyto failed: %d", r);
userbuf_off += tmpbuf_off;
tmpbuf_off = 0;
@@ -646,7 +644,7 @@ PUBLIC int fs_getdents(void)
r = sys_safecopyto(FS_PROC_NR, gid, userbuf_off,
(vir_bytes) getdents_buf, tmpbuf_off, D);
if (r != OK)
panic(__FILE__, "fs_getdents: sys_safecopyto failed\n", r);
panic("fs_getdents: sys_safecopyto failed: %d", r);
userbuf_off += tmpbuf_off;
}
+7 -8
View File
@@ -40,7 +40,7 @@ bit_t origin; /* number of bit to start searching at */
bit_t i, b;
if (sp->s_rd_only)
panic(__FILE__,"can't allocate bit on read-only filesys.", NO_NUM);
panic("can't allocate bit on read-only filesys");
if (map == IMAP) {
start_block = START_BLOCK;
@@ -113,7 +113,7 @@ bit_t bit_returned; /* number of bit to insert into the map */
block_t start_block;
if (sp->s_rd_only)
panic(__FILE__,"can't free bit on read-only filesys.", NO_NUM);
panic("can't free bit on read-only filesys");
if (map == IMAP) {
start_block = START_BLOCK;
@@ -131,8 +131,7 @@ bit_t bit_returned; /* number of bit to insert into the map */
k = conv2(sp->s_native, (int) bp->b_bitmap[word]);
if (!(k & mask)) {
panic(__FILE__,map == IMAP ? "tried to free unused inode" :
"tried to free unused block", bit_returned);
panic(map == IMAP ? "tried to free unused inode" : "tried to free unused block: %d", bit_returned);
}
k &= ~mask;
@@ -150,10 +149,10 @@ PUBLIC struct super_block *get_super(dev)
dev_t dev; /* device number whose super_block is sought */
{
if (dev == NO_DEV)
panic(__FILE__,"request for super_block of NO_DEV", NO_NUM);
panic("request for super_block of NO_DEV");
if(superblock.s_dev != dev)
panic(__FILE__,"wrong superblock", (int) dev);
panic("wrong superblock: %d", (int) dev);
return(&superblock);
}
@@ -165,7 +164,7 @@ dev_t dev; /* device number whose super_block is sought */
PUBLIC int get_block_size(dev_t dev)
{
if (dev == NO_DEV)
panic(__FILE__,"request for block size of NO_DEV", NO_NUM);
panic("request for block size of NO_DEV");
return(fs_block_size);
@@ -189,7 +188,7 @@ register struct super_block *sp; /* pointer to a superblock */
dev = sp->s_dev; /* save device (will be overwritten by copy) */
if (dev == NO_DEV)
panic(__FILE__,"request for super_block of NO_DEV", NO_NUM);
panic("request for super_block of NO_DEV");
r = block_dev_io(MFS_DEV_READ, dev, SELF_E,
sbbuf, cvu64(SUPER_BLOCK_BYTES), _MIN_BLOCK_SIZE, 0);
+5 -5
View File
@@ -68,10 +68,10 @@ PUBLIC time_t clock_time()
if (use_getuptime2) {
if ( (k=getuptime2(&uptime,&boottime)) != OK)
panic(__FILE__,"clock_time: getuptme2 failed", k);
panic("clock_time: getuptme2 failed: %d", k);
} else {
if ( (k=getuptime(&uptime)) != OK)
panic(__FILE__,"clock_time err", k);
panic("clock_time err: %d", k);
}
return( (time_t) (boottime + (uptime/sys_hz())));
@@ -86,7 +86,7 @@ PUBLIC int mfs_min_f(char *file, int line, int v1, int v2)
if(v1 < 0 || v2 < 0) {
printf("mfs:%s:%d: strange string lengths: %d, %d\n",
file, line, v1, v2);
panic(file, "strange string lengths", NO_NUM);
panic("strange string lengths");
}
if(v2 >= v1) return v1;
@@ -101,7 +101,7 @@ PUBLIC void mfs_nul_f(char *file, int line, char *str, int len, int maxlen)
{
if(len < 1) {
printf("mfs:%s:%d: %d-length string?!\n", file, line, len);
panic(file, "strange string length", NO_NUM);
panic("strange string length");
}
if(len < maxlen && str[len-1] != '\0') {
printf("mfs:%s:%d: string (length %d, maxlen %d) "
@@ -111,7 +111,7 @@ PUBLIC void mfs_nul_f(char *file, int line, char *str, int len, int maxlen)
}
#define MYASSERT(c) if(!(c)) { printf("MFS:%s:%d: sanity check: %s failed\n", \
file, line, #c); panic("MFS", "sanity check " #c " failed", __LINE__); }
file, line, #c); panic("sanity check " #c " failed: %d", __LINE__); }
/*===========================================================================*
+1 -1
View File
@@ -196,7 +196,7 @@ zone_t zone; /* zone to write */
struct super_block *sp;
if(bp == NIL_BUF)
panic(__FILE__, "wr_indir() on NIL_BUF", NO_NUM);
panic("wr_indir() on NIL_BUF");
sp = get_super(bp->b_dev); /* need super block to find file sys type */