+// 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 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. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
* This program will grow a list of files.
#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 lkfile();
+int lkfile(int fd, int operation, int lklevel);
void usage();
void help();
-void prt_examples();
+void prt_examples(FILE *stream);
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 */
char chr;
int ret;
int pre_alloc_space = 0;
-#ifndef NO_XFS
int total_grow_value = 0; /* used in pre-allocations */
-#endif
int backgrnd = 1; /* return control to user */
struct stat statbuf;
int time_iterval = -1;
case 'p' : /* pre allocate space */
-#ifdef NO_XFS
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 'W':
- sprintf( TagName, "(%.39s)", optarg );
+ sprintf( TagName, "(%.37s)", optarg );
break;
case 'y':
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",
total_grow_value=bytes_to_consume;
}
}
-#endif
/*
* If delaying between iterations, get amount time to
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);
lkfile(fd, LOCK_EX, LKLVL1); /* lock if lockfile is LKLVL1 */
-#ifndef NO_XFS
/*
* preallocation is only done once, if specified.
*/
Iter_cnt=0; /* reset outside loop to restart from one */
continue;
}
-#endif
/*
* grow file by desired amount.
* 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);
}
}
}
-#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 ) {
pre_alloc_space=0;
}
-#endif
-
-
} /* end iteration for loop */
#ifdef SIGRESTART
case SIGRESTART:
#endif /* SIGRESTART */
- case SIGCLD:
+ case SIGCHLD:
break;
default:
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 > 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;
return 0;
}
-#ifndef NO_XFS
/***********************************************************************
*
***********************************************************************/
int size;
{
-#ifndef NO_XFS
#ifdef XFS_IOC_RESVSP
struct xfs_flock64 f;
__FILE__, __LINE__, errno, strerror(errno));
return -1;
}
-#endif
#endif
return 0;
}
-#endif