X-Git-Url: http://git.apps.os.sepia.ceph.com/?p=xfstests-dev.git;a=blobdiff_plain;f=ltp%2Fgrowfiles.c;h=7ac44aba0bede0f5e0ddf7ee8c47c46b0fd47bf3;hp=ab15c4348385dcd3a7dae3a076fe61a84febb4c2;hb=fb72f6f547d7f2ecb97f33858193e58119bb5a4d;hpb=131f750d7db38c7260b93e659d94fa7e4ea07ce0 diff --git a/ltp/growfiles.c b/ltp/growfiles.c index ab15c434..7ac44aba 100644 --- a/ltp/growfiles.c +++ b/ltp/growfiles.c @@ -1,19 +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 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. @@ -62,34 +50,30 @@ #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(); -int pre_alloc(); +int pre_alloc(char *file, int fd, int size); #define NEWIO 1 /* Use the tlibio.c functions */ @@ -798,7 +782,7 @@ extern int Forker_npids; /* num of forked pid, defined in forker.c */ break; case 'W': - sprintf( TagName, "(%.39s)", optarg ); + sprintf( TagName, "(%.37s)", optarg ); break; case 'y': @@ -1223,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, - 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); @@ -1269,7 +1253,7 @@ no whole file checking will be performed!\n", Progname, TagName, (int)getpid()); * 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); @@ -1393,7 +1377,7 @@ set_sig() #ifdef SIGRESTART case SIGRESTART: #endif /* SIGRESTART */ - case SIGCLD: + case SIGCHLD: break; default: @@ -1459,11 +1443,12 @@ notify_others() 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); + } } } @@ -2263,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, - Woffset, Grow_incr, Fileinfo.openflags, openflags2symbols(Fileinfo.openflags, ",", NULL)); + Woffset, Grow_incr, Fileinfo.openflags, openflags2symbols(Fileinfo.openflags, ",", 0)); fflush(stderr); return 1;