Mercurial > hg > truffle
comparison agent/src/os/linux/libproc_impl.c @ 4936:d3384450b649
Merge
author | fparain |
---|---|
date | Fri, 17 Feb 2012 06:34:49 -0800 |
parents | 54d3535a6dd3 |
children | 2394a89e89f4 |
comparison
equal
deleted
inserted
replaced
4915:be398bba40e9 | 4936:d3384450b649 |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. | 2 * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | 4 * |
5 * This code is free software; you can redistribute it and/or modify it | 5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as | 6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
48 int pathmap_open(const char* name) { | 48 int pathmap_open(const char* name) { |
49 int fd; | 49 int fd; |
50 char alt_path[PATH_MAX + 1]; | 50 char alt_path[PATH_MAX + 1]; |
51 | 51 |
52 init_alt_root(); | 52 init_alt_root(); |
53 fd = open(name, O_RDONLY); | |
54 if (fd >= 0) { | |
55 return fd; | |
56 } | |
57 | 53 |
58 if (alt_root_len > 0) { | 54 if (alt_root_len > 0) { |
59 strcpy(alt_path, alt_root); | 55 strcpy(alt_path, alt_root); |
60 strcat(alt_path, name); | 56 strcat(alt_path, name); |
61 fd = open(alt_path, O_RDONLY); | 57 fd = open(alt_path, O_RDONLY); |
70 fd = open(alt_path, O_RDONLY); | 66 fd = open(alt_path, O_RDONLY); |
71 if (fd >= 0) { | 67 if (fd >= 0) { |
72 print_debug("path %s substituted for %s\n", alt_path, name); | 68 print_debug("path %s substituted for %s\n", alt_path, name); |
73 return fd; | 69 return fd; |
74 } | 70 } |
71 } | |
72 } else { | |
73 fd = open(name, O_RDONLY); | |
74 if (fd >= 0) { | |
75 return fd; | |
75 } | 76 } |
76 } | 77 } |
77 | 78 |
78 return -1; | 79 return -1; |
79 } | 80 } |