diff --git a/clients/fspprof.l b/clients/fspprof.l new file mode 100644 index 0000000..6808de8 --- /dev/null +++ b/clients/fspprof.l @@ -0,0 +1,92 @@ +%option nounput +%option noyyget_lineno +%option noyyset_lineno +%option noyyget_debug +%option noyyset_debug +%option noyyget_in +%option noyyget_out +%option noyyget_leng +%option noyyget_text +%option noyyset_in +%option noyyset_out +%option case-insensitive +%option never-interactive + +%{ +#include +#include "fhost.h" + +static struct fsp_host *host=NULL; +%} +DIGIT [0-9] +NUMBER {DIGIT}+ +WHITECHAR [ \t\n\r] +OPTWHITESPACE {WHITECHAR}* +WHITESPACE {WHITECHAR}+ +COMMENT #.*$ +IPADDRESS {NUMBER}\.{NUMBER}\.{NUMBER}\.{NUMBER} +HOSTNAME [[:alpha:]][\-._[:alnum:]]+ + /* stavy */ +%s shostname +%s shost +%s sport +%s salias +%s slport +%s sdir +%s sldir +%s sdelay +%s spassword +%s stimeout +%% +{COMMENT} /* ignore comments */ +^{WHITESPACE} /* ignore whitespace at begining of line */ +^{OPTWHITESPACE}(host|machine){WHITESPACE} { + add_host(host); + host=NULL; + BEGIN(shostname); + } +{HOSTNAME} { + host=init_host(); + /* printf("host %s!\n",yytext); */ + host->hostname=strdup(yytext); + BEGIN(shost); + } +{IPADDRESS} { + host=init_host(); + /* printf("ihost %s!\n",yytext); */ + host->hostaddr=strdup(yytext); + BEGIN(shost); + } +.|\n fprintf(stderr,"invalid hostname `%s`\n",yytext);BEGIN(INITIAL); +(fsp{WHITESPACE})?port BEGIN(sport); +{WHITESPACE} +{NUMBER} host->port=atoi(yytext);BEGIN(shost); +.|\n fprintf(stderr,"invalid port `%s`\n",yytext);BEGIN(shost); +alias{WHITESPACE} BEGIN(salias); +{HOSTNAME} add_host_alias(host,yytext);BEGIN(shost); +local{WHITESPACE}port BEGIN(slport); +{WHITESPACE} +{NUMBER} host->local_port=atoi(yytext);BEGIN(shost); +(fsp{WHITESPACE})?directory{WHITESPACE} BEGIN(sdir); +\/[[:graph:]]* host->dir=strdup(yytext);BEGIN(shost); +.|\n fprintf(stderr,"invalid directory `%s`\n",yytext);BEGIN(shost); +local{WHITESPACE}directory{WHITESPACE} BEGIN(sldir); +[[:graph:]]* host->local_dir=strdup(yytext);BEGIN(shost); +.|\n fprintf(stderr,"invalid local directory `%s`\n",yytext);BEGIN(shost); +delay BEGIN(sdelay); +{WHITESPACE} +{NUMBER} host->delay=atoi(yytext);BEGIN(shost); +.|\n fprintf(stderr,"invalid delay `%s`\n",yytext);BEGIN(shost); +timeout BEGIN(stimeout); +{WHITESPACE} +{NUMBER} host->timeout=atoi(yytext);BEGIN(shost); +.|\n fprintf(stderr,"invalid timeout `%s`\n",yytext);BEGIN(shost); +trace{WHITESPACE}on host->trace=1; +trace{WHITESPACE}off host->trace=0; +password{WHITESPACE} BEGIN(spassword); +[[:graph:]]+ host->password=strdup(yytext);BEGIN(shost); +<> add_host(host);host=NULL;yyterminate(); + +{WHITECHAR} /* ignore */ +. fprintf(stderr," %s",yytext);/* no default rule */ +%% diff --git a/tests/mklargefile.c b/tests/mklargefile.c new file mode 100644 index 0000000..d1fa3f5 --- /dev/null +++ b/tests/mklargefile.c @@ -0,0 +1,62 @@ +/* this file is public domain */ +/* return values: + * 3 - invocation error + * 2 - no LFS support + * 1 - file creation failed + * 0 - okay! + */ + +#include "tweak.h" +#include +#include +#include +#include +#include +#include + +int main(int argc,char *argv[]) +{ + off_t GB=1024*1024*1024; + FILE *fd; + off_t pos; + float size; + + if(argc<3) + { + printf("Makes a large file with hole using fseeko\n"); + printf("%s \n",argv[0]); + return 3; + } + + fd = fopen(argv[1],"w"); + if(fd == NULL) + { + perror("fopen"); + return 1; + } + size=atof(argv[2]); +#if SIZEOF_OFF_T <= 4 + if(size>2) + { + printf("You do not have LFS your system.\nMaximum supported filesize is 2 GB.\n"); + return 2; + } +#endif + pos=size*GB; + if(fseeko(fd,pos,SEEK_SET)) + { + perror("fseeko"); + return 1; + } + if(fwrite("!",1,1,fd)<1) + { + perror("write"); + return 1; + } + if(fclose(fd)) + { + perror("fclose"); + return 1; + } + return 0; +}