1997-04-26 17:21:57 +04:00
|
|
|
/*
|
|
|
|
* mklost+found.c - Creates a directory lost+found on a mounted second
|
|
|
|
* extended file system
|
|
|
|
*
|
|
|
|
* Copyright (C) 1992, 1993 Remy Card <card@masi.ibp.fr>
|
|
|
|
*
|
|
|
|
* This file can be redistributed under the terms of the GNU General
|
|
|
|
* Public License
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* History:
|
|
|
|
* 93/04/22 - Creation
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <errno.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <unistd.h>
|
ChangeLog, e2image.c, mke2fs.c, mklost+found.c, tune2fs.c, util.c, uuidgen.c:
e2image.c, mke2fs.c, mklost+found.c, tune2fs.c, util.c, uuidgen.c: Fix
gcc -Wall complaints, including one bug in tune2fs caused by a block
automatic shadowing version of the variable we really wanted to use,
which broke the logic testing to see if the filesystem was mounted.
ChangeLog, MCONFIG.in:
(gcc-wall-new): Added new target which forgoes the make clean so we
only check the newly modified .c files.
2001-01-11 19:08:23 +03:00
|
|
|
#include <stdlib.h>
|
1997-04-26 17:21:57 +04:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
|
Many files:
badblocks.c, chattr.c, dumpe2fs.c, e2image.c, findsuper.c, lsattr.c,
mke2fs.c, mklost+found.c, tune2fs.c, util.c: Change location of
ext2_fs.h to be ext2fs/ext2_fs.h
ChangeLog, Makefile.in, resize2fs.h:
resize2fs.h: Change location of ext2_fs.h to be ext2fs/ext2_fs.h
ChangeLog, Makefile.in, debugfs.h:
debugfs.h: Change location of ext2_fs.h to be ext2fs/ext2_fs.h
ChangeLog, Makefile.in, e2fsck.h, scantest.c:
e2fsck.h, scantest.c: Change location of ext2_fs.h to be
ext2fs/ext2_fs.h
ChangeLog, Makefile.in, tst_uuid.c, uuid_time.c:
tst_uuid.c, uuid_time.c: Remove unneeded #include of ext2_fs.h
ChangeLog, Makefile.in, e2p.h:
e2p.h: Change location of ext2_fs.h to be ext2fs/ext2_fs.h
ChangeLog, Makefile.in, test_icount.c, test_rel.c:
test_icount.c, test_rel.c: Change location of ext2_fs.h to be
ext2fs/ext2_fs.h
2001-05-14 15:45:38 +04:00
|
|
|
#include "ext2fs/ext2_fs.h"
|
1997-04-26 17:21:57 +04:00
|
|
|
#include "../version.h"
|
Many files:
badblocks.c, chattr.c, dumpe2fs.c, e2label.c, findsuper.c, fsck.c,
get_device_by_label.c, lsattr.c, mke2fs.c, mklost+found.c,
nls-enable.h, partinfo.c, tune2fs.c, uuidgen.c: Add
Internationalization support as suggested by Marco d'Itri
<md@linux.it>.
2000-02-08 03:47:55 +03:00
|
|
|
#include "nls-enable.h"
|
1997-04-26 17:21:57 +04:00
|
|
|
|
|
|
|
#define LPF "lost+found"
|
|
|
|
|
1997-09-16 06:13:52 +04:00
|
|
|
int main (int argc, char ** argv)
|
1997-04-26 17:21:57 +04:00
|
|
|
{
|
|
|
|
char name [EXT2_NAME_LEN];
|
1997-04-26 18:00:26 +04:00
|
|
|
char path [sizeof (LPF) + 1 + 256];
|
1997-04-26 17:21:57 +04:00
|
|
|
struct stat st;
|
|
|
|
int i, j;
|
|
|
|
int d;
|
|
|
|
|
Many files:
badblocks.c, chattr.c, dumpe2fs.c, e2label.c, findsuper.c, fsck.c,
get_device_by_label.c, lsattr.c, mke2fs.c, mklost+found.c,
nls-enable.h, partinfo.c, tune2fs.c, uuidgen.c: Add
Internationalization support as suggested by Marco d'Itri
<md@linux.it>.
2000-02-08 03:47:55 +03:00
|
|
|
#ifdef ENABLE_NLS
|
|
|
|
setlocale(LC_MESSAGES, "");
|
2002-03-05 11:26:52 +03:00
|
|
|
setlocale(LC_CTYPE, "");
|
Many files:
badblocks.c, chattr.c, dumpe2fs.c, e2label.c, findsuper.c, fsck.c,
get_device_by_label.c, lsattr.c, mke2fs.c, mklost+found.c,
nls-enable.h, partinfo.c, tune2fs.c, uuidgen.c: Add
Internationalization support as suggested by Marco d'Itri
<md@linux.it>.
2000-02-08 03:47:55 +03:00
|
|
|
bindtextdomain(NLS_CAT_NAME, LOCALEDIR);
|
|
|
|
textdomain(NLS_CAT_NAME);
|
|
|
|
#endif
|
2001-08-27 20:44:23 +04:00
|
|
|
fprintf (stderr, "mklost+found %s (%s)\n", E2FSPROGS_VERSION,
|
|
|
|
E2FSPROGS_DATE);
|
1997-04-26 17:21:57 +04:00
|
|
|
if (argc != 1) {
|
2003-12-28 15:04:35 +03:00
|
|
|
(void)argv; /* avoid unused argument warning */
|
Many files:
badblocks.c, chattr.c, dumpe2fs.c, e2label.c, findsuper.c, fsck.c,
get_device_by_label.c, lsattr.c, mke2fs.c, mklost+found.c,
nls-enable.h, partinfo.c, tune2fs.c, uuidgen.c: Add
Internationalization support as suggested by Marco d'Itri
<md@linux.it>.
2000-02-08 03:47:55 +03:00
|
|
|
fprintf (stderr, _("Usage: mklost+found\n"));
|
1997-04-26 17:21:57 +04:00
|
|
|
exit(1);
|
|
|
|
}
|
2002-10-12 01:44:12 +04:00
|
|
|
if (mkdir (LPF, 0700) == -1) {
|
1997-04-26 17:21:57 +04:00
|
|
|
perror ("mkdir");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
i = 0;
|
2006-03-24 06:37:02 +03:00
|
|
|
memset (name, 'x', 246);
|
1997-04-26 17:21:57 +04:00
|
|
|
do {
|
2006-03-24 06:37:02 +03:00
|
|
|
sprintf (name + 246, "%08d", i);
|
1997-04-26 17:21:57 +04:00
|
|
|
strcpy (path, LPF);
|
|
|
|
strcat (path, "/");
|
|
|
|
strcat (path, name);
|
|
|
|
if ((d = creat (path, 0644)) == -1) {
|
|
|
|
perror ("creat");
|
|
|
|
exit (1);
|
|
|
|
}
|
|
|
|
i++;
|
|
|
|
close (d);
|
|
|
|
if (stat (LPF, &st) == -1) {
|
|
|
|
perror ("stat");
|
|
|
|
exit (1);
|
|
|
|
}
|
|
|
|
} while (st.st_size <= (EXT2_NDIR_BLOCKS - 1) * st.st_blksize);
|
|
|
|
for (j = 0; j < i; j++) {
|
2006-03-24 06:37:02 +03:00
|
|
|
sprintf (name + 246, "%08d", j);
|
1997-04-26 17:21:57 +04:00
|
|
|
strcpy (path, LPF);
|
|
|
|
strcat (path, "/");
|
|
|
|
strcat (path, name);
|
|
|
|
if (unlink (path) == -1) {
|
|
|
|
perror ("unlink");
|
|
|
|
exit (1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
exit (0);
|
|
|
|
}
|