-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathio.c
More file actions
31 lines (27 loc) · 650 Bytes
/
io.c
File metadata and controls
31 lines (27 loc) · 650 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>
#include "superblock.h"
#include "dir.h"
static int fd;
void init_disk()
{
// fd = open("/dev/sdb", O_RDONLY);
fd = open("/home/doremi/img/sdcard.img", O_RDONLY);
// fd = open("fat32.img", O_RDONLY);
// fd = open("sd4g.img", O_RDONLY);
if (fd == -1) {
perror("open");
exit(1);
}
}
void read8blocks(void *buf, unsigned int start_block)
{
if (lseek(fd, start_block * 512, SEEK_SET) == -1)
perror("lseek");
if (read(fd, buf, cluster_size) == -1)
perror("read");
}