ltp/fsx: drop caches if we're doing closeopen
[xfstests-dev.git] / ltp / growfiles.c
index ddad712d4001b250d23a3cdb8d2af7ea07df644a..7ac44aba0bede0f5e0ddf7ee8c47c46b0fd47bf3 100644 (file)
@@ -1,33 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
 /*
- * Copyright (c) 2000 Silicon Graphics, Inc.  All Rights Reserved.
- * 
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- * 
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- * 
- * Further, this software is distributed without any warranty that it is
- * free of the rightful claim of any third person regarding infringement
- * or the like.  Any license provided herein, whether implied or
- * otherwise, applies only to this software file.  Patent licenses, if
- * any, provided herein do not apply to combinations of this program with
- * other software, or any other product whatsoever.
- * 
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc., 59
- * Temple Place - Suite 330, Boston MA 02111-1307, USA.
- * 
- * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
- * Mountain View, CA  94043, or:
- * 
- * http://www.sgi.com 
- * 
- * For further information regarding this notice, see: 
- * 
- * http://oss.sgi.com/projects/GenInfo/NoticeExplan/
+ * Copyright (c) 2000 Silicon Graphics, Inc.
+ * All Rights Reserved.
  */
 /*
  * This program will grow a list of files.
  */
 /*
  * This program will grow a list of files.
 #include "dataascii.h"
 #include "random_range.h"
 #include "databin.h"
 #include "dataascii.h"
 #include "random_range.h"
 #include "databin.h"
-
-
-extern char *openflags2symbols();
-
-extern int parse_open_flags();
-extern int background();
-extern int forker();
-extern int datapidgen();
-extern void databingen();
-extern int datapidchk();
-extern int databinchk();
-extern int file_lock();
-
-int file_size();
-int check_write();
-int shrinkfile();
-int check_file();
-int growfile();
+#include "open_flags.h"
+#include "forker.h"
+#include "file_lock.h"
+
+extern int datapidgen(int pid, unsigned char *buffer, int bsize, int offset);
+extern void databingen(int mode, unsigned char *buffer, int bsize, int offset);
+extern int datapidchk(int pid, char *buffer, int bsize, int offset, char **errmsg);
+extern int databinchk(int mode, char *buffer, int bsize, int offset, char **errmsg);
+
+int file_size(int fd);
+int check_write(int fd, int cf_inter, char *filename, int mode);
+int shrinkfile(int fd, char *filename, int trunc_incr, int trunc_inter, int just_trunc);
+int check_file(int fd, int cf_inter, char *filename, int no_file_check);
+int growfile(int fd, char *file, int grow_incr, unsigned char *buf);
 int cleanup();
 int handle_error();
 int cleanup();
 int handle_error();
-int lkfile();
+int lkfile(int fd, int operation, int lklevel);
 void usage();
 void help();
 void usage();
 void help();
-void prt_examples();
+void prt_examples(FILE *stream);
 int set_sig();
 void sig_handler();
 static void notify_others();
 int set_sig();
 void sig_handler();
 static void notify_others();
-#ifndef NO_XFS
-int pre_alloc();
-#endif
+int pre_alloc(char *file, int fd, int size);
 
 
 #define NEWIO  1       /* Use the tlibio.c functions */
 
 
 #define NEWIO  1       /* Use the tlibio.c functions */
@@ -182,11 +150,7 @@ int mult_size=1;           /* when random iosz, iosz must be mult of mult_size */
 /* the *_lseek variables are only used when radon lseek option (-R) is used */
 int min_lseek=0;               /* also set in option parsing */
 int max_lseek=-1;              /* -1 means size of file */
 /* the *_lseek variables are only used when radon lseek option (-R) is used */
 int min_lseek=0;               /* also set in option parsing */
 int max_lseek=-1;              /* -1 means size of file */
-#ifdef CRAY
-int Pattern=PATTERN_OFFSET;    /* This pattern is 64 bit word based */
-#else
 int Pattern=PATTERN_ASCII;
 int Pattern=PATTERN_ASCII;
-#endif
 int Seed=-1;                   /* random number seed, < 0 == uninitialized  */
 int Nseeds=0;                  /* Number of seed specified by the user */
 int *Seeds;                    /* malloc'ed arrary of ints holding user spec seeds */
 int Seed=-1;                   /* random number seed, < 0 == uninitialized  */
 int Nseeds=0;                  /* Number of seed specified by the user */
 int *Seeds;                    /* malloc'ed arrary of ints holding user spec seeds */
@@ -243,32 +207,6 @@ struct fileinfo_t {
  * to use.
  */
 int Open_flags[] = { 
  * to use.
  */
 int Open_flags[] = { 
-#ifdef CRAY
-       O_RDWR|O_CREAT,
-       O_RDWR|O_CREAT|O_RAW,
-       O_RDWR|O_CREAT|O_BIG,
-       O_RDWR|O_CREAT|O_APPEND,
-       O_RDWR|O_CREAT|O_NDELAY,
-       O_RDWR|O_CREAT|O_PLACE,
-       O_RDWR|O_CREAT|O_SYNC,
-       O_RDWR|O_CREAT|O_RAW|O_SYNC,
-       O_RDWR|O_CREAT|O_NDELAY|O_SYNC,
-       O_RDWR|O_CREAT|O_NDELAY|O_SYNC|O_BIG,
-       O_RDWR|O_CREAT|O_RAW,
-       O_RDWR|O_CREAT|O_RAW|O_APPEND,
-       O_RDWR|O_CREAT|O_RAW|O_BIG,
-       O_RDWR|O_CREAT|O_RAW|O_APPEND|O_BIG,
-/***
- * O_WELLFORMED makes -o random require well formed i/o
- ***/
-#if ALLOW_O_WELLFORMED
-#if O_PARALLEL
-       O_RDWR|O_CREAT|O_PARALLEL|O_WELLFORMED|O_RAW,
-       O_RDWR|O_CREAT|O_PARALLEL|O_WELLFORMED|O_RAW|O_TRUNC,
-#endif /* O_PARALLEL */
-#endif
-
-#else /* CRAY */
        O_RDWR|O_CREAT,
        O_RDWR|O_CREAT|O_APPEND,
        O_RDWR|O_CREAT|O_NDELAY,
        O_RDWR|O_CREAT,
        O_RDWR|O_CREAT|O_APPEND,
        O_RDWR|O_CREAT|O_NDELAY,
@@ -276,7 +214,6 @@ int Open_flags[] = {
        O_RDWR|O_CREAT|O_SYNC|O_NDELAY,
        O_RDWR|O_CREAT|O_APPEND|O_NDELAY,
 
        O_RDWR|O_CREAT|O_SYNC|O_NDELAY,
        O_RDWR|O_CREAT|O_APPEND|O_NDELAY,
 
-#endif /* CRAY */
 };
 
 #define REXEC_INIT     0       /* don't do re-exec of childern */
 };
 
 #define REXEC_INIT     0       /* don't do re-exec of childern */
@@ -284,11 +221,7 @@ int Open_flags[] = {
 #define REXEC_DONE     2       /* We've already been re-exec'ed */
 
 #ifndef BSIZE
 #define REXEC_DONE     2       /* We've already been re-exec'ed */
 
 #ifndef BSIZE
-#ifdef CRAY
-#define BSIZE  1024
-#else
 #define BSIZE  512
 #define BSIZE  512
-#endif  /* CRAY */
 #endif  /* BSIZE */
 
 #define USECS_PER_SEC  1000000  /* microseconds per second */
 #endif  /* BSIZE */
 
 #define USECS_PER_SEC  1000000  /* microseconds per second */
@@ -342,9 +275,7 @@ int tmp;
 char chr;
 int ret;
 int pre_alloc_space = 0;
 char chr;
 int ret;
 int pre_alloc_space = 0;
-#ifndef NO_XFS
 int total_grow_value = 0;      /* used in pre-allocations */
 int total_grow_value = 0;      /* used in pre-allocations */
-#endif
 int backgrnd = 1;              /* return control to user */
 struct stat statbuf;
 int time_iterval = -1;
 int backgrnd = 1;              /* return control to user */
 struct stat statbuf;
 int time_iterval = -1;
@@ -442,9 +373,6 @@ extern int Forker_npids;    /* num of forked pid, defined in forker.c */
 
                case 'd':
                        auto_dir=optarg;
 
                case 'd':
                        auto_dir=optarg;
-#ifdef CRAY
-                       unsetenv("TMPDIR");     /* force the use of auto_dir */
-#endif
                        if ( stat(auto_dir, &statbuf) == -1 ) {
                            if ( mkdir(auto_dir, 0777) == -1 ) {
                                if ( errno != EEXIST ) {
                        if ( stat(auto_dir, &statbuf) == -1 ) {
                            if ( mkdir(auto_dir, 0777) == -1 ) {
                                if ( errno != EEXIST ) {
@@ -616,28 +544,15 @@ extern int Forker_npids;  /* num of forked pid, defined in forker.c */
 
 
                case 'p' :      /* pre allocate space */
 
 
                case 'p' :      /* pre allocate space */
-#ifdef NO_XFS
                        printf("%s%s: --p is illegal option on this system\n",
                                Progname, TagName);
                        exit(1);
                        printf("%s%s: --p is illegal option on this system\n",
                                Progname, TagName);
                        exit(1);
-#else
-                       pre_alloc_space++;
-#endif
                        break;
 
                case 'P':
                        break;
 
                case 'P':
-#ifdef CRAY
-                       if (strcmp(optarg, "PANIC") != 0 ) {
-                               fprintf(stderr, "%s%s: --P arg must be PANIC\n", Progname, TagName);
-                               exit(1);
-                       }
-                       Upanic_on_error++;
-                       printf("%s: Will call upanic after writes\n");
-#else
                        printf("%s%s: --P is illegal option on non-cray system\n",
                                Progname, TagName);
                        exit(1);
                        printf("%s%s: --P is illegal option on non-cray system\n",
                                Progname, TagName);
                        exit(1);
-#endif
                        break;
 
                case 'q':       /* file content or pattern */
                        break;
 
                case 'q':       /* file content or pattern */
@@ -867,7 +782,7 @@ extern int Forker_npids;    /* num of forked pid, defined in forker.c */
                        break;
 
                case 'W':
                        break;
 
                case 'W':
-                       sprintf( TagName, "(%.39s)", optarg );
+                       sprintf( TagName, "(%.37s)", optarg );
                        break;
 
                case 'y':
                        break;
 
                case 'y':
@@ -918,11 +833,6 @@ no whole file checking will be performed!\n", Progname, TagName, (int)getpid());
            background(Progname);       /* give user their prompt back */
        }
 
            background(Progname);       /* give user their prompt back */
        }
 
-#if CRAY
-       if ( Sync_with_others )
-          setpgrp();
-#endif
-
        if ( Debug > 3 ) {
 #if NEWIO
            lio_set_debug(Debug-3);
        if ( Debug > 3 ) {
 #if NEWIO
            lio_set_debug(Debug-3);
@@ -1176,10 +1086,9 @@ no whole file checking will be performed!\n", Progname, TagName, (int)getpid());
        /*
         * construct auto filename and insert them into filenames space
         */
        /*
         * construct auto filename and insert them into filenames space
         */
-               
        for(ind=0;ind<num_auto_files; ind++, num++) {
        for(ind=0;ind<num_auto_files; ind++, num++) {
-               sprintf((char *)filenames+(num*PATH_MAX), "%s.%d",
-                       tempnam(auto_dir, auto_file), ind );
+               sprintf((char *)filenames+(num*PATH_MAX), "%s/%s.%d",
+                       auto_dir, auto_file, ind);
        }
 
        /*
        }
 
        /*
@@ -1214,7 +1123,6 @@ no whole file checking will be performed!\n", Progname, TagName, (int)getpid());
                        Progname, Pid, num_files);
        }
 
                        Progname, Pid, num_files);
        }
 
-#ifndef NO_XFS
        if ( pre_alloc_space ) {
                if ( iterations == 0 ) {
                    fprintf(stderr, "%s%s: %d %s/%d: can NOT pre-alloc and grow forever\n",
        if ( pre_alloc_space ) {
                if ( iterations == 0 ) {
                    fprintf(stderr, "%s%s: %d %s/%d: can NOT pre-alloc and grow forever\n",
@@ -1237,23 +1145,13 @@ no whole file checking will be performed!\n", Progname, TagName, (int)getpid());
                        total_grow_value=bytes_to_consume;
                }
        }
                        total_grow_value=bytes_to_consume;
                }
        }
-#endif
 
        /*
         * If delaying between iterations, get amount time to
         * delaysecs in clocks or usecs.
 
        /*
         * If delaying between iterations, get amount time to
         * delaysecs in clocks or usecs.
-        * If on the CRAY, delaytime is in clocks since
-        * _rtc() will be used, which does not have the overhead
-         * of gettimeofday(2).
         */
        if ( delaysecs ) {
         */
        if ( delaysecs ) {
-#if CRAY
-          int hz;
-          hz=sysconf(_SC_CLK_TCK);
-          delaytime=(int)((float)hz * delaysecs);
-#else
           delaytime=(int)((float)USECS_PER_SEC * delaysecs);
           delaytime=(int)((float)USECS_PER_SEC * delaysecs);
-#endif
         }
 
        /*
         }
 
        /*
@@ -1309,7 +1207,7 @@ no whole file checking will be performed!\n", Progname, TagName, (int)getpid());
                if ( Debug > 3 ) {
                    printf("%s: %d DEBUG3 %s/%d: %d Open filename = %s, open flags = %#o %s\n",
                        Progname, Pid, __FILE__, __LINE__, Iter_cnt, filename, ret, 
                if ( Debug > 3 ) {
                    printf("%s: %d DEBUG3 %s/%d: %d Open filename = %s, open flags = %#o %s\n",
                        Progname, Pid, __FILE__, __LINE__, Iter_cnt, filename, ret, 
-                       openflags2symbols(ret, ",", NULL));
+                       openflags2symbols(ret, ",", 0));
                } else if ( Debug > 2 ) {
                    printf("%s: %d DEBUG3 %s/%d: %d filename = %s, open flags = %#o\n",
                        Progname, Pid, __FILE__, __LINE__, Iter_cnt, filename, ret);
                } else if ( Debug > 2 ) {
                    printf("%s: %d DEBUG3 %s/%d: %d filename = %s, open flags = %#o\n",
                        Progname, Pid, __FILE__, __LINE__, Iter_cnt, filename, ret);
@@ -1330,7 +1228,6 @@ no whole file checking will be performed!\n", Progname, TagName, (int)getpid());
 
                lkfile(fd, LOCK_EX, LKLVL1);   /* lock if lockfile is LKLVL1 */
 
 
                lkfile(fd, LOCK_EX, LKLVL1);   /* lock if lockfile is LKLVL1 */
 
-#ifndef NO_XFS
                /*
                 * preallocation is only done once, if specified.
                 */
                /*
                 * preallocation is only done once, if specified.
                 */
@@ -1348,7 +1245,6 @@ no whole file checking will be performed!\n", Progname, TagName, (int)getpid());
                        Iter_cnt=0;     /* reset outside loop to restart from one */
                        continue;
                }
                        Iter_cnt=0;     /* reset outside loop to restart from one */
                        continue;
                }
-#endif
 
                /*
                 * grow file by desired amount.
 
                /*
                 * grow file by desired amount.
@@ -1357,7 +1253,7 @@ no whole file checking will be performed!\n", Progname, TagName, (int)getpid());
                 * if we are dealing with a FIFO file.
                 */
 
                 * if we are dealing with a FIFO file.
                 */
 
-               if (growfile(fd, filename, grow_incr, Buffer) != 0 ) {
+               if (growfile(fd, filename, grow_incr, (unsigned char *)Buffer) != 0 ) {
                        handle_error();
                        lkfile(fd, LOCK_UN, LKLVL1);   /* release lock */
                        close(fd);
                        handle_error();
                        lkfile(fd, LOCK_UN, LKLVL1);   /* release lock */
                        close(fd);
@@ -1413,13 +1309,6 @@ no whole file checking will be performed!\n", Progname, TagName, (int)getpid());
                if ( delaytime ) {
                
                    int ct, end;
                if ( delaytime ) {
                
                    int ct, end;
-#ifdef CRAY
-                   ct=_rtc();
-                   end=ct+delaytime;
-                   while ( ct < end ) {
-                       ct = _rtc();
-                   }
-#else
                    struct timeval curtime;
                    gettimeofday(&curtime, NULL);
                    ct=curtime.tv_sec*USECS_PER_SEC + curtime.tv_usec;
                    struct timeval curtime;
                    gettimeofday(&curtime, NULL);
                    ct=curtime.tv_sec*USECS_PER_SEC + curtime.tv_usec;
@@ -1429,10 +1318,8 @@ no whole file checking will be performed!\n", Progname, TagName, (int)getpid());
                        gettimeofday(&curtime, NULL);
                        ct=curtime.tv_sec*USECS_PER_SEC + curtime.tv_usec;
                    }
                        gettimeofday(&curtime, NULL);
                        ct=curtime.tv_sec*USECS_PER_SEC + curtime.tv_usec;
                    }
-#endif
                }
            }
                }
            }
-#ifndef NO_XFS
            /*
             * if Iter_cnt == 0, then we pre allocated space to all files
             * and we are starting outside loop over.  Set pre_alloc_space
            /*
             * if Iter_cnt == 0, then we pre allocated space to all files
             * and we are starting outside loop over.  Set pre_alloc_space
@@ -1441,9 +1328,6 @@ no whole file checking will be performed!\n", Progname, TagName, (int)getpid());
            if ( Iter_cnt == 0 ) {
                pre_alloc_space=0;
            }
            if ( Iter_cnt == 0 ) {
                pre_alloc_space=0;
            }
-#endif
-
-
        }   /* end iteration for loop */
 
 
        }   /* end iteration for loop */
 
 
@@ -1487,26 +1371,17 @@ set_sig()
                 case SIGKILL:
                 case SIGSTOP:
                 case SIGCONT:
                 case SIGKILL:
                 case SIGSTOP:
                 case SIGCONT:
-#ifdef CRAY
-                case SIGINFO:
-                case SIGRECOVERY:
-#endif /* CRAY */
 #ifdef SIGCKPT
                case SIGCKPT:
 #endif /* SIGCKPT */
 #ifdef SIGRESTART
                case SIGRESTART:
 #endif /* SIGRESTART */
 #ifdef SIGCKPT
                case SIGCKPT:
 #endif /* SIGCKPT */
 #ifdef SIGRESTART
                case SIGRESTART:
 #endif /* SIGRESTART */
-                case SIGCLD:
+                case SIGCHLD:
                     break;
 
                 default:
                     break;
 
                 default:
-#ifdef sgi
-                   sigset( sig, sig_handler );
-#else
-/* linux and cray */
                     signal(sig, sig_handler);
                     signal(sig, sig_handler);
-#endif
                 break;
             }
         } /* endfor */
                 break;
             }
         } /* endfor */
@@ -1527,9 +1402,7 @@ int sig;
     if ( sig == SIGUSR2 ) {
        fprintf(stdout, "%s%s: %d %s/%d: received SIGUSR2 (%d) - stopping.\n",
            Progname, TagName, Pid, __FILE__, __LINE__, sig);
     if ( sig == SIGUSR2 ) {
        fprintf(stdout, "%s%s: %d %s/%d: received SIGUSR2 (%d) - stopping.\n",
            Progname, TagName, Pid, __FILE__, __LINE__, sig);
-#ifndef sgi
         signal(sig, sig_handler);      /* allow us to get this signal more than once */
         signal(sig, sig_handler);      /* allow us to get this signal more than once */
-#endif
         
     } else if( sig == SIGINT ){
        /* The user has told us to cleanup, don't pretend it's an error. */
         
     } else if( sig == SIGINT ){
        /* The user has told us to cleanup, don't pretend it's an error. */
@@ -1567,23 +1440,16 @@ notify_others()
 
     if ( Sync_with_others && send_signals == 0 ) {
 
 
     if ( Sync_with_others && send_signals == 0 ) {
 
-#if CRAY
-       send_signals=1; /* only send signals once */
-       if ( Debug > 1 )
-           printf("%s%s: %d DEBUG2 %s/%d: Sending SIGUSR2 to pgrp\n",
-                 Progname, TagName, Pid, __FILE__, __LINE__);
-       killm(C_PGRP, getpgrp(), SIGUSR2);
-#else
        send_signals=1; /* only send signals once */
 
         for (ind=0; ind< Forker_npids; ind++) {
        send_signals=1; /* only send signals once */
 
         for (ind=0; ind< Forker_npids; ind++) {
-           if ( Forker_pids[ind] != Pid )
+           if ( Forker_pids[ind] != Pid ) {
                if ( Debug > 1 )
                    printf("%s%s: %d DEBUG2 %s/%d: Sending SIGUSR2 to pid %d\n",
                        Progname, TagName, Pid, __FILE__, __LINE__, Forker_pids[ind]);
                kill(Forker_pids[ind], SIGUSR2);
                if ( Debug > 1 )
                    printf("%s%s: %d DEBUG2 %s/%d: Sending SIGUSR2 to pid %d\n",
                        Progname, TagName, Pid, __FILE__, __LINE__, Forker_pids[ind]);
                kill(Forker_pids[ind], SIGUSR2);
+           }
         }
         }
-#endif
     }
 
 }
     }
 
 }
@@ -1598,12 +1464,6 @@ handle_error()
 {
     Errors++;
 
 {
     Errors++;
 
-#ifdef CRAY
-    if ( Errors & Upanic_on_error ) {
-        upanic(PA_PANIC);
-    }
-#endif
-
     if ( Maxerrs && Errors >= Maxerrs ) {
        printf("%s%s: %d %s/%d: %d Hit max errors value of %d\n", 
            Progname, TagName, Pid, __FILE__, __LINE__, Iter_cnt, Maxerrs);
     if ( Maxerrs && Errors >= Maxerrs ) {
        printf("%s%s: %d %s/%d: %d Hit max errors value of %d\n", 
            Progname, TagName, Pid, __FILE__, __LINE__, Iter_cnt, Maxerrs);
@@ -2045,25 +1905,6 @@ unsigned char *buf;
                                        Progname, TagName, __FILE__, __LINE__, errno, strerror(errno) );
                                return -1;
                        }
                                        Progname, TagName, __FILE__, __LINE__, errno, strerror(errno) );
                                return -1;
                        }
-#if NEWIO
-#ifdef sgi
-                       /* If this is POSIX I/O and it is via aio_{read,write}
-                        * or lio_listio then after completion of the I/O the
-                        * value of the file offset for the file is
-                        * unspecified--which means we cannot trust what
-                        * tell() told us.  Fudge it here.
-                        */
-                       if( (io_type & LIO_IO_ASYNC_TYPES) || (io_type & LIO_RANDOM) ){
-                               if( tmp != Woffset + grow_incr ){
-                                       if( Debug > 5 ){
-                                               printf("%s: %d DEBUG6 %s/%d: posix fudge, forcing tmp (%d) to match Woffset+grow_incr (%d)\n",
-                                                      Progname, Pid, __FILE__, __LINE__, tmp, Woffset+grow_incr);
-                                       }
-                                       tmp = Woffset + grow_incr;
-                               }
-                       }
-#endif
-#endif
                }
 
                lkfile(fd, LOCK_UN, LKLVL0);    
                }
 
                lkfile(fd, LOCK_UN, LKLVL0);    
@@ -2155,9 +1996,6 @@ int just_trunc;           /* lseek has already been done for you */
     int cur_offset;
     int new_offset;
     int ret;
     int cur_offset;
     int new_offset;
     int ret;
-#ifdef CRAY
-    int offset;
-#endif
 
        shrink_cnt++;
 
 
        shrink_cnt++;
 
@@ -2199,19 +2037,6 @@ int just_trunc;          /* lseek has already been done for you */
             else {
                 new_offset=random_range(min_lseek, max_lseek, 1, NULL);
             }
             else {
                 new_offset=random_range(min_lseek, max_lseek, 1, NULL);
             }
-
-#ifdef CRAY
-            if ((offset=lseek(fd, new_offset, SEEK_SET)) == -1 ) {
-                fprintf(stderr, "%s%s: %d %s/%d: lseek(%d, %d, SEEK_SET) l3 failed: %s\n",
-                    Progname, TagName, Pid, __FILE__, __LINE__, fd, new_offset, strerror(errno));
-               lkfile(fd, LOCK_UN, LKLVL0);
-                return -1;
-            }
-            else if ( Debug > 3 )
-                printf("%s: %d DEBUG4 %s/%d: lseeked to random offset %d\n",
-                    Progname, Pid, __FILE__, __LINE__, offset);
-    
-#endif
         }
 
        else {  /* remove trunc_incr from file */
         }
 
        else {  /* remove trunc_incr from file */
@@ -2220,41 +2045,19 @@ int just_trunc;         /* lseek has already been done for you */
 
            if ( new_offset < 0 )
                new_offset=0;
 
            if ( new_offset < 0 )
                new_offset=0;
-       
-#ifdef CRAY
-           if (  lseek(fd, new_offset, SEEK_SET) == -1 ) {
-               fprintf(stderr, "%s%s: %d %s/%d: lseek(fd, %d, SEEK_SET) l4 failed: %s\n",
-                       Progname, TagName, Pid, __FILE__, __LINE__, new_offset, strerror(errno));
-               lkfile(fd, LOCK_UN, LKLVL0);
-               return -1;
-           }
-            else if ( Debug > 3 )
-                printf("%s: %d DEBUG4 %s/%d: lseeked to offset %d, %d bytes from end\n",
-                    Progname, Pid, __FILE__, __LINE__, new_offset, trunc_incr);
-#endif
        }
 
        }
 
-
-#ifdef CRAY
-       ret=trunc(fd);
-#else
        ret=ftruncate(fd, new_offset );
        if( (ret == 0) && (Debug > 3) ){
                 printf("%s: %d DEBUG4 %s/%d: ftruncated to offset %d, %d bytes from end\n",
                     Progname, Pid, __FILE__, __LINE__, new_offset, trunc_incr);
        }
        ret=ftruncate(fd, new_offset );
        if( (ret == 0) && (Debug > 3) ){
                 printf("%s: %d DEBUG4 %s/%d: ftruncated to offset %d, %d bytes from end\n",
                     Progname, Pid, __FILE__, __LINE__, new_offset, trunc_incr);
        }
-#endif
 
        lkfile(fd, LOCK_UN, LKLVL0);
 
        if ( ret == -1 ) {
 
        lkfile(fd, LOCK_UN, LKLVL0);
 
        if ( ret == -1 ) {
-#ifdef CRAY
-               fprintf(stderr, "%s%s: %d %s/%d: trunc failed: %s\n",
-                       Progname, TagName, Pid, __FILE__, __LINE__, strerror(errno));
-#else
                fprintf(stderr, "%s%s: %d %s/%d: ftruncate failed: %s\n",
                        Progname, TagName, Pid, __FILE__, __LINE__, strerror(errno));
                fprintf(stderr, "%s%s: %d %s/%d: ftruncate failed: %s\n",
                        Progname, TagName, Pid, __FILE__, __LINE__, strerror(errno));
-#endif
                return -1;
        }
 
                return -1;
        }
 
@@ -2445,7 +2248,7 @@ int mode;       /* write mode */
        if ( Debug > 0 )
            printf("%s%s: %d DEBUG1 %s/%d: **fd:%d, lk:%d, offset:%d, sz:%d open flags:%#o %s\n",
                Progname, TagName, Pid, __FILE__, __LINE__, fd, lockfile, 
        if ( Debug > 0 )
            printf("%s%s: %d DEBUG1 %s/%d: **fd:%d, lk:%d, offset:%d, sz:%d open flags:%#o %s\n",
                Progname, TagName, Pid, __FILE__, __LINE__, fd, lockfile, 
-               Woffset, Grow_incr, Fileinfo.openflags, openflags2symbols(Fileinfo.openflags, ",", NULL));
+               Woffset, Grow_incr, Fileinfo.openflags, openflags2symbols(Fileinfo.openflags, ",", 0));
 
        fflush(stderr);
        return 1;
 
        fflush(stderr);
        return 1;
@@ -2760,7 +2563,6 @@ lkfile(int fd, int operation, int lklevel)
    return 0;
 }
 
    return 0;
 }
 
-#ifndef NO_XFS
 /***********************************************************************
  *
  ***********************************************************************/
 /***********************************************************************
  *
  ***********************************************************************/
@@ -2771,18 +2573,6 @@ int fd;
 int size;
 {
 
 int size;
 {
 
-#ifdef CRAY
-    long avl;
-
-        if ( ialloc(fd, size, IA_CONT, &avl) == -1 ) {
-                fprintf(stderr, "%s%s %s/%d: Unable to pre-alloc space: ialloc failed: %d  %s\n",
-                       Progname, TagName,
-                        __FILE__, __LINE__, errno, strerror(errno));
-                return -1;
-        }
-#endif
-
-#ifndef NO_XFS
 #ifdef XFS_IOC_RESVSP
     struct xfs_flock64 f;
 
 #ifdef XFS_IOC_RESVSP
     struct xfs_flock64 f;
 
@@ -2811,9 +2601,7 @@ int size;
                         __FILE__, __LINE__, errno, strerror(errno));
                return -1;
        }
                         __FILE__, __LINE__, errno, strerror(errno));
                return -1;
        }
-#endif
 #endif
 
        return 0;
 }
 #endif
 
        return 0;
 }
-#endif