Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <ftw.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <stdint.h>
- #include <dlfcn.h>
- #include <fcntl.h>
- #include <unistd.h>
- #include <errno.h>
- #include <aio.h>
- int main(int argc, char *argv[])
- {
- if (argc != 3)
- {
- printf("netinkamas argumentu kiekis");
- exit(255);
- }
- int number = atoi(argv[2]);
- if (number < 0)
- {
- printf("Skaicius turi buti teigiamas\n");
- exit(254);
- }
- int fd = open(argv[1], O_CREAT | O_RDWR | O_EXCL, S_IRUSR | S_IWUSR);
- if (fd < 0) {
- if (errno == EEXIST)
- {
- printf("Failas jau yra.\n");
- exit(254);
- }
- }
- else
- {
- #define BUF_SIZE number*1024*1024
- char buf[BUF_SIZE];
- struct aiocb aiocb;
- memset(buf, 0xAA, BUF_SIZE);
- memset(&aiocb, 0, sizeof(struct aiocb));
- aiocb.aio_fildes = fd;
- aiocb.aio_buf = buf;
- aiocb.aio_nbytes = BUF_SIZE;
- aio_write(&aiocb);
- while (aio_error (&aiocb) == EINPROGRESS);
- close(fd);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement