2 * mklost+found.c - Creates a directory lost+found on a mounted second
5 * Copyright (C) 1992, 1993 Remy Card <card@masi.ibp.fr>
7 * This file can be redistributed under the terms of the GNU General
21 #include <sys/param.h>
24 #include <linux/ext2_fs.h>
26 #include "../version.h"
28 #define LPF "lost+found"
30 int main (int argc, char ** argv)
32 char name [EXT2_NAME_LEN];
33 char path [sizeof (LPF) + 1 + 256];
38 fprintf (stderr, "mklost+found %s, %s for EXT2 FS %s, %s\n",
39 E2FSPROGS_VERSION, E2FSPROGS_DATE,
40 EXT2FS_VERSION, EXT2FS_DATE);
42 fprintf (stderr, "Usage: mklost+found\n");
45 if (mkdir (LPF, 0755) == -1) {
51 memset (name, 'x', 252);
53 sprintf (name + 252, "%02d", i);
57 if ((d = creat (path, 0644)) == -1) {
63 if (stat (LPF, &st) == -1) {
67 } while (st.st_size <= (EXT2_NDIR_BLOCKS - 1) * st.st_blksize);
68 for (j = 0; j < i; j++) {
69 sprintf (name + 252, "%02d", j);
73 if (unlink (path) == -1) {