Author: adrian.chadd
Date: Sun Apr 26 07:48:09 2009
New Revision: 13988
Modified:
branches/LUSCA_HEAD/tools/ufsdump.c
Log:
Modify the ufsdump tool to attempt to dump an entire storedir.
It now takes a directory, L1 and L2 on the command line.
It doesn't verify that the store file is in the right place (or a
whole host of other things!) but it does run well enough right now
to do some performance benchmarking and sanitisation of the
generated swaplog file. The generated swaplog file is currently
not yet able to be fed back into Lusca (notably lacking the
correct swapfile number and file size.)
Modified: branches/LUSCA_HEAD/tools/ufsdump.c
==============================================================================
--- branches/LUSCA_HEAD/tools/ufsdump.c (original)
+++ branches/LUSCA_HEAD/tools/ufsdump.c Sun Apr 26 07:48:09 2009
@@ -40,6 +40,7 @@
#include "../libsqstore/store_mgr.h"
#include "../libsqstore/store_meta.h"
#include "../libsqstore/store_log.h"
+#include "../libsqstore/store_file_ufs.h"
#define BUFSIZE 4096
@@ -152,6 +153,7 @@
rebuild_entry_t re;
storeSwapLogData sd;
+ fprintf(stderr, "read_file: %s\n", path);
fd = open(path, O_RDONLY);
if (fd < 0) {
perror("open");
@@ -178,24 +180,40 @@
}
void
-read_dir(const char *dirpath)
+read_dir(const char *dirpath, int l1, int l2)
{
DIR *d;
struct dirent *de;
- char path[256];
-
- d = opendir(dirpath);
- if (! d) {
- perror("opendir");
- return;
+ char path[SQUID_MAXPATHLEN];
+ char dir[SQUID_MAXPATHLEN];
+ int i, j;
+
+ for (i = 0; i < l1; i++) {
+ for (j = 0; j < l2; j++) {
+ (void) store_ufs_createDir(dirpath, i, j, dir);
+ fprintf(stderr, "opening dir %s\n", dir);
+ d = opendir(dir);
+ if (! d) {
+ perror("opendir");
+ continue;
+ }
+
+ /* The store dir stuff really should verify that the
given file
+ * exists where it is supposed to exist. It is also
plausible that
+ * this could attempt to shuffle files around in case
users
+ * wish to change L1/L2 configuration.. :)
+ */
+ while ( (de = readdir(d)) != NULL) {
+ if (de->d_name[0] == '.')
+ continue;
+ snprintf(path, sizeof(path) - 1, "%s/%s", dir,
de->d_name);
+ fprintf(stderr, "opening %s\n", path);
+ read_file(path);
+ }
+ closedir(d);
+ }
}
- while ( (de = readdir(d)) != NULL) {
- if (de->d_name[0] == '.')
- continue;
- snprintf(path, sizeof(path) - 1, "%s/%s", dirpath, de->d_name);
- read_file(path);
- }
}
int
@@ -209,9 +227,8 @@
bzero(buf, sizeof(buf));
- if (argc < 3) {
- printf("Usage: %s -f <path to swapfile>\n", argv[0]);
- printf("Usage: %s -d <directory of files to check>\n", argv[0]);
+ if (argc < 4) {
+ printf("Usage: %s <store path> <l1> <l2>\n", argv[0]);
exit(1);
}
@@ -222,11 +239,7 @@
write(1, sh, sizeof(storeSwapLogData));
- if (strcmp(argv[1], "-f") == 0){
- read_file(argv[2]);
- } else {
- read_dir(argv[2]);
- }
+ read_dir(argv[1], atoi(argv[2]), atoi(argv[3]));
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
-~----------~----~----~----~------~----~------~--~---