8000 minix/minix/servers/vfs/misc.c at master · vishnu3741/minix · GitHub
[go: up one dir, main page]

Skip to content

Latest commit

 

History

History
1006 lines (863 loc) · 27.6 KB

misc.c

File metadata and controls

1006 lines (863 loc) · 27.6 KB
if (fp_is_blocked(fp))
unpause();
/* open core file */
snprintf(core_path, PATH_MAX, "%s.%d", CORE_NAME, fp->fp_pid);
r = core_fd = common_open(core_path, O_WRONLY | O_CREAT | O_TRUNC,
CORE_MODE, FALSE /*for_exec*/);
if (r < 0) goto core_exit;
/* get process name */
r = sys_datacopy_wrapper(PM_PROC_NR, exe_name, VFS_PROC_NR,
(vir_bytes) proc_name, PROC_NAME_LEN);
if (r != OK) goto core_exit;
proc_name[PROC_NAME_LEN - 1] = '\0';
/* write the core dump */
f = get_filp(core_fd, VNODE_WRITE);
assert(f != NULL);
write_elf_core_file(f, csig, proc_name);
unlock_filp(f);
core_exit:
/* The core file descriptor will be closed as part of the process exit. */
free_proc(FP_EXITING);
return(r);
}
/*===========================================================================*
* ds_event *
*===========================================================================*/
void
ds_event(void)
{
char key[DS_MAX_KEYLEN];
char *blkdrv_prefix = "drv.blk.";
char *chrdrv_prefix = "drv.chr.";
char *sckdrv_prefix = "drv.sck.";
u32_t value;
int type, ftype, r;
endpoint_t owner_endpoint;
/* Get the event and the owner from DS. */
while ((r = ds_check(key, &type, &owner_endpoint)) == OK) {
/* Only check for block, character, socket driver up events. */
if (!strncmp(key, blkdrv_prefix, strlen(blkdrv_prefix))) {
ftype = S_IFBLK;
} else if (!strncmp(key, chrdrv_prefix, strlen(chrdrv_prefix))) {
ftype = S_IFCHR;
} else if (!strncmp(key, sckdrv_prefix, strlen(sckdrv_prefix))) {
ftype = S_IFSOCK;
} else {
continue;
}
if ((r = ds_retrieve_u32(key, &value)) != OK) {
printf("VFS: ds_event: ds_retrieve_u32 failed\n");
break;
}
if (value != DS_DRIVER_UP) continue;
/* Perform up. */
if (ftype == S_IFBLK || ftype == S_IFCHR)
dmap_endpt_up(owner_endpoint, (ftype == S_IFBLK));
else
smap_endpt_up(owner_endpoint);
}
if (r != ENOENT) printf("VFS: ds_event: ds_check failed: %d\n", r);
}
/* A function to be called on panic(). */
void panic_hook(void)
{
printf("VFS mthread stacktraces:\n");
mthread_stacktraces();
}
/*===========================================================================*
* do_getrusage *
*===========================================================================*/
int do_getrusage(void)
{
/* Obsolete vfs_getrusage(2) call from userland. The getrusage call is
0