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
23 #include <sys/param.h>
26 #include "ext2fs/ext2_fs.h"
27 #include "../version.h"
28 #include "nls-enable.h"
30 #define LPF "lost+found"
32 int main (int argc, char ** argv)
34 char name [EXT2_NAME_LEN];
35 char path [sizeof (LPF) + 1 + 256];
41 setlocale(LC_MESSAGES, "");
42 setlocale(LC_CTYPE, "");
43 bindtextdomain(NLS_CAT_NAME, LOCALEDIR);
44 textdomain(NLS_CAT_NAME);
46 fprintf (stderr, "mklost+found %s (%s)\n", E2FSPROGS_VERSION,
49 (void)argv; /* avoid unused argument warning */
50 fprintf (stderr, _("Usage: mklost+found\n"));
53 if (mkdir (LPF, 0700) == -1) {
59 memset (name, 'x', 246);
61 sprintf (name + 246, "%08d", i);
65 if ((d = creat (path, 0644)) == -1) {
71 if (stat (LPF, &st) == -1) {
75 } while (st.st_size <= (EXT2_NDIR_BLOCKS - 1) * st.st_blksize);
76 for (j = 0; j < i; j++) {
77 sprintf (name + 246, "%08d", j);
81 if (unlink (path) == -1) {