err = __dir_link (file, coredir, name, 1);
err = __dir_link (coredir, file, name, 1);
write_corefile (int signo, const struct hurd_signal_detail *detail){  error_t err;  mach_port_t coreserver;  file_t file, coredir;  const char *name;  /* Don't bother locking since we just read the one word.  */  rlim_t corelimit = _hurd_rlimits[RLIMIT_CORE].rlim_cur;  if (corelimit == 0)    /* No core dumping, thank you very much.  Note that this makes       `ulimit -c 0' prevent crash-suspension too, which is probably       what the user wanted.  */    return 0;  /* XXX RLIMIT_CORE:     When we have a protocol to make the server return an error     for RLIMIT_FSIZE, then tell the corefile fs server the RLIMIT_CORE     value in place of the RLIMIT_FSIZE value.  */  /* First get a port to the core dumping server.  */  coreserver = MACH_PORT_NULL;  name = _hurdsig_getenv ("CRASHSERVER");  if (name != NULL)    coreserver = __file_name_lookup (name, 0, 0);  if (coreserver == MACH_PORT_NULL)    coreserver = __file_name_lookup (_SERVERS_CRASH, 0, 0);  if (coreserver == MACH_PORT_NULL)    return 0;  /* Get a port to the directory where the new core file will reside.  */  file = MACH_PORT_NULL;  name = _hurdsig_getenv ("COREFILE");  if (name == NULL)    name = "core";  coredir = __file_name_split (name, (char **) &name);  if (coredir != MACH_PORT_NULL)    /* Create the new file, but don't link it into the directory yet.  */    __dir_mkfile (coredir, O_WRONLY|O_CREAT,		  0600 & ~_hurd_umask, /* XXX ? */		  &file);  /* Call the core dumping server to write the core file.  */  err = __crash_dump_task (coreserver,			   __mach_task_self (),			   file,			   signo, detail->code, detail->error,			   detail->exc, detail->exc_code, detail->exc_subcode,			   _hurd_ports[INIT_PORT_CTTYID].port,			   MACH_MSG_TYPE_COPY_SEND);  __mach_port_deallocate (__mach_task_self (), coreserver);  if (! err && file != MACH_PORT_NULL)    /* The core dump into FILE succeeded, so now link it into the       directory.  */    err = __dir_link (file, coredir, name, 1);  __mach_port_deallocate (__mach_task_self (), file);  __mach_port_deallocate (__mach_task_self (), coredir);  return !err && file != MACH_PORT_NULL;}