forked from pcercuei/mininit
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathloop.c
More file actions
35 lines (23 loc) · 778 Bytes
/
loop.c
File metadata and controls
35 lines (23 loc) · 778 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
31
32
33
34
//===========================================================================
#include <sys/ioctl.h>
#include <string.h>
#include "loop_info.h"
#include "loop.h"
//===========================================================================
int losetup (
int loopfd,
int filefd,
const char *filename
) {
int r; struct loop_info64 lo;
r = ioctl(loopfd, LOOP_SET_FD, filefd);
if (r < 0) return r;
memset(&lo, 0, sizeof(lo));
strncpy((char *)lo.lo_file_name, filename, LO_NAME_SIZE - 1);
return ioctl(loopfd, LOOP_SET_STATUS64, &lo);
}
//===========================================================================
int lodelete (int loopfd) {
return ioctl(loopfd, LOOP_CLR_FD, 0);
}
//===========================================================================