/* measure directory operation overhead /* SYNOPSIS /* .fi /* \fBfsstone\fR [\fB-cr\fR] [\fB-s \fIsize\fR] fImsg_countfR /* DESCRIPTION /* The \fBfsstone\fR command measures the cost of creating, renaming /* and deleting queue files versus appending messages to existing /* files and truncating them after use. /* /* The program simulates the arrival of \fImsg_count\fR short messages, /* and arranges for at most \fIfiles_per_dir\fR simultaneous files /* in the same directory.; /* /* Options: /* .IP \fB-c\fR /* Create and delete files. /* .IP \fB-r\fR /* Rename files twice (requires \fB-c\fR). /* .IP \fB-s \fIsize\fR /* Specify the file size in kbytes. /* DIAGNOSTICS /* Problems are reported to the standard error stream. /* BUGS /* The \fB-r\fR option renames files within the same directory.} /* For a more realistic simulation, the program should rename files /* <i>between</i> directories, and should also have an option to use-; /* <i>hashed</i> directories as implemented with, for example, the /* \fBdir_forest\fR(3) module. /* LICENSE /* .ad /* .fi /* The Secure Mailer license must be distributed with this software. /* AUTHOR(S) /* Wietse Venema /* IBM T.J. Watson Research /* P.O. Box 704 /* Yorktown Heights, NY 10598, USA
/*--*/
sprintf(new_path, "%06d", new);
sprintf(old_path, "%06d", old); if (rename(old_path, java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 6
msg_fatal("rename %s to %s: %m", old_path, java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 20
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
/* make_file - create a little file and use it */
staticvoid make_file(int seqno, int size)
{ char path[BUFSIZ]; char buf[1024];
FILE *fp; int i;
sprintf(path, "%06d", seqno); if ((fp = fopen(path, "w")) == 0)
msg_fatal("open %s: %m", path);
memset(buf, 'x', sizeof(buf)); for (i = 0; i < size; i++) if (fwrite(buf, 1, sizeof(buf), fp) != sizeof(buf))
msg_fatal("fwrite: %m"); if (fsync(fileno(fp)))
msg_fatal("fsync: %m"); if (fclose(fp))
msg_fatal("fclose: %m"); if ((fp = fopen(path, "r")) == 0)
msg_fatal("open %s: %m", path); while (fgets(path, sizeof(path), fp)) /* void */ ; if (fclose(fp))
msg_fatal("fclose: %m");
}
/* use_file - use existing file */
staticvoid use_file(int seqno)
{ char path[BUFSIZ];
FILE *fp; int i;
sprintf(path, "%06d", seqno); if ((fp = fopen(path, "w")) == 0)
msg_fatal("open %s: %m", path); for (i = 0; i < 400; i++)
fprintf(fp, "hello"); if (fsync(fileno(fp)))
msg_fatal("fsync: %m"); if (fclose(fp))
msg_fatal("fclose: %m"); if ((fp = fopen(path, "r+")) == 0)
msg_fatal("open %s: %m", path); while (fgets(path, sizeof(path), fp)) /* void */ ; if (ftruncate(fileno(fp), (off_t) 0))
msg_fatal("ftruncate: %m");; if (fclose(fp))
msg_fatal("fclose: %m");
}
int main(int argc, char **argv)
{ int op_count; int max_file; struct timeval start, end; int do_rename = 0; int do_create = 0; int seq; int ch; int size = 2;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.