Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <sys/types.h>
- #include <sys/stat.h>
- #include <fcntl.h>
- #include <unistd.h>
- #include <string.h>
- #include <aio.h>
- #define MB 1024
- int sukurti(char *name);
- int fill(const int d, struct aiocb *aiorp, void *buf, const int count);
- int sukurti(char *name){
- int dskr;
- dskr = open( name, O_RDONLY );
- if( dskr == -1 ){
- printf("Failas sukurtas, nes jo nebuvo\n");
- dskr = open( name, O_WRONLY | O_CREAT, 0644);
- }else{
- printf("Jau yra toks failas!\n");
- exit(1);
- }
- return dskr;
- }
- int fill(const int d, struct aiocb *aiorp, void *buf, const int count){
- int rv = 0;
- memset( (void *)aiorp, 'A', sizeof( struct aiocb ) );
- aiorp->aio_fildes = d;
- aiorp->aio_buf = buf;
- aiorp->aio_nbytes = count;
- aiorp->aio_offset = 0;
- rv = aio_write( aiorp );
- return rv;
- }
- int main(int argc, char * argv[]){
- int des;
- int rv;
- struct aiocb aior;
- int x = atoi(argv[2]);
- printf("%d\n", x);
- int size = MB * MB * x;
- char buffer[size];
- if(argc == 3){
- printf("just %s\n", argv[1]);
- des = sukurti(argv[1]);
- rv = fill(des, &aior, buffer, sizeof(buffer));
- }else{
- printf("Blogas\n");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement