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
22 #include <sys/param.h>
25 #include "ext2fs/ext2_fs.h"
26 #include "../version.h"
27 #include "nls-enable.h"
29 #define LPF "lost+found"
31 int main (int argc, char ** argv)
33 char name [EXT2_NAME_LEN];
34 char path [sizeof (LPF) + 1 + 256];
40 setlocale(LC_MESSAGES, "");
41 setlocale(LC_CTYPE, "");
42 bindtextdomain(NLS_CAT_NAME, LOCALEDIR);
43 textdomain(NLS_CAT_NAME);
45 fprintf (stderr, "mklost+found %s (%s)\n", E2FSPROGS_VERSION,
48 (void)argv; /* avoid unused argument warning */
49 fprintf (stderr, _("Usage: mklost+found\n"));
52 if (mkdir (LPF, 0700) == -1) {
58 memset (name, 'x', 252);
60 sprintf (name + 252, "%02d", i);
64 if ((d = creat (path, 0644)) == -1) {
70 if (stat (LPF, &st) == -1) {
74 } while (st.st_size <= (EXT2_NDIR_BLOCKS - 1) * st.st_blksize);
75 for (j = 0; j < i; j++) {
76 sprintf (name + 252, "%02d", j);
80 if (unlink (path) == -1) {