diff options
author | Justus Winter <justus@gnupg.org> | 2017-06-19 21:20:57 +0200 |
---|---|---|
committer | Justus Winter <justus@gnupg.org> | 2017-08-05 18:42:22 +0200 |
commit | 835b293d35a209d38047126443d41fa7090daa4c (patch) | |
tree | 5bf956895e6030f91cd618fb191b2151f6d25423 /fatfs | |
parent | dc0b5a43224999223a246870912b0f292b1980e9 (diff) | |
download | hurd-835b293d35a209d38047126443d41fa7090daa4c.tar.gz hurd-835b293d35a209d38047126443d41fa7090daa4c.tar.bz2 hurd-835b293d35a209d38047126443d41fa7090daa4c.zip |
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 'fatfs')
-rw-r--r-- | fatfs/dir.c | 36 | ||||
-rw-r--r-- | fatfs/fat.c | 28 | ||||
-rw-r--r-- | fatfs/inode.c | 20 | ||||
-rw-r--r-- | fatfs/main.c | 6 | ||||
-rw-r--r-- | fatfs/pager.c | 8 | ||||
-rw-r--r-- | fatfs/virt-inode.c | 8 |
6 files changed, 53 insertions, 53 deletions
diff --git a/fatfs/dir.c b/fatfs/dir.c index b9b7ae55..2679a0ce 100644 --- a/fatfs/dir.c +++ b/fatfs/dir.c @@ -191,7 +191,7 @@ diskfs_lookup_hard (struct node *dp, const char *name, enum lookup_type type, int looped; if ((type == REMOVE) || (type == RENAME)) - assert (npp); + assert_backtrace (npp); if (npp) *npp = 0; @@ -352,7 +352,7 @@ diskfs_lookup_hard (struct node *dp, const char *name, enum lookup_type type, goto out; } else - assert (0); + assert_backtrace (0); } if ((type == CREATE || type == RENAME) && !inum && ds && ds->stat == LOOKING) @@ -383,7 +383,7 @@ diskfs_lookup_hard (struct node *dp, const char *name, enum lookup_type type, if (np) { - assert (npp); + assert_backtrace (npp); if (err) { if (!spec_dotdot) @@ -590,9 +590,9 @@ diskfs_direnter_hard (struct node *dp, const char *name, struct node *np, error_t err; loff_t oldsize = 0; - assert (ds->type == CREATE); + assert_backtrace (ds->type == CREATE); - assert (!diskfs_readonly); + assert_backtrace (!diskfs_readonly); dp->dn_set_mtime = 1; @@ -604,7 +604,7 @@ diskfs_direnter_hard (struct node *dp, const char *name, struct node *np, { case TAKE: /* We are supposed to consume this slot. */ - assert ((char)ds->entry->name[0] == FAT_DIR_NAME_LAST + assert_backtrace ((char)ds->entry->name[0] == FAT_DIR_NAME_LAST || (char)ds->entry->name[0] == FAT_DIR_NAME_DELETED); new = ds->entry; @@ -612,7 +612,7 @@ diskfs_direnter_hard (struct node *dp, const char *name, struct node *np, case EXTEND: /* Extend the file. */ - assert (needed <= bytes_per_cluster); + assert_backtrace (needed <= bytes_per_cluster); oldsize = dp->dn_stat.st_size; while (oldsize + bytes_per_cluster > dp->allocsize) @@ -636,7 +636,7 @@ diskfs_direnter_hard (struct node *dp, const char *name, struct node *np, case SHRINK: case COMPRESS: default: - assert(0); + assert_backtrace (0); /* COMPRESS will be used later, with long filenames, but shrink does not make sense on fat, as all entries have fixed @@ -689,10 +689,10 @@ diskfs_direnter_hard (struct node *dp, const char *name, struct node *np, error_t diskfs_dirremove_hard (struct node *dp, struct dirstat *ds) { - assert (ds->type == REMOVE); - assert (ds->stat == HERE_TIS); + assert_backtrace (ds->type == REMOVE); + assert_backtrace (ds->stat == HERE_TIS); - assert (!diskfs_readonly); + assert_backtrace (!diskfs_readonly); dp->dn_set_mtime = 1; @@ -729,22 +729,22 @@ diskfs_dirrewrite_hard (struct node *dp, struct node *np, struct dirstat *ds) entry_key.dir_inode = dp->cache_id; entry_key.dir_offset = ((int) ds->entry) - ((int) ds->mapbuf); err = vi_rlookup (entry_key, &inode, &vinode, 0); - assert (err != EINVAL); + assert_backtrace (err != EINVAL); if (err) return err; /* Lookup the node, we already have a reference. */ oldnp = diskfs_cached_ifind (inode); - assert (ds->type == RENAME); - assert (ds->stat == HERE_TIS); + assert_backtrace (ds->type == RENAME); + assert_backtrace (ds->stat == HERE_TIS); - assert (!diskfs_readonly); + assert_backtrace (!diskfs_readonly); /* The link count must be 0 so the file will be removed and the node will be dropped. */ oldnp->dn_stat.st_nlink--; - assert (!oldnp->dn_stat.st_nlink); + assert_backtrace (!oldnp->dn_stat.st_nlink); /* Close the file, free the referenced held by clients. */ fshelp_fetch_control (&oldnp->transbox, &control); @@ -784,7 +784,7 @@ diskfs_dirempty (struct node *dp, struct protid *cred) err = vm_map (mach_task_self (), &buf, dp->dn_stat.st_size, 0, 1, memobj, 0, 0, VM_PROT_READ, VM_PROT_READ, 0); mach_port_deallocate (mach_task_self (), memobj); - assert (!err); + assert_backtrace (!err); diskfs_set_node_atime (dp); @@ -817,7 +817,7 @@ diskfs_drop_dirstat (struct node *dp, struct dirstat *ds) { if (ds->type != LOOKUP) { - assert (ds->mapbuf); + assert_backtrace (ds->mapbuf); munmap ((caddr_t) ds->mapbuf, ds->mapextent); ds->type = LOOKUP; } diff --git a/fatfs/fat.c b/fatfs/fat.c index 4c98f623..e191cfc4 100644 --- a/fatfs/fat.c +++ b/fatfs/fat.c @@ -22,7 +22,7 @@ #include <error.h> #include <limits.h> #include <errno.h> -#include <assert.h> +#include <assert-backtrace.h> #include <ctype.h> #include <time.h> @@ -214,7 +214,7 @@ fat_write_next_cluster(cluster_t cluster, cluster_t next_cluster) cluster_t data; /* First data cluster is cluster 2. */ - assert (cluster >= 2 && cluster < nr_of_clusters + 2); + assert_backtrace (cluster >= 2 && cluster < nr_of_clusters + 2); switch (fat_type) { @@ -267,7 +267,7 @@ fat_get_next_cluster(cluster_t cluster, cluster_t *next_cluster) loff_t fat_entry_offset; /* First data cluster is cluster 2. */ - assert (cluster >= 2 && cluster < nr_of_clusters + 2); + assert_backtrace (cluster >= 2 && cluster < nr_of_clusters + 2); switch (fat_type) { @@ -321,7 +321,7 @@ fat_allocate_cluster (cluster_t content, cluster_t *cluster) int wrapped = 0; cluster_t found_cluster = FAT_FREE_CLUSTER; - assert (content != FAT_FREE_CLUSTER); + assert_backtrace (content != FAT_FREE_CLUSTER); pthread_spin_lock (&allocate_free_cluster_lock); old_next_free_cluster = next_free_cluster; @@ -483,17 +483,17 @@ fat_getcluster (struct node *node, cluster_t cluster, int create, return err; if (cluster >= node->dn->length_of_chain) { - assert (!create); + assert_backtrace (!create); return EINVAL; } } chain = node->dn->first; while (chains_to_go--) { - assert (chain); + assert_backtrace (chain); chain = chain->next; } - assert (chain); + assert_backtrace (chain); *disk_cluster = chain->cluster[offs]; return 0; } @@ -508,14 +508,14 @@ fat_truncate_node (struct node *node, cluster_t clusters_to_keep) /* The root dir of a FAT12/16 fs is of fixed size, while the root dir of a FAT32 fs must never decease to exist. */ - assert (! (((fat_type == FAT12 || fat_type == FAT16) && node == diskfs_root_node) + assert_backtrace (! (((fat_type == FAT12 || fat_type == FAT16) && node == diskfs_root_node) || (fat_type == FAT32 && node == diskfs_root_node && clusters_to_keep == 0))); /* Expand the cluster chain, because we have to know the complete tail. */ fat_extend_chain (node, FAT_EOC, 0); if (clusters_to_keep == node->dn->length_of_chain) return; - assert (clusters_to_keep < node->dn->length_of_chain); + assert_backtrace (clusters_to_keep < node->dn->length_of_chain); /* Truncation happens here. */ next = node->dn->first; @@ -532,7 +532,7 @@ fat_truncate_node (struct node *node, cluster_t clusters_to_keep) offs = (clusters_to_keep - 1) & (CLUSTERS_PER_TABLE - 1); while (count-- > 0) { - assert (next); + assert_backtrace (next); /* This cluster is now the last cluster in the chain. */ if (count == 0) @@ -540,7 +540,7 @@ fat_truncate_node (struct node *node, cluster_t clusters_to_keep) next = next->next; } - assert (next); + assert_backtrace (next); fat_write_next_cluster (next->cluster[offs++], FAT_EOC); pos = clusters_to_keep; } @@ -553,7 +553,7 @@ fat_truncate_node (struct node *node, cluster_t clusters_to_keep) { offs = 0; next = next->next; - assert(next); + assert_backtrace (next); } fat_write_next_cluster(next->cluster[offs++], 0); pos++; @@ -567,10 +567,10 @@ fat_truncate_node (struct node *node, cluster_t clusters_to_keep) offs = (clusters_to_keep - 1) & (CLUSTERS_PER_TABLE - 1); while (count-- > 0) { - assert (next); + assert_backtrace (next); next = next->next; } - assert (next); + assert_backtrace (next); next = next->next; } while (next) diff --git a/fatfs/inode.c b/fatfs/inode.c index 4f28d144..e92922f6 100644 --- a/fatfs/inode.c +++ b/fatfs/inode.c @@ -98,7 +98,7 @@ diskfs_node_norefs (struct node *np) if (np->dn->dirnode) diskfs_nrele (np->dn->dirnode); - assert (!np->dn->pager); + assert_backtrace (!np->dn->pager); free (np); } @@ -178,7 +178,7 @@ diskfs_user_read_node (struct node *np, struct lookup_context *ctx) by libdiskfs. The only case it is not locked is for NFS (fsys_getfile) and we disabled that. */ dp = diskfs_cached_ifind (vk.dir_inode); - assert (dp); + assert_backtrace (dp); /* Map in the directory contents. */ memobj = diskfs_get_filemap (dp, prot); @@ -339,13 +339,13 @@ write_node (struct node *np) if (vk.dir_inode == 0 || np == diskfs_root_node) return; - assert (!np->dn_set_ctime && !np->dn_set_atime && !np->dn_set_mtime); + assert_backtrace (!np->dn_set_ctime && !np->dn_set_atime && !np->dn_set_mtime); if (np->dn_stat_dirty) { - assert (!diskfs_readonly); + assert_backtrace (!diskfs_readonly); dp = np->dn->dirnode; - assert (dp); + assert_backtrace (dp); pthread_mutex_lock (&dp->lock); @@ -474,14 +474,14 @@ diskfs_set_translator (struct node *node, const char *name, u_int namelen, struct protid *cred) { - assert (!diskfs_readonly); + assert_backtrace (!diskfs_readonly); return EOPNOTSUPP; } error_t diskfs_get_translator (struct node *node, char **namep, u_int *namelen) { - assert(0); + assert_backtrace (0); } void @@ -503,7 +503,7 @@ diskfs_truncate (struct node *node, loff_t length) loff_t offset; diskfs_check_readonly (); - assert (!diskfs_readonly); + assert_backtrace (!diskfs_readonly); if (length >= node->dn_stat.st_size) return 0; @@ -565,7 +565,7 @@ diskfs_S_file_get_storage_info (struct protid *cred, void diskfs_free_node (struct node *np, mode_t old_mode) { - assert (!diskfs_readonly); + assert_backtrace (!diskfs_readonly); vi_free(np->dn->inode); } @@ -584,7 +584,7 @@ diskfs_alloc_node (struct node *dir, mode_t mode, struct node **node) struct node *np; struct lookup_context ctx = { dir: dir }; - assert (!diskfs_readonly); + assert_backtrace (!diskfs_readonly); /* FIXME: We use a magic key here that signals read_node that we are not entered in any directory yet. */ diff --git a/fatfs/main.c b/fatfs/main.c index 00c56bc5..f0b3aa88 100644 --- a/fatfs/main.c +++ b/fatfs/main.c @@ -189,7 +189,7 @@ fetch_root () break; default: - assert(!"don't know how to set size of root dir"); + assert_backtrace (!"don't know how to set size of root dir"); }; /* The magic vi_key {0, 1} for the root directory is distinguished @@ -197,14 +197,14 @@ fetch_root () normal virtual inode keys (in the dir_inode value). Enter the disknode into the inode table. */ err = vi_new ((struct vi_key) {0, 1}, &inum, &ctx.inode); - assert_perror (err); + assert_perror_backtrace (err); /* Allocate a node for the root directory disknode in diskfs_root_node. */ if (!err) err = diskfs_cached_lookup_context (inum, &diskfs_root_node, &ctx); - assert_perror (err); + assert_perror_backtrace (err); pthread_mutex_unlock (&diskfs_root_node->lock); } diff --git a/fatfs/pager.c b/fatfs/pager.c index bef8dbeb..53b5bbc1 100644 --- a/fatfs/pager.c +++ b/fatfs/pager.c @@ -608,7 +608,7 @@ void pager_notify_evict (struct user_pager_info *pager, vm_offset_t page) { - assert (!"unrequested notification on eviction"); + assert_backtrace (!"unrequested notification on eviction"); } /* Grow the disk allocated to locked node NODE to be at least SIZE @@ -621,7 +621,7 @@ error_t diskfs_grow (struct node *node, loff_t size, struct protid *cred) { diskfs_check_readonly (); - assert (!diskfs_readonly); + assert_backtrace (!diskfs_readonly); if (size > node->allocsize) { @@ -718,7 +718,7 @@ inline error_t pager_report_extent (struct user_pager_info *pager, vm_address_t *offset, vm_size_t *size) { - assert (pager->type == FAT || pager->type == FILE_DATA); + assert_backtrace (pager->type == FAT || pager->type == FILE_DATA); *offset = 0; @@ -815,7 +815,7 @@ diskfs_get_filemap (struct node *node, vm_prot_t prot) { mach_port_t right; - assert (S_ISDIR (node->dn_stat.st_mode) + assert_backtrace (S_ISDIR (node->dn_stat.st_mode) || S_ISREG (node->dn_stat.st_mode) || (S_ISLNK (node->dn_stat.st_mode))); diff --git a/fatfs/virt-inode.c b/fatfs/virt-inode.c index 71381699..7267cbe0 100644 --- a/fatfs/virt-inode.c +++ b/fatfs/virt-inode.c @@ -25,7 +25,7 @@ up-to-date. When a table page can be freed, do so. */ #include <stdlib.h> -#include <assert.h> +#include <assert-backtrace.h> #include <string.h> #include <pthread.h> #include "virt-inode.h" @@ -117,7 +117,7 @@ vi_new(vi_key_t key, ino_t *inode, inode_t *v_inode) { error_t err; - assert (memcmp(&vi_zero_key, &key, sizeof (vi_key_t))); + assert_backtrace (memcmp(&vi_zero_key, &key, sizeof (vi_key_t))); pthread_spin_lock (&inode_table_lock); err = _vi_new(key, inode, v_inode); @@ -171,7 +171,7 @@ vi_rlookup(vi_key_t key, ino_t *inode, inode_t *v_inode, int create) int page = 0; int offset = 0; - assert (memcmp(&vi_zero_key, &key, sizeof (vi_key_t))); + assert_backtrace (memcmp(&vi_zero_key, &key, sizeof (vi_key_t))); pthread_spin_lock (&inode_table_lock); @@ -211,7 +211,7 @@ vi_key_t vi_change(inode_t v_inode, vi_key_t key) { vi_key_t okey = v_inode->key; - assert (memcmp(&vi_zero_key, &key, sizeof (vi_key_t))); + assert_backtrace (memcmp(&vi_zero_key, &key, sizeof (vi_key_t))); v_inode->key = key; return okey; } |