Author: adrian.chadd
Date: Tue Apr 21 21:47:42 2009
New Revision: 13976
Modified:
branches/LUSCA_HEAD/tools/ufsdump.c
Log:
Create a 'read file' function!
Modified: branches/LUSCA_HEAD/tools/ufsdump.c
==============================================================================
--- branches/LUSCA_HEAD/tools/ufsdump.c (original)
+++ branches/LUSCA_HEAD/tools/ufsdump.c Tue Apr 21 21:47:42 2009
@@ -105,13 +105,26 @@
printf("\n");
}
+void
+read_file(const char *path)
+{
+ int fd;
+ char buf[BUFSIZE];
+ int len;
+
+ fd = open(path, O_RDONLY);
+ if (fd < 0) {
+ perror("open");
+ return;
+ }
+ len = read(fd, buf, BUFSIZE);
+ parse_header(buf, len);
+ close(fd);
+}
+
int
main(int argc, char *argv[])
{
- int fd;
- char buf[BUFSIZE];
- int len;
-
/* Setup the debugging library */
_db_init("ALL,1");
_db_set_stderr_debug(1);
@@ -120,13 +133,8 @@
printf("Usage: %s <path to swapfile>\n", argv[0]);
exit(1);
}
- fd = open(argv[1], O_RDONLY);
- if (fd < 0) {
- perror("open");
- exit(1);
- }
- len = read(fd, buf, BUFSIZE);
- parse_header(buf, len);
+ read_file(argv[1]);
+
return 0;
}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"lusca-commit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/lusca-commit?hl=en
-~----------~----~----~----~------~----~------~--~---