mtd/util/checkfs Makefile, 1.1, 1.2 checkfs.c, 1.7, 1.8 comm.c, 1.2, 1.3 makefiles.c, 1.1, 1.2

gleixner at infradead.org gleixner at infradead.org
Mon Nov 7 06:15:57 EST 2005


Update of /home/cvs/mtd/util/checkfs
In directory phoenix.infradead.org:/tmp/cvs-serv29274/util/checkfs

Modified Files:
	Makefile checkfs.c comm.c makefiles.c 
Log Message:
[MTD / JFFS2] Clean up trailing white spaces


Index: Makefile
===================================================================
RCS file: /home/cvs/mtd/util/checkfs/Makefile,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Makefile	21 Jun 2001 23:07:56 -0000	1.1
+++ Makefile	7 Nov 2005 11:15:16 -0000	1.2
@@ -11,4 +11,4 @@
 	gcc -g -Wall makefiles.c -o makefiles
 
 clean:
-	rm -f makefiles checkfs *~ *.o
\ No newline at end of file
+	rm -f makefiles checkfs *~ *.o

Index: checkfs.c
===================================================================
RCS file: /home/cvs/mtd/util/checkfs/checkfs.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- checkfs.c	21 Jun 2001 23:04:17 -0000	1.7
+++ checkfs.c	7 Nov 2005 11:15:17 -0000	1.8
@@ -11,28 +11,31 @@
  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
  * See the Licence for the specific language governing rights and
  * limitations under the Licence.
-  
+
   This program opens files in progression (file00001, file00002 etc),
   upto MAX_NUM_FILES and checks their CRC. If a file is not found or the
   CRC does not match it stops it's operation.
-  
+
   Everything is logged in a logfile called './logfile'.
-  
+
   If everything is ok this program sends a signal, via com1, to the remote
   power control box to power cycle this computer.
-  
+
   This program then proceeds to create new files file0....file<MAX_NUM_FILES>
   in a endless loop and checksum each before closing them.
-  
+
   STRUCTURE OF THE FILES:
   The fist int is the size of the file in bytes.
   The last 2 bytes are the CRC for the entire file.
   There is random data in between.
-  
+
   The files are opened in the current dir.
-  
+
   $Id$
   $Log$
+  Revision 1.8  2005/11/07 11:15:17  gleixner
+  [MTD / JFFS2] Clean up trailing white spaces
+
   Revision 1.7  2001/06/21 23:04:17  dwmw2
   Initial import to MTD CVS
 
@@ -60,7 +63,7 @@
   power failed. If the write did succeed, then the newer data will have its own
   CRC in place when it gets checked => hence no error. In theory at least!
 
-  
+
   Revision 1.2  2001/05/11 19:27:33  vipin
   Added cmd line args to change serial port, and specify max size of
   random files created. Some cleanup. Added -Wall to Makefile.
@@ -73,7 +76,7 @@
   "checkfs" is then run on every powerup to check consistancy
   of the files. See checkfs.c for more details.
 
-  
+
 */
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -154,34 +157,34 @@
 
   [A possible enhancement to this program would be to pass these
   parameters via the command line.]
-  
+
   Returns file descriptor to open port. Use this fd to write to port
   and close it later, when done.
 */
 int setupSerial (const char *dev) {
     int i, fd;
     struct termios tios;
-    
+
     fd = open(dev,O_RDWR | O_NDELAY );
     if (fd < 0) {
-        fprintf(stderr, "%s: %s\n", dev, sys_errlist[errno]); 
+        fprintf(stderr, "%s: %s\n", dev, sys_errlist[errno]);
         exit(1);
     }
     if (tcgetattr(fd, &tios) < 0) {
         fprintf(stderr,"Could not get terminal attributes: %s",sys_errlist[errno]);
         exit(1);
     }
-    
-    tios.c_cflag = 
+
+    tios.c_cflag =
         CS7 |
         CREAD |			// Enable Receiver
         HUPCL |			// Hangup after close
         CLOCAL |                // Ignore modem control lines
         PARENB;			// Enable parity (even by default)
-    
-    
-    
-    tios.c_iflag      = IGNBRK; // Ignore break 
+
+
+
+    tios.c_iflag      = IGNBRK; // Ignore break
     tios.c_oflag      = 0;
     tios.c_lflag      = 0;
     for(i = 0; i < NCCS; i++) {
@@ -189,10 +192,10 @@
     }
     tios.c_cc[VMIN] = 1;
     tios.c_cc[VTIME] = 0;
-    
+
     cfsetospeed (&tios, B9600);
     cfsetispeed (&tios, B9600);
-    
+
     if (tcsetattr(fd, TCSAFLUSH, &tios) < 0) {
         fprintf(stderr,"Could not set attributes: ,%s",sys_errlist[errno]);
         exit(1);
@@ -221,7 +224,7 @@
     char dataByte;
     int retry;
     char done;
-    
+
     fp =   fopen(filename,"rb");
     if(!fp){
         logfp = fopen("logfile","a"); /*open for appending only.*/
@@ -229,8 +232,8 @@
         fclose(logfp);
         return FALSE;
     }
-    
-    
+
+
     /*the first int contains an int that is the length of the file in long.*/
     if(fread(&len, sizeof(int), 1, fp) != 1){
         logfp = fopen("logfile","a"); /*open for appending only.*/
@@ -254,13 +257,13 @@
         fclose(logfp);
         return FALSE;
     }
-    
-    
+
+
     rewind(fp);
     len+=2; /*the file has two extra bytes at the end, it's checksum. Those
               two MUST also be included in the checksum calculation.
             */
-    
+
     for (;len>0;len--){
         retry=5; /*retry 5 times*/
         done = FALSE;
@@ -304,11 +307,11 @@
   program.
 */
 void send_pwrdn_ok(void){
-    
+
     int fd;
     FILE *cyclefp;
     int cycle_fd;
-    
+
     cyclefp =   fopen("cycleCnt","rb");
     if(!cyclefp){
         printf("expecting file \"cycleCnt\". Cannot continue.\n");
@@ -319,9 +322,9 @@
         exit(1);
     }
     fclose(cyclefp);
-    
+
     CycleCount++;
-    
+
     /*now write this puppy back*/
     cyclefp  = fopen("cycleCnt","wb");
     cycle_fd = fileno(cyclefp);
@@ -337,10 +340,10 @@
         fprintf(stderr, "Error! cannot sync file buffer with disk.\n");
         exit(1);
     }
-    
+
     fclose(cyclefp);
     (void)sync();
-    
+
     printf("\n\n Sending Power down command to the remote box.\n");
     fd = setupSerial(SerialDevice);
 
@@ -349,7 +352,7 @@
         fprintf(stderr, "Error sending power down command.\n");
         exit(1);
     }
-    
+
     close(fd);
 }//end send_pwrnd_ok()
 
@@ -361,12 +364,12 @@
   Make sure buf, extends at least 2 bytes beyond.
  */
 void appendChecksum(char *buf, int numBytes){
-    
+
     unsigned short crc = 0xffff;
     int index = 0;
 
     /* printf("Added CRC (2 bytes) to %i bytes.\n", numBytes); */
-        
+
     for (; numBytes > 0; numBytes--){
 
         crc = (crc >> 8) ^ crc_ccitt_table[(crc ^ buf[index++]) & 0xff];
@@ -377,8 +380,8 @@
     buf[index++] = crc;
     buf[index++] = crc >> 8;
 
-    
-    
+
+
 }/*end checksum()*/
 
 
@@ -393,8 +396,8 @@
   data to read and checksum later).
 */
 void make_new_file(char *filename){
-    
-    
+
+
     int dfd; /* data file descriptor */
     int rand_data;
     int data_size;
@@ -402,13 +405,13 @@
     int dataIndex = 0;
     int err;
 
-    
+
     struct {
         int sizeInBytes; /* must be int */
         int dataInt[MAX_INTS_ALLOW+1]; /* how many int's can we write? */
     }__attribute((packed)) dataBuf;
-    
-    
+
+
     fprintf(stderr, "Creating File:%s. ", filename);
 
     if((dfd = open(filename, O_RDWR | O_CREAT | O_SYNC)) <= 0)
@@ -426,28 +429,28 @@
     while(
 	((data_size = (int)(1+(int)((FileSizeMax/sizeof(int))*rand()/(RAND_MAX+1.0)))) < 5)
     );
-    
+
     /* printf("Writing %i ints to the file.\n", data_size); */
-    
+
     temp_size = data_size * sizeof(int);
 
     /* Make sure that all data is written in one go! This is important to
        check for reliability of file systems like JFFS/JFFS that purport to
        have "reliable" writes during powre fail.
      */
-    
+
     dataBuf.sizeInBytes = temp_size;
 
     data_size--; /*one alrady written*/
     dataIndex = 0;
-    
+
     while(data_size--){
         rand_data =  (int)(1 + (int)(10000.0*rand()/(RAND_MAX+1.0)));
 
         dataBuf.dataInt[dataIndex++] = rand_data;
-        
+
     }
-    
+
     /*now calculate the file checksum and append it to the end*/
     appendChecksum((char *)&dataBuf, dataBuf.sizeInBytes);
 
@@ -471,11 +474,11 @@
         perror("Error: Unable to truncate file.");
         exit(1);
     }
-    
-    
+
+
     close(dfd);
-    
-    
+
+
 }//end make_new_file()
 
 
@@ -494,14 +497,14 @@
            CMDLINE_MAXERROR);
     printf("%s or %s: This Help screen.\n", CMDLINE_HELPSHORT,
            CMDLINE_HELPLONG);
-    
+
 }/* end printHelp()*/
 
 
 
 void processCmdLine(int argc, char **argv)
 {
-    
+
     int cnt;
 
     /* skip past name of this program, process rest */
@@ -521,7 +524,7 @@
                            MAX_INTS_ALLOW*sizeof(int));
                     exit(0);
                 }
-                
+
                 continue;
             }else
                 if(strcmp(argv[cnt], CMDLINE_HELPSHORT) == 0)
@@ -535,21 +538,21 @@
                         printHelp(argv);
                         exit(0);
                     }else
-                        
+
                         if(strcmp(argv[cnt], CMDLINE_MAXERROR) == 0)
                         {
                             MaxErrAllowed = atoi(argv[++cnt]);
-                        }           
+                        }
                         else
                         {
                             printf("Unknown cmd line option:%s\n", argv[cnt]);
                             printHelp(argv);
                             exit(0);
-                            
+
                         }
     }
-    
-    
+
+
 }/* end processCmdLine() */
 
 
@@ -557,7 +560,7 @@
 
 
 int main(int argc, char **argv){
-    
+
     FILE *logfp;
     int log_fd;
     char filename[30];
@@ -569,16 +572,16 @@
     time_t timep;
     char * time_string;
     unsigned int seed;
-    
-    
+
+
     numberFiles = MAX_NUM_FILES;
 
     if(argc >= 1)
     {
         processCmdLine(argc, argv);
     }
-    
-    
+
+
     /*
       First open MAX_NUM_FILES and make sure that the checksum is ok.
       Also make an intry into the logfile.
@@ -586,7 +589,7 @@
     /* timestamp! */
     time(&timep);
     time_string = (char *)ctime((time_t *)&timep);
-    
+
     /*start a new check, make a log entry and continue*/
     logfp = fopen("logfile","a"); /*open for appending only.*/
     log_fd = fileno(logfp);
@@ -595,23 +598,23 @@
     if(fdatasync(log_fd) == -1){
         fprintf(stderr,"Error! Cannot sync file data with disk.\n");
         exit(1);
-    }  
-    
+    }
+
     fclose(logfp);
     (void)sync();
-    
+
     /*
       Now check all random data files in this dir.
     */
     for(counter=0;counter<MAX_NUM_FILES;counter++){
-        
+
         fprintf(stderr, "%i.", counter);
-        
+
         /*create the filename in sequence. The number of files
           to check and the algorithm to create the filename is
           fixed and known in advance.*/
         sprintf(filename,"file%i",filenameCounter++);
-        
+
         if(!check_crc_ccitt(filename)){
             /*oops, checksum does not match. Make an entry into the log file
               and decide if we can continue or not.*/
@@ -625,10 +628,10 @@
             }
             fclose(logfp);
             (void)sync();
-            
+
             error = TRUE;
             errorCnt++;
-            
+
             if(errorCnt > MaxErrAllowed){
                 logfp = fopen("logfile","a"); /*open for appending only.*/
                 log_fd = fileno(logfp);
@@ -639,17 +642,17 @@
                 }
                 fclose(logfp);
                 (void)sync();
-                
+
                 fprintf(stderr, "Too many errors. See \"logfile\".\n");
                 exit(1);
             }/* if too many errors */
-            
+
             /*we have decided to continue, however first repair this file
               so that we do not cumulate errors across power cycles.*/
             make_new_file(filename);
         }
     }//for
-    
+
     /*all files checked, make a log entry and continue*/
     logfp = fopen("logfile","a"); /*open for appending only.*/
     log_fd = fileno(logfp);
@@ -657,36 +660,36 @@
     if(fdatasync(log_fd)){
         fprintf(stderr, "Error! cannot sync file buffer with disk.\n");
         exit(1);
-    }  
-    
+    }
+
     fclose(logfp);
     (void)sync();
-    
+
     /*now send a message to the remote power box and have it start a random
       pwer down timer after which power will be killed to this unit.
     */
     send_pwrdn_ok();
-    
-    /*now go into a forever loop of writing to files and CRC'ing them on 
+
+    /*now go into a forever loop of writing to files and CRC'ing them on
       a continious basis.*/
-    
+
     /*start from a random file #*/
     /*seed rand based on the current time*/
     seed = (unsigned int)time(NULL);
     srand(seed);
-    
+
     filenameCounter=(int)(1+(int)((float)(MAX_NUM_FILES-1)*rand()/(RAND_MAX+1.0)));
-    
+
     while(1){
-        
+
         for(;filenameCounter<MAX_NUM_FILES;filenameCounter++){
-            
+
             /*create the filename in sequence*/
             sprintf(filename,"file%i",filenameCounter);
             make_new_file(filename);
         }
         filenameCounter = 0;
     }
-    
+
     exit(0); /* though we will never reach here, but keeps the compiler happy*/
 }/*end main()*/

Index: comm.c
===================================================================
RCS file: /home/cvs/mtd/util/checkfs/comm.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- comm.c	21 Jun 2001 23:07:18 -0000	1.2
+++ comm.c	7 Nov 2005 11:15:17 -0000	1.3
@@ -11,6 +11,9 @@
 
   $Id$
   $Log$
+  Revision 1.3  2005/11/07 11:15:17  gleixner
+  [MTD / JFFS2] Clean up trailing white spaces
+
   Revision 1.2  2001/06/21 23:07:18  dwmw2
   Initial import to MTD CVS
 
@@ -19,7 +22,7 @@
   message) into another file "comm.c"
 
 
-  
+
  */
 
 #include <stdio.h>
@@ -38,7 +41,7 @@
 {
 
     char buf[200];
-    
+
     sprintf(buf, "ok to power me down!\nCount = %i\n", cycleCnt);
 
     if(write(fd, buf, strlen(buf)) < strlen(buf))

Index: makefiles.c
===================================================================
RCS file: /home/cvs/mtd/util/checkfs/makefiles.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- makefiles.c	21 Jun 2001 23:07:56 -0000	1.1
+++ makefiles.c	7 Nov 2005 11:15:17 -0000	1.2
@@ -12,7 +12,7 @@
  * limitations under the Licence.
 
  * $Id$
- 
+
 This program creates MAX_NUM_FILES files (file00001, file00002 etc) and
 fills them with random numbers till they are a random length. Then it checksums
 the files (with the checksum as the last two bytes) and closes the file.
@@ -85,7 +85,7 @@
   int len;
   char dataByte;
   int retry;
-  
+
   fp =   fopen(filename,"rb");
   if(!fp){
     printf("Verify checksum:Error! Cannot open filename passed for verify checksum: %s\n",filename);
@@ -123,7 +123,7 @@
 
 
 /*this routine opens a file 'filename' and checksumn's the entire
- contents, and then appends the checksum at the end of the file, 
+ contents, and then appends the checksum at the end of the file,
  closes the file and returns.
 */
 void checksum(char *filename){
@@ -133,7 +133,7 @@
   int len;
   char dataByte;
   int retry;
-  
+
   fp =   fopen(filename,"rb");
   if(!fp){
     printf("Error! Cannot open filename passed for checksum: %s\n",filename);
@@ -156,7 +156,7 @@
       printf("...bytes left to be read %i.\n\n",len);
       fclose(fp);
       exit(1);
-    } 
+    }
     crc = (crc >> 8) ^ crc_ccitt_table[(crc ^ dataByte) & 0xff];
   }
   crc ^= 0xffff;
@@ -169,7 +169,7 @@
   if(!fp){
     printf("Error! Cannot open filename to update checksum: %s\n",filename);
     exit(1);
-  } 
+  }
   if(fwrite(&crc, sizeof(crc), 1, fp) != 1){
     printf("error! unable to update the file for checksum.\n");
     fclose(fp);
@@ -177,14 +177,14 @@
   }
   fflush(fp);
   fclose(fp);
-  
-  
+
+
 }/*end checksum()*/
 
 
 
 int main(void){
-    
+
   FILE *fp, *cyclefp;
   int cycleCount;
   int rand_data;
@@ -196,7 +196,7 @@
   unsigned short numberFiles;
 
   numberFiles = MAX_NUM_FILES;
-  
+
   for(counter=0;counter<numberFiles;counter++){
     /*create the filename in sequence*/
     sprintf(filename,"file%i",filenameCounter++);
@@ -236,7 +236,7 @@
     /*now calculate the file checksum and append it to the end*/
     checksum(filename);
     /*this is just a test. Check the CRC to amek sure that it is OK.*/
-    check_crc_ccitt(filename);    
+    check_crc_ccitt(filename);
   }
 
   /*now make a file called "cycleCnt" and put a binary (int)0 in it.





More information about the linux-mtd-cvs mailing list