summaryrefslogtreecommitdiff
path: root/tmpfs
diff options
context:
space:
mode:
authorJustus Winter <justus@gnupg.org>2017-06-19 21:20:57 +0200
committerJustus Winter <justus@gnupg.org>2017-08-05 18:42:22 +0200
commit835b293d35a209d38047126443d41fa7090daa4c (patch)
tree5bf956895e6030f91cd618fb191b2151f6d25423 /tmpfs
parentdc0b5a43224999223a246870912b0f292b1980e9 (diff)
Use our own variant of 'assert' and 'assert_perror'.
Our variants print stack traces on failures. This will make locating errors much easier.
Diffstat (limited to 'tmpfs')
-rw-r--r--tmpfs/dir.c18
-rw-r--r--tmpfs/node.c28
-rw-r--r--tmpfs/tmpfs.c2
3 files changed, 24 insertions, 24 deletions
diff --git a/tmpfs/dir.c b/tmpfs/dir.c
index 37bb7bff..340a63da 100644
--- a/tmpfs/dir.c
+++ b/tmpfs/dir.c
@@ -44,8 +44,8 @@ diskfs_clear_directory (struct node *dp, struct node *pdp,
{
if (dp->dn->u.dir.entries != 0)
return ENOTEMPTY;
- assert (dp->dn_stat.st_size == 0);
- assert (dp->dn->u.dir.dotdot == pdp->dn);
+ assert_backtrace (dp->dn_stat.st_size == 0);
+ assert_backtrace (dp->dn->u.dir.dotdot == pdp->dn);
/* Decrease hardlink count for parent directory */
pdp->dn_stat.st_nlink--;
@@ -97,7 +97,7 @@ diskfs_get_directs (struct node *dp, int entry, int n,
{
if (dp->dn->u.dir.dotdot == 0)
{
- assert (dp == diskfs_root_node);
+ assert_backtrace (dp == diskfs_root_node);
/* Use something not zero and not an st_ino value for any node in
this filesystem. Since we use pointer values, 2 will never
be a valid number. */
@@ -120,7 +120,7 @@ diskfs_get_directs (struct node *dp, int entry, int n,
if (i < entry)
{
- assert (d == 0);
+ assert_backtrace (d == 0);
*datacnt = 0;
*amt = 0;
return 0;
@@ -177,7 +177,7 @@ diskfs_lookup_hard (struct node *dp,
struct tmpfs_dirent *d, **prevp;
if (type == REMOVE || type == RENAME)
- assert (np);
+ assert_backtrace (np);
if (ds)
ds->dotdot = type & SPEC_DOTDOT;
@@ -196,16 +196,16 @@ diskfs_lookup_hard (struct node *dp,
struct disknode *dddn = dp->dn->u.dir.dotdot;
error_t err;
- assert (np != 0);
+ assert_backtrace (np != 0);
if (dddn == 0) /* root directory */
return EAGAIN;
if (type == (REMOVE|SPEC_DOTDOT) || type == (RENAME|SPEC_DOTDOT))
{
*np = *dddn->hprevp;
- assert (*np);
- assert ((*np)->dn == dddn);
- assert (*dddn->hprevp == *np);
+ assert_backtrace (*np);
+ assert_backtrace ((*np)->dn == dddn);
+ assert_backtrace (*dddn->hprevp == *np);
return 0;
}
else
diff --git a/tmpfs/node.c b/tmpfs/node.c
index 2a4489c2..e93b8794 100644
--- a/tmpfs/node.c
+++ b/tmpfs/node.c
@@ -78,7 +78,7 @@ diskfs_free_node (struct node *np, mode_t mode)
}
break;
case DT_DIR:
- assert (np->dn->u.dir.entries == 0);
+ assert_backtrace (np->dn->u.dir.entries == 0);
break;
case DT_LNK:
free (np->dn->u.lnk);
@@ -122,7 +122,7 @@ diskfs_node_norefs (struct node *np)
switch (np->dn->type)
{
case DT_REG:
- assert (np->allocsize % vm_page_size == 0);
+ assert_backtrace (np->allocsize % vm_page_size == 0);
np->dn->u.reg.allocpages = np->allocsize / vm_page_size;
break;
case DT_CHR:
@@ -170,7 +170,7 @@ diskfs_cached_lookup (ino_t inum, struct node **npp)
struct disknode *dn = (void *) (uintptr_t) inum;
struct node *np;
- assert (npp);
+ assert_backtrace (npp);
pthread_rwlock_rdlock (&all_nodes_lock);
if (dn->hprevp != 0) /* There is already a node. */
@@ -232,8 +232,8 @@ diskfs_cached_lookup (ino_t inum, struct node **npp)
gotit:
np = *dn->hprevp;
- assert (np->dn == dn);
- assert (*dn->hprevp == np);
+ assert_backtrace (np->dn == dn);
+ assert_backtrace (*dn->hprevp == np);
diskfs_nref (np);
pthread_rwlock_unlock (&all_nodes_lock);
pthread_mutex_lock (&np->lock);
@@ -379,7 +379,7 @@ diskfs_set_translator (struct node *np,
static error_t
create_symlink_hook (struct node *np, const char *target)
{
- assert (np->dn->u.lnk == 0);
+ assert_backtrace (np->dn->u.lnk == 0);
np->dn_stat.st_size = strlen (target);
if (np->dn_stat.st_size > 0)
{
@@ -444,7 +444,7 @@ diskfs_truncate (struct node *np, off_t size)
if (np->allocsize <= size)
return 0;
- assert (np->dn->type == DT_REG);
+ assert_backtrace (np->dn->type == DT_REG);
if (default_pager == MACH_PORT_NULL)
return EIO;
@@ -484,7 +484,7 @@ diskfs_truncate (struct node *np, off_t size)
error_t
diskfs_grow (struct node *np, off_t size, struct protid *cred)
{
- assert (np->dn->type == DT_REG);
+ assert_backtrace (np->dn->type == DT_REG);
if (np->allocsize >= size)
return 0;
@@ -548,7 +548,7 @@ diskfs_get_filemap (struct node *np, vm_prot_t prot)
errno = err;
return MACH_PORT_NULL;
}
- assert (np->dn->u.reg.memobj != MACH_PORT_NULL);
+ assert_backtrace (np->dn->u.reg.memobj != MACH_PORT_NULL);
/* XXX we need to keep a reference to the object, or GNU Mach
will terminate it when we release the map. */
@@ -556,7 +556,7 @@ diskfs_get_filemap (struct node *np, vm_prot_t prot)
vm_map (mach_task_self (), &np->dn->u.reg.memref, 4096, 0, 1,
np->dn->u.reg.memobj, 0, 0, VM_PROT_NONE, VM_PROT_NONE,
VM_INHERIT_NONE);
- assert_perror (err);
+ assert_perror_backtrace (err);
}
/* XXX always writable */
@@ -564,7 +564,7 @@ diskfs_get_filemap (struct node *np, vm_prot_t prot)
/* Add a reference for each call, the caller will deallocate it. */
err = mach_port_mod_refs (mach_task_self (), np->dn->u.reg.memobj,
MACH_PORT_RIGHT_SEND, +1);
- assert_perror (err);
+ assert_perror_backtrace (err);
return np->dn->u.reg.memobj;
}
@@ -613,18 +613,18 @@ diskfs_S_file_get_storage_info (struct protid *cred,
if (memobj == MACH_PORT_NULL)
return errno;
- assert (*num_ports >= 1); /* mig always gives us some */
+ assert_backtrace (*num_ports >= 1); /* mig always gives us some */
*num_ports = 1;
*ports_type = MACH_MSG_TYPE_MOVE_SEND;
(*ports)[0]
= (cred->po->openstat & O_RDWR) == O_RDWR ? memobj : MACH_PORT_NULL;
- assert (*num_offsets >= 2); /* mig always gives us some */
+ assert_backtrace (*num_offsets >= 2); /* mig always gives us some */
*num_offsets = 2;
(*offsets)[0] = 0;
(*offsets)[1] = cred->po->np->dn_stat.st_size;
- assert (*num_ints >= 6); /* mig always gives us some */
+ assert_backtrace (*num_ints >= 6); /* mig always gives us some */
*num_ints = 6;
(*ints)[0] = STORAGE_MEMORY;
(*ints)[1] = (cred->po->openstat & O_WRITE) ? 0 : STORE_READONLY;
diff --git a/tmpfs/tmpfs.c b/tmpfs/tmpfs.c
index fd1c9aaf..28151990 100644
--- a/tmpfs/tmpfs.c
+++ b/tmpfs/tmpfs.c
@@ -341,7 +341,7 @@ main (int argc, char **argv)
struct stat st;
err = argp_parse (&startup_argp, argc, argv, ARGP_IN_ORDER, NULL, NULL);
- assert_perror (err);
+ assert_perror_backtrace (err);
task_get_bootstrap_port (mach_task_self (), &bootstrap);
if (bootstrap == MACH_PORT_NULL)