Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 166940
b: refs/heads/master
c: 31bbf66
h: refs/heads/master
v: v3
  • Loading branch information
Wu Fengguang authored and Linus Torvalds committed Oct 8, 2009
1 parent 699257b commit 69e9117
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 0c57effe27eb6544eb44d5fac563b7334e3bc771
refs/heads/master: 31bbf66eaaaf50ba79e50ab7d3c89531b31c0614
24 changes: 14 additions & 10 deletions trunk/Documentation/vm/page-types.c
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,18 @@ static void fatal(const char *x, ...)
exit(EXIT_FAILURE);
}

int checked_open(const char *pathname, int flags)
{
int fd = open(pathname, flags);

if (fd < 0) {
perror(pathname);
exit(EXIT_FAILURE);
}

return fd;
}


/*
* page flag names
Expand Down Expand Up @@ -534,11 +546,7 @@ static void walk_addr_ranges(void)
{
int i;

kpageflags_fd = open(PROC_KPAGEFLAGS, O_RDONLY);
if (kpageflags_fd < 0) {
perror(PROC_KPAGEFLAGS);
exit(EXIT_FAILURE);
}
kpageflags_fd = checked_open(PROC_KPAGEFLAGS, O_RDONLY);

if (!nr_addr_ranges)
add_addr_range(0, ULONG_MAX);
Expand Down Expand Up @@ -631,11 +639,7 @@ static void parse_pid(const char *str)
opt_pid = parse_number(str);

sprintf(buf, "/proc/%d/pagemap", opt_pid);
pagemap_fd = open(buf, O_RDONLY);
if (pagemap_fd < 0) {
perror(buf);
exit(EXIT_FAILURE);
}
pagemap_fd = checked_open(buf, O_RDONLY);

sprintf(buf, "/proc/%d/maps", opt_pid);
file = fopen(buf, "r");
Expand Down

0 comments on commit 69e9117

Please sign in to comment.