Bug fixes.
This commit is contained in:
@ -170,9 +170,9 @@ void procfs_create(void *__os, int ref, int osnum, int pid, unsigned long arg)
|
|||||||
printk("ERROR: procfs_creat: file name not properly terminated.\n");
|
printk("ERROR: procfs_creat: file name not properly terminated.\n");
|
||||||
goto quit;
|
goto quit;
|
||||||
}
|
}
|
||||||
entry = get_procfs_entry(f->fname, mode);
|
entry = get_procfs_entry(name, mode);
|
||||||
if (entry == NULL) {
|
if (entry == NULL) {
|
||||||
printk("ERROR: could not create a procfs entry for %s.\n", f->fname);
|
printk("ERROR: could not create a procfs entry for %s.\n", name);
|
||||||
goto quit;
|
goto quit;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -260,14 +260,14 @@ int mckernel_procfs_read(char *buffer, char **start, off_t offset,
|
|||||||
int count, int *peof, void *dat)
|
int count, int *peof, void *dat)
|
||||||
{
|
{
|
||||||
struct procfs_list_entry *e = dat;
|
struct procfs_list_entry *e = dat;
|
||||||
struct procfs_read *r;
|
volatile struct procfs_read *r;
|
||||||
struct ikc_scd_packet isp;
|
struct ikc_scd_packet isp;
|
||||||
int ret, retrycount = 0;
|
int ret, retrycount = 0;
|
||||||
unsigned long pbuf;
|
unsigned long pbuf;
|
||||||
|
|
||||||
dprintk("mckernel_procfs_read: invoked for %s\n", e->fname);
|
dprintk("mckernel_procfs_read: invoked for %s\n", e->fname);
|
||||||
|
|
||||||
if (count <= 0 || dat == NULL) {
|
if (count <= 0 || dat == NULL || offset < 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -59,6 +59,9 @@ void create_proc_procfs_files(int pid, int cpuid)
|
|||||||
|
|
||||||
dprintf("create procfs files:\n");
|
dprintf("create procfs files:\n");
|
||||||
|
|
||||||
|
snprintf(fname, PROCFS_NAME_MAX, "mcos%d/%d/auxv", osnum, pid);
|
||||||
|
create_proc_procfs_file(pid, fname, 0400, cpuid);
|
||||||
|
|
||||||
snprintf(fname, PROCFS_NAME_MAX, "mcos%d/%d/task/%d/mem", osnum, pid, pid);
|
snprintf(fname, PROCFS_NAME_MAX, "mcos%d/%d/task/%d/mem", osnum, pid, pid);
|
||||||
create_proc_procfs_file(pid, fname, 0400, cpuid);
|
create_proc_procfs_file(pid, fname, 0400, cpuid);
|
||||||
|
|
||||||
@ -100,6 +103,9 @@ void delete_proc_procfs_files(int pid)
|
|||||||
snprintf(fname, PROCFS_NAME_MAX, "mcos%d/%d/task", osnum, pid);
|
snprintf(fname, PROCFS_NAME_MAX, "mcos%d/%d/task", osnum, pid);
|
||||||
delete_proc_procfs_file(pid, fname);
|
delete_proc_procfs_file(pid, fname);
|
||||||
|
|
||||||
|
snprintf(fname, PROCFS_NAME_MAX, "mcos%d/%d/auxv", osnum, pid);
|
||||||
|
delete_proc_procfs_file(pid, fname);
|
||||||
|
|
||||||
snprintf(fname, PROCFS_NAME_MAX, "mcos%d/%d", osnum, pid);
|
snprintf(fname, PROCFS_NAME_MAX, "mcos%d/%d", osnum, pid);
|
||||||
delete_proc_procfs_file(pid, fname);
|
delete_proc_procfs_file(pid, fname);
|
||||||
|
|
||||||
@ -194,19 +200,18 @@ void process_procfs_request(unsigned long rarg)
|
|||||||
dprintf("rarg: %x\n", rarg);
|
dprintf("rarg: %x\n", rarg);
|
||||||
parg = ihk_mc_map_memory(NULL, rarg, sizeof(struct procfs_read));
|
parg = ihk_mc_map_memory(NULL, rarg, sizeof(struct procfs_read));
|
||||||
dprintf("parg: %x\n", parg);
|
dprintf("parg: %x\n", parg);
|
||||||
r = ihk_mc_map_virtual(parg, sizeof(struct procfs_read),
|
r = ihk_mc_map_virtual(parg, 1, PTATTR_WRITABLE | PTATTR_ACTIVE);
|
||||||
PTATTR_WRITABLE | PTATTR_ACTIVE);
|
|
||||||
dprintf("r: %p\n", r);
|
|
||||||
if (r == NULL) {
|
if (r == NULL) {
|
||||||
kprintf("ERROR: process_procfs_request: got a null procfs_read structure.\n");
|
kprintf("ERROR: process_procfs_request: got a null procfs_read structure.\n");
|
||||||
packet.err = -EIO;
|
packet.err = -EIO;
|
||||||
goto dataunavail;
|
goto dataunavail;
|
||||||
}
|
}
|
||||||
|
dprintf("r: %p\n", r);
|
||||||
|
|
||||||
dprintf("remote pbuf: %x\n", r->pbuf);
|
dprintf("remote pbuf: %x\n", r->pbuf);
|
||||||
pbuf = ihk_mc_map_memory(NULL, r->pbuf, r->count);
|
pbuf = ihk_mc_map_memory(NULL, r->pbuf, r->count);
|
||||||
dprintf("pbuf: %x\n", pbuf);
|
dprintf("pbuf: %x\n", pbuf);
|
||||||
buf = ihk_mc_map_virtual(pbuf, r->count, PTATTR_WRITABLE | PTATTR_ACTIVE);
|
buf = ihk_mc_map_virtual(pbuf, 1, PTATTR_WRITABLE | PTATTR_ACTIVE);
|
||||||
dprintf("buf: %p\n", buf);
|
dprintf("buf: %p\n", buf);
|
||||||
if (buf == NULL) {
|
if (buf == NULL) {
|
||||||
kprintf("ERROR: process_procfs_request: got a null buffer.\n");
|
kprintf("ERROR: process_procfs_request: got a null buffer.\n");
|
||||||
@ -236,8 +241,7 @@ void process_procfs_request(unsigned long rarg)
|
|||||||
/* Processing for pattern "mcos%d/xxx" files should be here.
|
/* Processing for pattern "mcos%d/xxx" files should be here.
|
||||||
Its template is something like what follows:
|
Its template is something like what follows:
|
||||||
|
|
||||||
ret = sscanf(p, "PATTERN", ...)
|
if (pattern matches) {
|
||||||
if ((ret == xx) && pattern has matched) {
|
|
||||||
get the data (at 'r->offset')
|
get the data (at 'r->offset')
|
||||||
and write it to 'buf'
|
and write it to 'buf'
|
||||||
up to 'r->count' bytes.
|
up to 'r->count' bytes.
|
||||||
@ -277,7 +281,23 @@ void process_procfs_request(unsigned long rarg)
|
|||||||
p = strchr(p, '/') + 1;
|
p = strchr(p, '/') + 1;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* mcos0/PID/taks/PID/mem
|
* mcos%d/PID/auxv
|
||||||
|
*/
|
||||||
|
if (strcmp(p, "auxv") == 0) {
|
||||||
|
unsigned int limit = AUXV_LEN * sizeof(int);
|
||||||
|
unsigned int len = r->count;
|
||||||
|
if (r->offset < limit) {
|
||||||
|
if (limit < r->offset + r->count) {
|
||||||
|
len = limit - r->offset;
|
||||||
|
}
|
||||||
|
memcpy((void *)buf, ((char *) proc->saved_auxv) + r->offset, len);
|
||||||
|
ans = len;
|
||||||
|
}
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* mcos%d/PID/taks/PID/mem
|
||||||
*
|
*
|
||||||
* The offset is treated as the beginning of the virtual address area
|
* The offset is treated as the beginning of the virtual address area
|
||||||
* of the process. The count is the length of the area.
|
* of the process. The count is the length of the area.
|
||||||
@ -299,7 +319,7 @@ void process_procfs_request(unsigned long rarg)
|
|||||||
if (range->end < r->offset + r->count) {
|
if (range->end < r->offset + r->count) {
|
||||||
len = range->end - r->offset;
|
len = range->end - r->offset;
|
||||||
}
|
}
|
||||||
memcpy((void *) buf, (void *)range->start, len);
|
memcpy((void *)buf, (void *)range->start, len);
|
||||||
ans = len;
|
ans = len;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -312,14 +332,14 @@ void process_procfs_request(unsigned long rarg)
|
|||||||
*/
|
*/
|
||||||
dprintf("could not find a matching entry for %s.\n", p);
|
dprintf("could not find a matching entry for %s.\n", p);
|
||||||
end:
|
end:
|
||||||
ihk_mc_unmap_virtual(buf, r->count, 0);
|
ihk_mc_unmap_virtual(buf, 1, 0);
|
||||||
dprintf("ret: %d, eof: %d\n", ans, eof);
|
dprintf("ret: %d, eof: %d\n", ans, eof);
|
||||||
r->ret = ans;
|
r->ret = ans;
|
||||||
r->eof = eof;
|
r->eof = eof;
|
||||||
packet.err = 0;
|
packet.err = 0;
|
||||||
bufunavail:
|
bufunavail:
|
||||||
ihk_mc_unmap_memory(NULL, pbuf, r->count);
|
ihk_mc_unmap_memory(NULL, pbuf, r->count);
|
||||||
ihk_mc_unmap_virtual(r, sizeof(struct procfs_read), 0);
|
ihk_mc_unmap_virtual(r, 1, 0);
|
||||||
dataunavail:
|
dataunavail:
|
||||||
ihk_mc_unmap_memory(NULL, parg, sizeof(struct procfs_read));
|
ihk_mc_unmap_memory(NULL, parg, sizeof(struct procfs_read));
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user