annotate toys/other/fsfreeze.c @ 1322:b91284c2e569 draft

Make "losetup /dev/loop0 filename" work. Sigh. Implement the complex cases and you screw up the simple cases you already tested...
author Rob Landley <rob@landley.net>
date Thu, 29 May 2014 06:29:12 -0500
parents 0ce03bb85ebd
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1237
867f9c964f3e New toy fsfreeze, from Isaac Dunham, plus minor cleanups.
Rob Landley <rob@landley.net>
parents:
diff changeset
1 /* fsfreeze.c - freeze or thaw filesystem
867f9c964f3e New toy fsfreeze, from Isaac Dunham, plus minor cleanups.
Rob Landley <rob@landley.net>
parents:
diff changeset
2 *
867f9c964f3e New toy fsfreeze, from Isaac Dunham, plus minor cleanups.
Rob Landley <rob@landley.net>
parents:
diff changeset
3 * No standard.
867f9c964f3e New toy fsfreeze, from Isaac Dunham, plus minor cleanups.
Rob Landley <rob@landley.net>
parents:
diff changeset
4
867f9c964f3e New toy fsfreeze, from Isaac Dunham, plus minor cleanups.
Rob Landley <rob@landley.net>
parents:
diff changeset
5 USE_FSFREEZE(NEWTOY(fsfreeze, "<1>1f|u|[!fu]", TOYFLAG_USR|TOYFLAG_SBIN))
867f9c964f3e New toy fsfreeze, from Isaac Dunham, plus minor cleanups.
Rob Landley <rob@landley.net>
parents:
diff changeset
6
867f9c964f3e New toy fsfreeze, from Isaac Dunham, plus minor cleanups.
Rob Landley <rob@landley.net>
parents:
diff changeset
7 config FSFREEZE
867f9c964f3e New toy fsfreeze, from Isaac Dunham, plus minor cleanups.
Rob Landley <rob@landley.net>
parents:
diff changeset
8 bool "fsfreeze"
867f9c964f3e New toy fsfreeze, from Isaac Dunham, plus minor cleanups.
Rob Landley <rob@landley.net>
parents:
diff changeset
9 default y
1260
0ce03bb85ebd Probe for the existence of FIFREEZE and make fsfreeze depend on it.
Rob Landley <rob@landley.net>
parents: 1237
diff changeset
10 depends on TOYBOX_FIFREEZE
1237
867f9c964f3e New toy fsfreeze, from Isaac Dunham, plus minor cleanups.
Rob Landley <rob@landley.net>
parents:
diff changeset
11 help
867f9c964f3e New toy fsfreeze, from Isaac Dunham, plus minor cleanups.
Rob Landley <rob@landley.net>
parents:
diff changeset
12 usage: fsfreeze {-f | -u} MOUNTPOINT
867f9c964f3e New toy fsfreeze, from Isaac Dunham, plus minor cleanups.
Rob Landley <rob@landley.net>
parents:
diff changeset
13
867f9c964f3e New toy fsfreeze, from Isaac Dunham, plus minor cleanups.
Rob Landley <rob@landley.net>
parents:
diff changeset
14 Freeze or unfreeze a filesystem.
867f9c964f3e New toy fsfreeze, from Isaac Dunham, plus minor cleanups.
Rob Landley <rob@landley.net>
parents:
diff changeset
15
867f9c964f3e New toy fsfreeze, from Isaac Dunham, plus minor cleanups.
Rob Landley <rob@landley.net>
parents:
diff changeset
16 -f freeze
867f9c964f3e New toy fsfreeze, from Isaac Dunham, plus minor cleanups.
Rob Landley <rob@landley.net>
parents:
diff changeset
17 -u unfreeze
867f9c964f3e New toy fsfreeze, from Isaac Dunham, plus minor cleanups.
Rob Landley <rob@landley.net>
parents:
diff changeset
18 */
867f9c964f3e New toy fsfreeze, from Isaac Dunham, plus minor cleanups.
Rob Landley <rob@landley.net>
parents:
diff changeset
19
867f9c964f3e New toy fsfreeze, from Isaac Dunham, plus minor cleanups.
Rob Landley <rob@landley.net>
parents:
diff changeset
20 #define FOR_fsfreeze
867f9c964f3e New toy fsfreeze, from Isaac Dunham, plus minor cleanups.
Rob Landley <rob@landley.net>
parents:
diff changeset
21 #include "toys.h"
867f9c964f3e New toy fsfreeze, from Isaac Dunham, plus minor cleanups.
Rob Landley <rob@landley.net>
parents:
diff changeset
22 #include <linux/fs.h>
867f9c964f3e New toy fsfreeze, from Isaac Dunham, plus minor cleanups.
Rob Landley <rob@landley.net>
parents:
diff changeset
23
867f9c964f3e New toy fsfreeze, from Isaac Dunham, plus minor cleanups.
Rob Landley <rob@landley.net>
parents:
diff changeset
24 void fsfreeze_main(void)
867f9c964f3e New toy fsfreeze, from Isaac Dunham, plus minor cleanups.
Rob Landley <rob@landley.net>
parents:
diff changeset
25 {
867f9c964f3e New toy fsfreeze, from Isaac Dunham, plus minor cleanups.
Rob Landley <rob@landley.net>
parents:
diff changeset
26 int fd = xopen(*toys.optargs, O_RDONLY);
867f9c964f3e New toy fsfreeze, from Isaac Dunham, plus minor cleanups.
Rob Landley <rob@landley.net>
parents:
diff changeset
27 long p = 1;
867f9c964f3e New toy fsfreeze, from Isaac Dunham, plus minor cleanups.
Rob Landley <rob@landley.net>
parents:
diff changeset
28
867f9c964f3e New toy fsfreeze, from Isaac Dunham, plus minor cleanups.
Rob Landley <rob@landley.net>
parents:
diff changeset
29 xioctl(fd, (toys.optflags & FLAG_f) ? FIFREEZE : FITHAW, &p);
867f9c964f3e New toy fsfreeze, from Isaac Dunham, plus minor cleanups.
Rob Landley <rob@landley.net>
parents:
diff changeset
30 xclose(fd);
867f9c964f3e New toy fsfreeze, from Isaac Dunham, plus minor cleanups.
Rob Landley <rob@landley.net>
parents:
diff changeset
31 }