Advertisement
Guest User

Untitled

a guest
Oct 28th, 2018
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.74 KB | None | 0 0
  1. unsigned int GET_DEVICES(){
  2.     FILE *devices;
  3.     int size_files, i;
  4.     char *buffer = (char*)malloc(1), charac;
  5.     printf(".-----------------------------------------------------------------.\n"); //remove this
  6.     printf("!  Devices  ! Partition Table !  Size  ! Sector(Physical/Logical) !\n"); //remove this
  7.     printf("!-----------------------------------------------------------------!\n"); //remove this
  8.     devices = fopen("/proc/partitions", "r");
  9.     fseek(devices, 0L, SEEK_END);
  10.     buffer = (char*)realloc(buffer, ftell(devices)+1);
  11.     fseek(devices, 0L, SEEK_SET);
  12.     charac = fgetc(devices);
  13.     for(i=0;charac!=EOF;i++){
  14.         buffer[i] = charac;
  15.         charac = fgetc(devices);
  16.     }
  17.     buffer[i-1] = '\0';
  18.     fclose(devices);
  19.     printf("%s\n", buffer);
  20.     return 0;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement