Código
#include <fcntl.h> #include <stdio.h> #include <unistd.h> #include <string.h> int main(){ char name[100]; int i = 0; int file = -1; do{ if(file != -1) close(file); sprintf(name,"file%d",i); }while((file = open(name,O_RDONLY)) != -1 && ++i); file = open(name,O_WRONLY | O_CREAT); char text[1024]; for(int j = 0;j<i+1;j++){ sprintf(text,"Hola %d veces\n",j); while(write(file,text,strlen(text)) != strlen(text)); } close(file); return 0; }
luego use un bucle
Código
while true; do ./a.out;done
En el escritorio me aparecieron mucho archivos con sus permisos aleatorios y raros.
Ejemplo:
Código
----r-Sr-t 1 root root 14155 jun 21 23:57 file950 --wS---r-x 1 root root 14170 jun 21 23:57 file951 ---Sr-Sr-x 1 root root 14185 jun 21 23:57 file952 ------Sr-x 1 root root 14200 jun 21 23:57 file953 --ws---r-t 1 root root 14215 jun 21 23:57 file954 -rwxr-Sr-x 1 root root 14230 jun 21 23:57 file955 -r----Sr-x 1 root root 14245 jun 21 23:57 file956 -r-xr--r-t 1 root root 14260 jun 21 23:57 file957 -r-sr--r-t 1 root root 14275 jun 21 23:57 file958 -r-Sr-Sr-t 1 root root 14290 jun 21 23:57 file959 -r-Sr--r-T 1 root root 1348 jun 21 23:57 file96 --wSr--r-x 1 root root 14305 jun 21 23:57 file960 ---xr--r-x 1 root root 14320 jun 21 23:57 file961 -rwSr-Sr-t 1 root root 14335 jun 21 23:57 file962 --wxr-Sr-x 1 root root 14350 jun 21 23:57 file963 -r-sr--r-t 1 root root 14365 jun 21 23:57 file964 ---xr--r-t 1 root root 14380 jun 21 23:57 file965 -rw-r--r-x 1 root root 14395 jun 21 23:57 file966 -rw-r--r-t 1 root root 14410 jun 21 23:57 file967 -rwx--Sr-x 1 root root 14425 jun 21 23:57 file968 ---xr--r-x 1 root root 14440 jun 21 23:57 file969 -r--r-Sr-T 1 root root 1362 jun 21 23:57 file97 -r--r--r-x 1 root root 14455 jun 21 23:57 file970 --w----r-t 1 root root 14470 jun 21 23:57 file971 -r----Sr-t 1 root root 14485 jun 21 23:57 file972 -rw---Sr-x 1 root root 14500 jun 21 23:57 file973 ------Sr-x 1 root root 14515 jun 21 23:57 file974 --w-r-Sr-t 1 root root 14530 jun 21 23:57 file975 -rw---Sr-t 1 root root 14545 jun 21 23:57 file976 -rwx--Sr-t 1 root root 14560 jun 21 23:57 file977 ---x--Sr-t 1 root root 14575 jun 21 23:57 file978 -------r-t 1 root root 14590 jun 21 23:57 file979 ----r-Sr-T 1 root root 1376 jun 21 23:57 file98 -r-sr--r-t 1 root root 14605 jun 21 23:57 file980 -rwxr--r-t 1 root root 14620 jun 21 23:57 file981 --wxr-Sr-t 1 root root 14635 jun 21 23:57 file982 --ws---r-t 1 root root 14650 jun 21 23:57 file983 ---Sr--r-x 1 root root 14665 jun 21 23:57 file984 -rw-r--r-x 1 root root 14680 jun 21 23:57 file985 -rw-r-Sr-t 1 root root 14695 jun 21 23:57 file986 --wxr-Sr-t 1 root root 14710 jun 21 23:57 file987 -r-S--Sr-t 1 root root 14725 jun 21 23:58 file988 --wsr--r-x 1 root root 14740 jun 21 23:58 file989 --ws---r-T 1 root root 1390 jun 21 23:57 file99 --wS---r-t 1 root root 14755 jun 21 23:58 file990 -r-xr--r-x 1 root root 14770 jun 21 23:58 file991 -rwS--Sr-x 1 root root 14785 jun 21 23:58 file992
Porque??
Saludos