Changes by: antona
Update of /cvsroot/linux-ntfs/linux-ntfs/ntfstools
In directory usw-pr-cvs1:/tmp/cvs-serv6047/ntfstools
Added Files:
mkntfs.c
Log Message:
Added begin of mkntfs utility. (Doesn't do anything, including doesn't compile at the moment.)
--- NEW FILE ---
const char *EXEC_NAME = "mkntfs";
const char *EXEC_VERSION = "0.0.1";
/*
* mkntfs - Part of the Linux-NTFS project.
*
* Copyright (c) 2000,2001 Anton Altaparmakov.
*
* This utility will create an NTFS volume on a user specified block device.
*
* Anton Altaparmakov <ai...@ca...>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program (in the main directory of the Linux-NTFS source
* in the file COPYING); if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*
* WARNING: This program might not work on architectures which do not allow
* unaligned access. For those, the program would need to start using
* get/put_unaligned macros (#include <asm/unaligned.h>), but not doing it yet,
* since NTFS really mostly applies to ia32 only, which does allow unaligned
* accesses. We might not actually have a problem though, since the structs are
* defined as being packed so that might be enough for gcc to insert the
* correct code.
*
* If anyone using a non-little endian and/or an aligned access only CPU tries
* this program please let me know whether it works or not!
*
* Anton Altaparmakov <ai...@ca...>
*/
//#include <unistd.h>
//#include <stdlib.h>
//#include <stdio.h>
//#include <linux/types.h>
//#include <fcntl.h>
//#include <errno.h>
//#include <string.h>
//#include "attrib.h"
//#include "endians.h"
//#include "mft.h"
//#include "disk_io.h"
//#include "volume.h"
//#include "logfile.h"
struct {
int cluster_size; /* -b, in bytes, 512*1024 max,
power of 2, if not specified
determined by file system size. */
char check_bad_blocks = 0; /* -c, read-only test for bad
clusters. */
char no_action = 0; /* -n, do not write to device, only
display what would be done. */
char *bad_blocks_filename = NULL; /* -l filename, file to read list of
bad clusters from. */
char quiet = 0; /* -q, quiet execution. */
char verbose = 0; /* -v, verbose execution. */
char force = 0; /* -F, force fs creation. */
char *volume_label = NULL; /* -L, set the volume label. */
union { /* -r, revision of ntfs, 1.2 or 3.0 */
__u16 ntfs_version;
struct {
__u8 ntfs_major_ver;
__u8 ntfs_minor_ver;
}
}
char version_only; /* -V, print the version number and
exit */
char quick_format = 0; /* Don't zero the volume. */
__u64 number_of_clusters;
__u64 mft_record_size = 1024;
__u64 index_record_size = 4096;
__u64 mft_size;
__u64 logfile_size;
} opt;
int main(int argc, char **argv)
{
RESTART_PAGE_HEADER *rph;
RESTART_AREA *rr;
RESTART_CLIENT *cr;
int pass = 1;
int i, lps;
options opt;
printf("\n");
if (argc < 2) {
printf("%s v%s - Create an NTFS volume on a user specified "
"block device.\n\n"
/* Generic copyright / disclaimer. */
"Copyright (c) 2000, 2001 Anton Altaparmakov.\n\n"
"%s is free software, released under the GNU "
"General Public License\nand you are welcome to "
"redistribute it under certain conditions.\n"
"%s comes with ABSOLUTELY NO WARRANTY; for details "
"read the GNU\nGeneral Public License to be found "
"in the file COPYING in the main Linux-NTFS\n"
"distribution directory.\n\n"
/* Generic part ends here. */
"Syntax: mkntfs block_device\n"
" e.g. mkntfs /dev/hda6\n\n",
EXEC_NAME, EXEC_VERSION, EXEC_NAME, EXEC_NAME);
fprintf(stderr, "Error: incorrect syntax\n");
exit(1);
}
// Parse command line options!!!
// Need to have: block size, device size / number of blocks to use, cluster
// size, mft record size, index record size, ntfs version, mft
// size, logfile size, volume label, list of bad blocks, quick-
// format, verbose, check for bad blocks, ...
if (stat(name, &sbuf)) {
fprintf(stderr, "Error getting information about %s: %s\n",
name, sterror(errno));
exit(1);
}
if (!S_ISBLK(sbuf.st_mode)) {
fprintf(stderr, "Error: %s is not a block devicer.\n", name);
exit(1);
}
// - Determine real size of device.
// - Open device.
// - If not quickformat then overwrite the device with 0s (except bad blocks!).
// - Create & write (C&w) empty $Mft & $MftMirr ($MftMirr in the middle of the
// partition (not on bad blocks!).
// - C&w $BitMap (not on bad blocks!).
// - C&w empty $BadClus (or if bad blocks are specified fill with these)
// (allocating the bad clusters if present in the $BitMap).
// - C&w bootsector ($Boot) & backup bootsector (backup in last sector of the
// partition).
// - C&w $Volume.
// - C&w empty $LogFile (fill with -1).
// - C&w $AttrDef according to ntfs version.
// - C&w $UpCase (need this to be from a static copyr; don't know a way to
// generate it).
// - Depending on the ntfs version, c&w $Secure file and $Extend directory with
// the corresponding special files in it (i.e. $ObjId, $Quota, $Reparse and
// $UsnJrnl and others?).
// - C&w $root and fill with the system files (and $Extend directory if
// applicable). Possibly should move this as far to the top as possible and
// update during each subsequent c&w.
// - Close device.
return 0;
}
|