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 fprintf (stderr, _("Usage: mklost+found\n"));
51 if (mkdir (LPF, 0700) == -1) {
57 memset (name, 'x', 252);
59 sprintf (name + 252, "%02d", i);
63 if ((d = creat (path, 0644)) == -1) {
69 if (stat (LPF, &st) == -1) {
73 } while (st.st_size <= (EXT2_NDIR_BLOCKS - 1) * st.st_blksize);
74 for (j = 0; j < i; j++) {
75 sprintf (name + 252, "%02d", j);
79 if (unlink (path) == -1) {