Diferencia entre revisiones de «Ejemplo uso de llamadas al sistema para modificar el sistema de archivos»

De Wiki de Sistemas Operativos
Saltar a: navegación, buscar
(Página creada con «#include <stdio.h> #include <stdlib.h> #include <string.h> <syntax lang="c"> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> int main(void) { char buf[102...»)
 
Línea 1: Línea 1:
 +
<syntax lang="c">
 
#include <stdio.h>
 
#include <stdio.h>
 
#include <stdlib.h>
 
#include <stdlib.h>
 
#include <string.h>
 
#include <string.h>
<syntax lang="c">
 
 
#include <sys/types.h>
 
#include <sys/types.h>
 
#include <sys/stat.h>
 
#include <sys/stat.h>

Revisión del 16:07 11 oct 2019

<syntax lang="c">

  1. include <stdio.h>
  2. include <stdlib.h>
  3. include <string.h>
  4. include <sys/types.h>
  5. include <sys/stat.h>
  6. include <fcntl.h>

int main(void) { char buf[1024] = {}; int fd, numbytes;

fd = open("fichero.txt", O_RDONLY); if (fd < 0) { perror("open"); exit(EXIT_FAILURE); }

numbytes = read(fd, buf, sizeof(buf)); while (numbytes > 0) { write(1, buf, strlen(buf)); numbytes = read(fd, buf, sizeof(buf)); }

close(fd); mkdir("prueba", 0755);

exit(EXIT_SUCCESS); } </syntax>