⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rf_dfsconvert.c

📁 RAIDFrame是个非常好的磁盘阵列RAID仿真工具
💻 C
字号:
/* * Copyright (c) 1995 Carnegie-Mellon University. * All rights reserved. * * Author: Jim Zelenka * * Permission to use, copy, modify and distribute this software and * its documentation is hereby granted, provided that both the copyright * notice and this permission notice appear in all copies of the * software, derivative works or modified versions, and any portions * thereof, and that both notices appear in supporting documentation. * * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. * * Carnegie Mellon requests users of this software to return to * *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU *  School of Computer Science *  Carnegie Mellon University *  Pittsburgh PA 15213-3890 * * any improvements or extensions that they make and grant Carnegie the * rights to redistribute these changes. *//* * rf_dfsconvert.c * Jim Zelenka, CMU/SCS, 29 September 1995 * read a dfstrace output file, output a raidframe * trace.dat style file *//* $Locker:  $ * $Log: rf_dfsconvert.c,v $ * Revision 1.8  1996/06/14  14:21:43  jimz * give a compilation path when RF_DFSTRACE == 0 * (mainly so "make depend" is happier) * * Revision 1.7  1996/06/05  18:06:02  jimz * Major code cleanup. The Great Renaming is now done. * Better modularity. Better typing. Fixed a bunch of * synchronization bugs. Made a lot of global stuff * per-desc or per-array. Removed dead code. * * Revision 1.6  1996/05/23  00:33:23  jimz * code cleanup: move all debug decls to rf_options.c, all extern * debug decls to rf_options.h, all debug vars preceded by rf_ * * Revision 1.5  1995/12/01  16:00:56  root * added copyright info * */#if RF_DFSTRACE > 0#include <stdio.h>#include <unistd.h>#include <fcntl.h>#include <strings.h>#include <sys/file.h>#include <sys/stat.h>#include <ufs/inode.h>#include <sys/mount.h>#include <sys/param.h>#include <sys/time.h>#include <tracelib.h>#include "rf_acctrace.h"static char *progname;static char *infile, *outfile;static void usage(){	fprintf(stderr, "USAGE: %s dfstracefile outputfile\n", progname);	exit(1);}main(argc, argv)  int argc;  char **argv;{	int outfd, rc, l, num_notes, num_done;	RF_AccTraceEntry_t *acc;	struct dfs_note *note;	dfs_header_t *rec;	FILE *inf;	progname = argv[0];	if (argc != 3)		usage();	infile = argv[1];	outfile = argv[2];	outfd = open(outfile, O_RDWR|O_CREAT, IREAD|IWRITE);	if (outfd < 0) {		perror(outfile);		usage();	}	inf = Trace_Open(infile);	if (inf == NULL) {		perror(infile);		usage();	}	num_notes = num_done = 0;	l = sizeof(RF_AccTraceEntry_t);	while (rec = Trace_GetRecord(inf)) {		if (rec->opcode == DFS_NOTE) {			note = (struct dfs_note *)rec;			if (note->length == l) {				num_done++;				acc = (RF_AccTraceEntry_t *)note->note;				rc = write(outfd, (char *)acc, l);				if (rc != l) {					if (rc < 0) {						perror(outfile);						exit(1);					}					else {						printf(stderr, "ERROR: wrote %d/%d bytes to %s\n",								rc, l, outfile);						exit(1);					}				}			}			num_notes++;		}	}	printf("Converted %d notes to %d trace entries\n", num_notes, num_done);	close(outfd);	exit(0);}#else /* RF_DFSTRACE > 0 */#include <stdio.h>main(argc, argv)  int     argc;  char  **argv;{  fprintf(stderr, "ERROR: %s only supported with DFSTRACE\n", argv[0]);  fflush(stderr);  exit(1);}#endif /* RF_DFSTRACE > 0 */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -