summaryrefslogtreecommitdiff
path: root/utils/libmach/map.c
diff options
context:
space:
mode:
Diffstat (limited to 'utils/libmach/map.c')
-rw-r--r--utils/libmach/map.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/utils/libmach/map.c b/utils/libmach/map.c
index e1d6010e..12bee1be 100644
--- a/utils/libmach/map.c
+++ b/utils/libmach/map.c
@@ -83,21 +83,19 @@ attachproc(int pid, int kflag, int corefd, Fhdr *fp)
int fd;
Map *map;
uvlong n;
- int mode;
map = newmap(0, 4);
if (!map)
return 0;
- if(kflag) {
+ if(kflag)
regs = "kregs";
- mode = OREAD;
- } else {
+ else
regs = "regs";
- mode = ORDWR;
- }
if (mach->regsize) {
sprint(buf, "/proc/%d/%s", pid, regs);
- fd = open(buf, mode);
+ fd = open(buf, ORDWR);
+ if(fd < 0)
+ fd = open(buf, OREAD);
if(fd < 0) {
free(map);
return 0;
@@ -106,7 +104,9 @@ attachproc(int pid, int kflag, int corefd, Fhdr *fp)
}
if (mach->fpregsize) {
sprint(buf, "/proc/%d/fpregs", pid);
- fd = open(buf, mode);
+ fd = open(buf, ORDWR);
+ if(fd < 0)
+ fd = open(buf, OREAD);
if(fd < 0) {
close(map->seg[0].fd);
free(map);