From 835b293d35a209d38047126443d41fa7090daa4c Mon Sep 17 00:00:00 2001 From: Justus Winter Date: Mon, 19 Jun 2017 21:20:57 +0200 Subject: Use our own variant of 'assert' and 'assert_perror'. Our variants print stack traces on failures. This will make locating errors much easier. --- libdiskfs/boot-start.c | 102 +++++++++++++++++++++--------------------- libdiskfs/console.c | 6 +-- libdiskfs/dir-clear.c | 8 ++-- libdiskfs/dir-init.c | 4 +- libdiskfs/dir-link.c | 2 +- libdiskfs/dir-lookup.c | 4 +- libdiskfs/dir-renamed.c | 12 ++--- libdiskfs/disk-pager.c | 10 ++--- libdiskfs/diskfs-pager.h | 2 +- libdiskfs/diskfs.h | 2 +- libdiskfs/file-get-trans.c | 8 ++-- libdiskfs/file-getfh.c | 2 +- libdiskfs/file-set-trans.c | 6 +-- libdiskfs/init-main.c | 4 +- libdiskfs/init-startup.c | 6 +-- libdiskfs/io-map-cntl.c | 2 +- libdiskfs/io-reauthenticate.c | 2 +- libdiskfs/io-write.c | 2 +- libdiskfs/lookup.c | 2 +- libdiskfs/name-cache.c | 4 +- libdiskfs/node-cache.c | 10 ++--- libdiskfs/node-drop.c | 6 +-- libdiskfs/priv.h | 2 +- libdiskfs/protid-make.c | 6 +-- libdiskfs/rdwr-internal.c | 2 +- libdiskfs/trans-callback.c | 2 +- 26 files changed, 109 insertions(+), 109 deletions(-) (limited to 'libdiskfs') diff --git a/libdiskfs/boot-start.c b/libdiskfs/boot-start.c index f048badf..d0044478 100644 --- a/libdiskfs/boot-start.c +++ b/libdiskfs/boot-start.c @@ -73,18 +73,18 @@ get_console () void _diskfs_boot_privports (void) { - assert (diskfs_boot_filesystem ()); + assert_backtrace (diskfs_boot_filesystem ()); if (_hurd_host_priv == MACH_PORT_NULL) { /* We are the boot command run by the real bootstrap filesystem. We get the privileged ports from it as init would. */ mach_port_t bootstrap; error_t err = task_get_bootstrap_port (mach_task_self (), &bootstrap); - assert_perror (err); + assert_perror_backtrace (err); err = fsys_getpriv (bootstrap, &_hurd_host_priv, &_hurd_device_master, &parent_task); mach_port_deallocate (mach_task_self (), bootstrap); - assert_perror (err); + assert_perror_backtrace (err); } } @@ -113,10 +113,10 @@ diskfs_start_bootstrap () /* Create the port for current and root directory. */ err = diskfs_make_peropen (diskfs_root_node, O_READ | O_EXEC, 0, &rootpo); - assert_perror (err); + assert_perror_backtrace (err); err = diskfs_create_protid (rootpo, 0, &rootpi); - assert_perror (err); + assert_perror_backtrace (err); /* Get us a send right to copy around. */ root_pt = ports_get_send_right (rootpi); @@ -128,8 +128,8 @@ diskfs_start_bootstrap () Our parent (the real bootstrap filesystem) provides us a root directory where we look up /servers/exec like any non-bootstrap filesystem would. */ - assert (_hurd_ports); - assert (_hurd_ports[INIT_PORT_CRDIR].port != MACH_PORT_NULL); + assert_backtrace (_hurd_ports); + assert_backtrace (_hurd_ports[INIT_PORT_CRDIR].port != MACH_PORT_NULL); diskfs_exec = file_name_lookup (_SERVERS_EXEC, 0, 0); if (diskfs_exec == MACH_PORT_NULL) error (1, errno, "%s", _SERVERS_EXEC); @@ -139,7 +139,7 @@ diskfs_start_bootstrap () /* Make sure this is really a port to another server. */ struct port_info *pi = ports_lookup_port (diskfs_port_bucket, diskfs_exec, 0); - assert (!pi); + assert_backtrace (!pi); #endif } @@ -165,16 +165,16 @@ diskfs_start_bootstrap () start_execserver (); pthread_cond_wait (&execstarted, &execstartlock); pthread_mutex_unlock (&execstartlock); - assert (diskfs_exec_ctl != MACH_PORT_NULL); + assert_backtrace (diskfs_exec_ctl != MACH_PORT_NULL); /* Contact the exec server. */ err = fsys_getroot (diskfs_exec_ctl, root_pt, MACH_MSG_TYPE_COPY_SEND, idlist, 3, idlist, 3, 0, &retry, retry_name, &diskfs_exec); - assert_perror (err); - assert (retry == FS_RETRY_NORMAL); - assert (retry_name[0] == '\0'); - assert (diskfs_exec != MACH_PORT_NULL); + assert_perror_backtrace (err); + assert_backtrace (retry == FS_RETRY_NORMAL); + assert_backtrace (retry_name[0] == '\0'); + assert_backtrace (diskfs_exec != MACH_PORT_NULL); /* Attempt to set the active translator for the exec server so that filesystems other than the bootstrap can find it. */ @@ -187,14 +187,14 @@ diskfs_start_bootstrap () } else { - assert (retry == FS_RETRY_NORMAL); - assert (retry_name[0] == '\0'); - assert (execnode != MACH_PORT_NULL); + assert_backtrace (retry == FS_RETRY_NORMAL); + assert_backtrace (retry_name[0] == '\0'); + assert_backtrace (execnode != MACH_PORT_NULL); err = file_set_translator (execnode, 0, FS_TRANS_SET, 0, 0, 0, diskfs_exec_ctl, MACH_MSG_TYPE_COPY_SEND); mach_port_deallocate (mach_task_self (), diskfs_exec_ctl); mach_port_deallocate (mach_task_self (), execnode); - assert_perror (err); + assert_perror_backtrace (err); } diskfs_exec_ctl = MACH_PORT_NULL; /* Not used after this. */ } @@ -206,7 +206,7 @@ diskfs_start_bootstrap () { /* We have a boot command line to run instead of init. */ err = argz_create (_diskfs_boot_command, &exec_argv, &exec_argvlen); - assert_perror (err); + assert_perror_backtrace (err); } else { @@ -216,11 +216,11 @@ diskfs_start_bootstrap () initname++; int len = asprintf (&exec_argv, "/%s%c", initname, '\0'); - assert (len != -1); + assert_backtrace (len != -1); exec_argvlen = (size_t) len; err = argz_add_sep (&exec_argv, &exec_argvlen, diskfs_boot_command_line, ' '); - assert_perror (err); + assert_perror_backtrace (err); } err = task_create (mach_task_self (), @@ -228,7 +228,7 @@ diskfs_start_bootstrap () NULL, 0, /* OSF Mach */ #endif 0, &newt); - assert_perror (err); + assert_perror_backtrace (err); if (MACH_PORT_VALID (diskfs_kernel_task)) { @@ -246,11 +246,11 @@ diskfs_start_bootstrap () diskfs_kernel_task = MACH_PORT_NULL; len = snprintf (buf, sizeof buf, "--kernel-task=%d", kernel_task_name); - assert (len < sizeof buf); + assert_backtrace (len < sizeof buf); /* Insert as second argument. */ err = argz_insert (&exec_argv, &exec_argvlen, argz_next (exec_argv, exec_argvlen, exec_argv), buf); - assert_perror (err); + assert_perror_backtrace (err); } initname = exec_argv; @@ -267,11 +267,11 @@ diskfs_start_bootstrap () initname, strerror (err)); fflush (stdout); free (exec_argv); - assert_perror (err); /* XXX this won't reboot properly */ + assert_perror_backtrace (err); /* XXX this won't reboot properly */ } else if (retry == FS_RETRY_MAGICAL && pathbuf[0] == '/') { - assert (sysconf (_SC_SYMLOOP_MAX) < 0 || + assert_backtrace (sysconf (_SC_SYMLOOP_MAX) < 0 || init_lookups < sysconf (_SC_SYMLOOP_MAX)); /* INITNAME is a symlink with an absolute target, so try again. */ @@ -279,12 +279,12 @@ diskfs_start_bootstrap () goto lookup_init; } - assert (retry == FS_RETRY_NORMAL); - assert (pathbuf[0] == '\0'); + assert_backtrace (retry == FS_RETRY_NORMAL); + assert_backtrace (pathbuf[0] == '\0'); err = ports_create_port (diskfs_initboot_class, diskfs_port_bucket, sizeof (struct port_info), &bootinfo); - assert_perror (err); + assert_perror_backtrace (err); bootpt = ports_get_send_right (bootinfo); ports_port_deref (bootinfo); @@ -298,7 +298,7 @@ diskfs_start_bootstrap () fdarray[0] = fdarray[1] = fdarray[2] = get_console (); /* XXX */ err = argz_create (environ, &exec_env, &exec_envlen); - assert_perror (err); + assert_perror_backtrace (err); if (_diskfs_boot_pause) { @@ -383,10 +383,10 @@ diskfs_S_exec_startup_get_info (struct bootinfo *upt, *intarraylen = 0; err = diskfs_make_peropen (diskfs_root_node, O_READ | O_EXEC, 0, &rootpo); - assert_perror (err); + assert_perror_backtrace (err); err = diskfs_create_protid (rootpo, 0, &rootpi); - assert_perror (err); + assert_perror_backtrace (err); rootport = ports_get_right (rootpi); ports_port_deref (rootpi); @@ -425,17 +425,17 @@ diskfs_execboot_fsys_startup (mach_port_t port, int flags, return EOPNOTSUPP; err = diskfs_make_peropen (diskfs_root_node, flags, 0, &rootpo); - assert_perror (err); + assert_perror_backtrace (err); err = diskfs_create_protid (rootpo, 0, &rootpi); - assert_perror (err); + assert_perror_backtrace (err); rootport = ports_get_send_right (rootpi); ports_port_deref (rootpi); err = dir_lookup (rootport, _SERVERS_EXEC, flags|O_NOTRANS, 0, &retry, pathbuf, real); - assert_perror (err); - assert (retry == FS_RETRY_NORMAL); - assert (pathbuf[0] == '\0'); + assert_perror_backtrace (err); + assert_backtrace (retry == FS_RETRY_NORMAL); + assert_backtrace (pathbuf[0] == '\0'); *realpoly = MACH_MSG_TYPE_MOVE_SEND; mach_port_deallocate (mach_task_self (), rootport); @@ -506,10 +506,10 @@ diskfs_S_fsys_init (struct diskfs_control *pt, for the library itself. */ err = mach_port_mod_refs (mach_task_self (), procserver, MACH_PORT_RIGHT_SEND, +1); - assert_perror (err); + assert_perror_backtrace (err); err = mach_port_mod_refs (mach_task_self (), authhandle, MACH_PORT_RIGHT_SEND, +1); - assert_perror (err); + assert_perror_backtrace (err); if (diskfs_auth_server_port != MACH_PORT_NULL) mach_port_deallocate (mach_task_self (), diskfs_auth_server_port); @@ -519,7 +519,7 @@ diskfs_S_fsys_init (struct diskfs_control *pt, { process_t execprocess; err = proc_task2proc (procserver, diskfs_exec_server_task, &execprocess); - assert_perror (err); + assert_perror_backtrace (err); /* Declare that the exec server is our child. */ proc_child (procserver, diskfs_exec_server_task); @@ -541,7 +541,7 @@ diskfs_S_fsys_init (struct diskfs_control *pt, mach_port_t bootstrap; process_t parent_proc; - assert (parent_task != MACH_PORT_NULL); + assert_backtrace (parent_task != MACH_PORT_NULL); /* Tell the proc server that our parent task is our child. This makes the process hierarchy fail to represent the real order of @@ -553,12 +553,12 @@ diskfs_S_fsys_init (struct diskfs_control *pt, we send it fsys_init (below). */ err = proc_child (procserver, parent_task); - assert_perror (err); + assert_perror_backtrace (err); /* Get the parent's proc server port so we can send it in the fsys_init RPC just as init would. */ err = proc_task2proc (procserver, parent_task, &parent_proc); - assert_perror (err); + assert_perror_backtrace (err); /* We don't need this anymore. */ mach_port_deallocate (mach_task_self (), parent_task); @@ -569,20 +569,20 @@ diskfs_S_fsys_init (struct diskfs_control *pt, /* Give our parent (the real bootstrap filesystem) an fsys_init RPC of its own, as init would have sent it. */ err = task_get_bootstrap_port (mach_task_self (), &bootstrap); - assert_perror (err); + assert_perror_backtrace (err); err = fsys_init (bootstrap, parent_proc, MACH_MSG_TYPE_COPY_SEND, authhandle); mach_port_deallocate (mach_task_self (), parent_proc); mach_port_deallocate (mach_task_self (), bootstrap); - assert_perror (err); + assert_perror_backtrace (err); } /* Get a port to the root directory to put in the library's data structures. */ err = diskfs_make_peropen (diskfs_root_node, O_READ|O_EXEC, 0, &rootpo); - assert_perror (err); + assert_perror_backtrace (err); err = diskfs_create_protid (rootpo, 0, &rootpi); - assert_perror (err); + assert_perror_backtrace (err); root_pt = ports_get_send_right (rootpi); ports_port_deref (rootpi); @@ -656,17 +656,17 @@ start_execserver (void) extern task_t diskfs_exec_server_task; /* Set in opts-std-startup.c. */ struct port_info *execboot_info; - assert (diskfs_exec_server_task != MACH_PORT_NULL); + assert_backtrace (diskfs_exec_server_task != MACH_PORT_NULL); err = ports_create_port (diskfs_execboot_class, diskfs_port_bucket, sizeof (struct port_info), &execboot_info); - assert_perror (err); + assert_perror_backtrace (err); right = ports_get_send_right (execboot_info); ports_port_deref (execboot_info); err = task_set_special_port (diskfs_exec_server_task, TASK_BOOTSTRAP_PORT, right); - assert_perror (err); + assert_perror_backtrace (err); err = mach_port_deallocate (mach_task_self (), right); - assert_perror (err); + assert_perror_backtrace (err); if (_diskfs_boot_pause) { @@ -675,7 +675,7 @@ start_execserver (void) getc (stdin); } err = task_resume (diskfs_exec_server_task); - assert_perror (err); + assert_perror_backtrace (err); printf (" exec"); fflush (stdout); diff --git a/libdiskfs/console.c b/libdiskfs/console.c index a4c3a1af..74715b8b 100644 --- a/libdiskfs/console.c +++ b/libdiskfs/console.c @@ -24,7 +24,7 @@ #include #include #include -#include +#include #include #include @@ -60,10 +60,10 @@ diskfs_console_stdio () if (diskfs_boot_filesystem ()) _diskfs_boot_privports (); err = get_privileged_ports (NULL, &dev); - assert_perror (err); + assert_perror_backtrace (err); err = device_open (dev, D_READ|D_WRITE, "console", &cons); mach_port_deallocate (mach_task_self (), dev); - assert_perror (err); + assert_perror_backtrace (err); stdin = mach_open_devstream (cons, "r"); stdout = stderr = mach_open_devstream (cons, "w"); mach_port_deallocate (mach_task_self (), cons); diff --git a/libdiskfs/dir-clear.c b/libdiskfs/dir-clear.c index 7cf32358..02a800ed 100644 --- a/libdiskfs/dir-clear.c +++ b/libdiskfs/dir-clear.c @@ -31,10 +31,10 @@ diskfs_clear_directory (struct node *dp, /* Find and remove the `.' entry. */ err = diskfs_lookup (dp, ".", REMOVE, &np, ds, cred); - assert (err != ENOENT); + assert_backtrace (err != ENOENT); if (!err) { - assert (np == dp); + assert_backtrace (np == dp); err = diskfs_dirremove (dp, np, ".", ds); diskfs_nrele (np); } @@ -49,10 +49,10 @@ diskfs_clear_directory (struct node *dp, /* Find and remove the `..' entry. */ err = diskfs_lookup (dp, "..", REMOVE | SPEC_DOTDOT, &np, ds, cred); - assert (err != ENOENT); + assert_backtrace (err != ENOENT); if (!err) { - assert (np == pdp); + assert_backtrace (np == pdp); err = diskfs_dirremove (dp, np, "..", ds); } else diff --git a/libdiskfs/dir-init.c b/libdiskfs/dir-init.c index 8301ca1b..a085a00a 100644 --- a/libdiskfs/dir-init.c +++ b/libdiskfs/dir-init.c @@ -43,7 +43,7 @@ diskfs_init_dir (struct node *dp, struct node *pdp, struct protid *cred) dp->dn_stat.st_nlink++; /* for `.' */ dp->dn_set_ctime = 1; err = diskfs_lookup (dp, ".", CREATE, &foo, ds, &lookupcred); - assert (err == ENOENT); + assert_backtrace (err == ENOENT); err = diskfs_direnter (dp, ".", dp, ds, cred); if (err) { @@ -55,7 +55,7 @@ diskfs_init_dir (struct node *dp, struct node *pdp, struct protid *cred) pdp->dn_stat.st_nlink++; /* for `..' */ pdp->dn_set_ctime = 1; err = diskfs_lookup (dp, "..", CREATE, &foo, ds, &lookupcred); - assert (err == ENOENT); + assert_backtrace (err == ENOENT); err = diskfs_direnter (dp, "..", pdp, ds, cred); if (err) { diff --git a/libdiskfs/dir-link.c b/libdiskfs/dir-link.c index ca5dd561..403e9d5c 100644 --- a/libdiskfs/dir-link.c +++ b/libdiskfs/dir-link.c @@ -106,7 +106,7 @@ diskfs_S_dir_link (struct protid *dircred, /* Attach it */ if (tnp) { - assert (!excl); + assert_backtrace (!excl); err = diskfs_dirrewrite (dnp, tnp, np, name, ds); if (!err) { diff --git a/libdiskfs/dir-lookup.c b/libdiskfs/dir-lookup.c index 8b43e27b..3c7198fb 100644 --- a/libdiskfs/dir-lookup.c +++ b/libdiskfs/dir-lookup.c @@ -100,7 +100,7 @@ diskfs_S_dir_lookup (struct protid *dircred, do { - assert (!lastcomp); + assert_backtrace (!lastcomp); /* Find the name of the next pathname component */ nextname = index (filename, '/'); @@ -377,7 +377,7 @@ diskfs_S_dir_lookup (struct protid *dircred, 0, np->dn_stat.st_size, 0, dircred, &amt); if (!err) - assert (amt == np->dn_stat.st_size); + assert_backtrace (amt == np->dn_stat.st_size); } if (err) goto out; diff --git a/libdiskfs/dir-renamed.c b/libdiskfs/dir-renamed.c index a4878f3d..772258d2 100644 --- a/libdiskfs/dir-renamed.c +++ b/libdiskfs/dir-renamed.c @@ -93,7 +93,7 @@ diskfs_rename_dir (struct node *fdp, struct node *fnp, const char *fromname, /* 1: Lookup target; if it exists, make sure it's an empty directory. */ ds = buf; err = diskfs_lookup (tdp, toname, RENAME, &tnp, ds, tocred); - assert (err != EAGAIN); /* <-> assert (TONAME != "..") */ + assert_backtrace (err != EAGAIN); /* <-> assert_backtrace (TONAME != "..") */ if (err && err != ENOENT) goto out; @@ -110,7 +110,7 @@ diskfs_rename_dir (struct node *fdp, struct node *fnp, const char *fromname, /* Check permissions to remove FROMNAME and lock FNP. */ tmpds = alloca (diskfs_dirstat_size); err = diskfs_lookup (fdp, fromname, REMOVE, &tmpnp, tmpds, fromcred); - assert (!tmpnp || tmpnp == fnp); + assert_backtrace (!tmpnp || tmpnp == fnp); if (tmpnp) diskfs_nrele (tmpnp); diskfs_drop_dirstat (fdp, tmpds); @@ -144,13 +144,13 @@ diskfs_rename_dir (struct node *fdp, struct node *fnp, const char *fromname, tmpds = alloca (diskfs_dirstat_size); err = diskfs_lookup (fnp, "..", RENAME | SPEC_DOTDOT, &tmpnp, tmpds, fromcred); - assert (err != ENOENT); + assert_backtrace (err != ENOENT); if (err) { diskfs_drop_dirstat (fnp, tmpds); goto out; } - assert (tmpnp == fdp); + assert_backtrace (tmpnp == fdp); err = diskfs_dirrewrite (fnp, fdp, tdp, "..", tmpds); if (diskfs_synchronous) @@ -207,12 +207,12 @@ diskfs_rename_dir (struct node *fdp, struct node *fnp, const char *fromname, ds = buf; pthread_mutex_unlock (&fnp->lock); err = diskfs_lookup (fdp, fromname, REMOVE, &tmpnp, ds, fromcred); - assert (!tmpnp || tmpnp == fnp); + assert_backtrace (!tmpnp || tmpnp == fnp); if (tmpnp) diskfs_nrele (tmpnp); if (err) { - assert (!tmpnp); + assert_backtrace (!tmpnp); /* diskfs_lookup has not locked fnp then, do not unlock it. */ fnp = NULL; goto out; diff --git a/libdiskfs/disk-pager.c b/libdiskfs/disk-pager.c index 434ceed9..1a5d8bf2 100644 --- a/libdiskfs/disk-pager.c +++ b/libdiskfs/disk-pager.c @@ -93,10 +93,10 @@ fault_handler (int sig, long int sigcode, struct sigcontext *scp) sig, sigcode, preemptor.first, preemptor.last, scp->sc_pc, scp->sc_error); - assert (scp->sc_error == EKERN_MEMORY_ERROR); + assert_backtrace (scp->sc_error == EKERN_MEMORY_ERROR); err = pager_get_error (diskfs_disk_pager, sigcode); - assert (err); - assert_perror (err); + assert_backtrace (err); + assert_perror_backtrace (err); } #endif @@ -104,9 +104,9 @@ fault_handler (int sig, long int sigcode, struct sigcontext *scp) diskfs_exception_diu = NULL; /* Fetch the error code from the pager. */ - assert (scp->sc_error == EKERN_MEMORY_ERROR); + assert_backtrace (scp->sc_error == EKERN_MEMORY_ERROR); err = pager_get_error (diskfs_disk_pager, sigcode); - assert (err); + assert_backtrace (err); /* Make `diskfault_catch' return the error code. */ longjmp (diskfs_exception_diu->env, err); diff --git a/libdiskfs/diskfs-pager.h b/libdiskfs/diskfs-pager.h index 550ca644..e8227413 100644 --- a/libdiskfs/diskfs-pager.h +++ b/libdiskfs/diskfs-pager.h @@ -24,7 +24,7 @@ #include #include #include -#include +#include #include extern __thread struct disk_image_user *diskfs_exception_diu; diff --git a/libdiskfs/diskfs.h b/libdiskfs/diskfs.h index 106aeb06..ea79a1d2 100644 --- a/libdiskfs/diskfs.h +++ b/libdiskfs/diskfs.h @@ -20,7 +20,7 @@ #ifndef _HURD_DISKFS #define _HURD_DISKFS -#include +#include #include #include #include diff --git a/libdiskfs/file-get-trans.c b/libdiskfs/file-get-trans.c index e6e994df..be07605c 100644 --- a/libdiskfs/file-get-trans.c +++ b/libdiskfs/file-get-trans.c @@ -42,7 +42,7 @@ diskfs_S_file_get_translator (struct protid *cred, { unsigned int len = sizeof _HURD_SYMLINK + np->dn_stat.st_size + 1; size_t amt; - assert (diskfs_shortcut_symlink); + assert_backtrace (diskfs_shortcut_symlink); if (len > *translen) *trans = mmap (0, len, PROT_READ|PROT_WRITE, MAP_ANON, 0, 0); memcpy (*trans, _HURD_SYMLINK, sizeof _HURD_SYMLINK); @@ -55,7 +55,7 @@ diskfs_S_file_get_translator (struct protid *cred, err = diskfs_node_rdwr (np, *trans + sizeof _HURD_SYMLINK, 0, np->dn_stat.st_size, 0, cred, &amt); if (!err) - assert (amt == np->dn_stat.st_size); + assert_backtrace (amt == np->dn_stat.st_size); } if (!err) { @@ -71,9 +71,9 @@ diskfs_S_file_get_translator (struct protid *cred, unsigned int buflen; if (S_ISCHR (np->dn_stat.st_mode)) - assert (diskfs_shortcut_chrdev); + assert_backtrace (diskfs_shortcut_chrdev); else - assert (diskfs_shortcut_blkdev); + assert_backtrace (diskfs_shortcut_blkdev); buflen = asprintf (&buf, "%s%c%d%c%d", (S_ISCHR (np->dn_stat.st_mode) diff --git a/libdiskfs/file-getfh.c b/libdiskfs/file-getfh.c index e4bc8921..ce5c1998 100644 --- a/libdiskfs/file-getfh.c +++ b/libdiskfs/file-getfh.c @@ -37,7 +37,7 @@ diskfs_S_file_getfh (struct protid *cred, char **fh, size_t *fh_len) if (! idvec_contains (cred->user->uids, 0)) return EPERM; - assert (sizeof *f == sizeof f->bytes); + assert_backtrace (sizeof *f == sizeof f->bytes); node = cred->po->np; diff --git a/libdiskfs/file-set-trans.c b/libdiskfs/file-set-trans.c index 3238037a..6a73e23c 100644 --- a/libdiskfs/file-set-trans.c +++ b/libdiskfs/file-set-trans.c @@ -141,7 +141,7 @@ diskfs_S_file_set_translator (struct protid *cred, char *arg; arg = passive + strlen (passive) + 1; - assert (arg <= passive + passivelen); + assert_backtrace (arg <= passive + passivelen); if (arg == passive + passivelen) { pthread_mutex_unlock (&np->lock); @@ -150,7 +150,7 @@ diskfs_S_file_set_translator (struct protid *cred, major = strtol (arg, 0, 0); arg = arg + strlen (arg) + 1; - assert (arg < passive + passivelen); + assert_backtrace (arg < passive + passivelen); if (arg == passive + passivelen) { pthread_mutex_unlock (&np->lock); @@ -185,7 +185,7 @@ diskfs_S_file_set_translator (struct protid *cred, if (newmode == S_IFLNK) { char *arg = passive + strlen (passive) + 1; - assert (arg <= passive + passivelen); + assert_backtrace (arg <= passive + passivelen); if (arg == passive + passivelen) { pthread_mutex_unlock (&np->lock); diff --git a/libdiskfs/init-main.c b/libdiskfs/init-main.c index 3e03ae4e..5c29b7b8 100644 --- a/libdiskfs/init-main.c +++ b/libdiskfs/init-main.c @@ -19,7 +19,7 @@ #include "diskfs.h" #include -#include +#include #include #include @@ -37,7 +37,7 @@ diskfs_init_main (struct argp *startup_argp, err = argp_parse (startup_argp ?: &diskfs_store_startup_argp, argc, argv, ARGP_IN_ORDER, NULL, &store_params); - assert_perror (err); + assert_perror_backtrace (err); *store_parsed = store_params.result; err = store_parsed_name (*store_parsed, &diskfs_disk_name); diff --git a/libdiskfs/init-startup.c b/libdiskfs/init-startup.c index c1407ed4..a2e3638d 100644 --- a/libdiskfs/init-startup.c +++ b/libdiskfs/init-startup.c @@ -56,9 +56,9 @@ diskfs_startup_diskfs (mach_port_t bootstrap, int flags) /* Create a protid we can use in diskfs_lookup. */ err = diskfs_make_peropen (diskfs_root_node, O_READ|O_EXEC, 0, &rootpo); - assert_perror (err); + assert_perror_backtrace (err); err = diskfs_create_protid (rootpo, 0, &rootpi); - assert_perror (err); + assert_perror_backtrace (err); /* Look up the directory name. */ err = diskfs_lookup (diskfs_root_node, _diskfs_chroot_directory, @@ -185,7 +185,7 @@ _diskfs_init_completed () If we get an error, print an informational message. */ proc = getproc (); - assert (proc); + assert_backtrace (proc); err = ports_create_port (diskfs_shutdown_notification_class, diskfs_port_bucket, sizeof (struct port_info), diff --git a/libdiskfs/io-map-cntl.c b/libdiskfs/io-map-cntl.c index 2e9b9e98..4a9b1f61 100644 --- a/libdiskfs/io-map-cntl.c +++ b/libdiskfs/io-map-cntl.c @@ -28,7 +28,7 @@ diskfs_S_io_map_cntl (struct protid *cred, if (!cred) return EOPNOTSUPP; - assert (__vm_page_size >= sizeof (struct shared_io)); + assert_backtrace (__vm_page_size >= sizeof (struct shared_io)); pthread_mutex_lock (&cred->po->np->lock); if (!cred->mapped) { diff --git a/libdiskfs/io-reauthenticate.c b/libdiskfs/io-reauthenticate.c index 985db498..1b88a3b2 100644 --- a/libdiskfs/io-reauthenticate.c +++ b/libdiskfs/io-reauthenticate.c @@ -47,7 +47,7 @@ diskfs_S_io_reauthenticate (struct protid *cred, } newright = ports_get_send_right (newcred); - assert (newright != MACH_PORT_NULL); + assert_backtrace (newright != MACH_PORT_NULL); /* Release the node lock while blocking on the auth server and client. */ pthread_mutex_unlock (&cred->po->np->lock); diff --git a/libdiskfs/io-write.c b/libdiskfs/io-write.c index 2967c4c8..f3e191b6 100644 --- a/libdiskfs/io-write.c +++ b/libdiskfs/io-write.c @@ -40,7 +40,7 @@ diskfs_S_io_write (struct protid *cred, pthread_mutex_lock (&np->lock); - assert (!S_ISDIR(np->dn_stat.st_mode)); + assert_backtrace (!S_ISDIR(np->dn_stat.st_mode)); iohelp_get_conch (&np->conch); diff --git a/libdiskfs/lookup.c b/libdiskfs/lookup.c index 486fedce..b6193657 100644 --- a/libdiskfs/lookup.c +++ b/libdiskfs/lookup.c @@ -78,7 +78,7 @@ diskfs_lookup (struct node *dp, const char *name, enum lookup_type type, struct node *cached; if (type == REMOVE || type == RENAME) - assert (np); + assert_backtrace (np); if (!S_ISDIR (dp->dn_stat.st_mode)) { diff --git a/libdiskfs/name-cache.c b/libdiskfs/name-cache.c index 53935ab3..99591754 100644 --- a/libdiskfs/name-cache.c +++ b/libdiskfs/name-cache.c @@ -20,7 +20,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. */ #include "priv.h" -#include +#include #include #include @@ -93,7 +93,7 @@ add_entry (struct cache_bucket *b, int i, free (charp (b->name[i])); b->name[i] = (unsigned long) strdup (name); - assert ((b->name[i] & 3) == 0); + assert_backtrace ((b->name[i] & 3) == 0); if (b->name[i] == 0) return; diff --git a/libdiskfs/node-cache.c b/libdiskfs/node-cache.c index ee7e6fdb..d2815883 100644 --- a/libdiskfs/node-cache.c +++ b/libdiskfs/node-cache.c @@ -105,7 +105,7 @@ diskfs_cached_lookup_context (ino_t inum, struct node **npp, err = hurd_ihash_locp_add (&nodecache, slot, (hurd_ihash_key_t) &np->cache_id, np); - assert_perror (err); + assert_perror_backtrace (err); diskfs_nref_light (np); pthread_rwlock_unlock (&nodecache_lock); @@ -138,7 +138,7 @@ diskfs_cached_ifind (ino_t inum) np = hurd_ihash_find (&nodecache, (hurd_ihash_key_t) &inum); pthread_rwlock_unlock (&nodecache_lock); - assert (np); + assert_backtrace (np); return np; } @@ -233,7 +233,7 @@ diskfs_node_iterate (error_t (*fun)(struct node *)) error_t __attribute__ ((weak)) diskfs_user_make_node (struct node **npp, struct lookup_context *ctx) { - assert (! "diskfs_user_make_node not implemented"); + assert_backtrace (! "diskfs_user_make_node not implemented"); } /* The user must define this function if she wants to use the node @@ -241,7 +241,7 @@ diskfs_user_make_node (struct node **npp, struct lookup_context *ctx) error_t __attribute__ ((weak)) diskfs_user_read_node (struct node *np, struct lookup_context *ctx) { - assert (! "diskfs_user_read_node not implemented"); + assert_backtrace (! "diskfs_user_read_node not implemented"); } /* The user must define this function if she wants to use the node @@ -250,5 +250,5 @@ diskfs_user_read_node (struct node *np, struct lookup_context *ctx) void __attribute__ ((weak)) diskfs_user_try_dropping_softrefs (struct node *np) { - assert (! "diskfs_user_try_dropping_softrefs not implemented"); + assert_backtrace (! "diskfs_user_try_dropping_softrefs not implemented"); } diff --git a/libdiskfs/node-drop.c b/libdiskfs/node-drop.c index 455031bc..aa00cf05 100644 --- a/libdiskfs/node-drop.c +++ b/libdiskfs/node-drop.c @@ -41,7 +41,7 @@ diskfs_drop_node (struct node *np) if (np->dn_stat.st_nlink == 0) { diskfs_check_readonly (); - assert (!diskfs_readonly); + assert_backtrace (!diskfs_readonly); if (np->dn_stat.st_mode & S_IPTRANS) diskfs_set_translator (np, 0, 0, 0); @@ -70,7 +70,7 @@ diskfs_drop_node (struct node *np) return; } - assert (np->dn_stat.st_size == 0); + assert_backtrace (np->dn_stat.st_size == 0); savemode = np->dn_stat.st_mode; np->dn_stat.st_mode = 0; @@ -89,7 +89,7 @@ diskfs_drop_node (struct node *np) if (np->filemod_reqs) free_modreqs (np->filemod_reqs); - assert (!np->sockaddr); + assert_backtrace (!np->sockaddr); pthread_mutex_unlock(&np->lock); pthread_mutex_destroy(&np->lock); diff --git a/libdiskfs/priv.h b/libdiskfs/priv.h index 276d0931..bece45a0 100644 --- a/libdiskfs/priv.h +++ b/libdiskfs/priv.h @@ -27,7 +27,7 @@ #include #include #include -#include +#include #include #include "diskfs.h" diff --git a/libdiskfs/protid-make.c b/libdiskfs/protid-make.c index 0b092994..f8b5dcbd 100644 --- a/libdiskfs/protid-make.c +++ b/libdiskfs/protid-make.c @@ -17,7 +17,7 @@ #include "priv.h" #include -#include +#include /* Build and return in CRED a protid which has no user identification, for peropen PO. On success, consume a reference to PO. */ @@ -48,11 +48,11 @@ diskfs_finish_protid (struct protid *cred, struct iouser *user) err = iohelp_create_simple_iouser (&cred->user, 0, 0); else err = iohelp_dup_iouser (&cred->user, user); - assert_perror (err); + assert_perror_backtrace (err); err = mach_port_move_member (mach_task_self (), cred->pi.port_right, diskfs_port_bucket->portset); - assert_perror (err); + assert_perror_backtrace (err); } /* Create and return a protid for an existing peropen PO in CRED for diff --git a/libdiskfs/rdwr-internal.c b/libdiskfs/rdwr-internal.c index 0d405517..eec0d6a0 100644 --- a/libdiskfs/rdwr-internal.c +++ b/libdiskfs/rdwr-internal.c @@ -39,7 +39,7 @@ _diskfs_rdwr_internal (struct node *np, error_t err = 0; if (dir) - assert (!diskfs_readonly); + assert_backtrace (!diskfs_readonly); if (*amt == 0) /* Zero-length writes do not update mtime or anything else, by POSIX. */ diff --git a/libdiskfs/trans-callback.c b/libdiskfs/trans-callback.c index 15e8f9a1..d08f91c6 100644 --- a/libdiskfs/trans-callback.c +++ b/libdiskfs/trans-callback.c @@ -38,7 +38,7 @@ _diskfs_translator_callback1_fn (void *cookie1, void *cookie2, err = diskfs_get_translator (np, argz, (u_int *) argz_len); if (err) { - assert (err != EOPNOTSUPP); + assert_backtrace (err != EOPNOTSUPP); return err; } -- cgit v1.2.3