diff options
author | Jim Kaye <jameskaye@google.com> | 2018-08-30 12:54:08 -0700 |
---|---|---|
committer | Dan Willemsen <dwillemsen@google.com> | 2019-05-10 18:40:26 -0700 |
commit | 1c4634f61047330bef41952e6f3908499b3f7cc1 (patch) | |
tree | 65972d0aa7c481c72fe1e03a07c14515d4353124 | |
parent | b2a144df273e417caaf3aff63254ca654a276a59 (diff) | |
download | sdk-1c4634f61047330bef41952e6f3908499b3f7cc1.tar.gz |
Remove mksdcard from the System source tree
The live version is in aosp/emu-master-dev under
sdk/emulator/
Bug: 113514423
Test: None
Change-Id: Ib6a6d3fe79d434d3c76a969049c7e212f309b29b
Merged-In: Ib6a6d3fe79d434d3c76a969049c7e212f309b29b
(cherry picked from commit 131905021f2df34096124c0f93eecc311a60f56d)
-rw-r--r-- | emulator/mksdcard/.gitignore | 3 | ||||
-rw-r--r-- | emulator/mksdcard/Android.mk | 11 | ||||
-rw-r--r-- | emulator/mksdcard/MODULE_LICENSE_BSD | 0 | ||||
-rw-r--r-- | emulator/mksdcard/NOTICE | 190 | ||||
-rw-r--r-- | emulator/mksdcard/build.gradle | 54 | ||||
-rw-r--r-- | emulator/mksdcard/src/source/mksdcard.c | 364 | ||||
-rw-r--r-- | emulator/mksdcard/vfat-empty-32MB.img.gz | bin | 32807 -> 0 bytes |
7 files changed, 0 insertions, 622 deletions
diff --git a/emulator/mksdcard/.gitignore b/emulator/mksdcard/.gitignore deleted file mode 100644 index 4a78fc83a..000000000 --- a/emulator/mksdcard/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -build -.gradle - diff --git a/emulator/mksdcard/Android.mk b/emulator/mksdcard/Android.mk deleted file mode 100644 index 0547f0073..000000000 --- a/emulator/mksdcard/Android.mk +++ /dev/null @@ -1,11 +0,0 @@ -# Copyright 2006 The Android Open Source Project - -LOCAL_PATH:= $(call my-dir) - -# host executable -# -include $(CLEAR_VARS) -LOCAL_SRC_FILES:= src/source/mksdcard.c -LOCAL_MODULE = mksdcard -include $(BUILD_HOST_EXECUTABLE) - diff --git a/emulator/mksdcard/MODULE_LICENSE_BSD b/emulator/mksdcard/MODULE_LICENSE_BSD deleted file mode 100644 index e69de29bb..000000000 --- a/emulator/mksdcard/MODULE_LICENSE_BSD +++ /dev/null diff --git a/emulator/mksdcard/NOTICE b/emulator/mksdcard/NOTICE deleted file mode 100644 index 06a9081ca..000000000 --- a/emulator/mksdcard/NOTICE +++ /dev/null @@ -1,190 +0,0 @@ - - Copyright (c) 2005-2014, The Android Open Source Project - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - diff --git a/emulator/mksdcard/build.gradle b/emulator/mksdcard/build.gradle deleted file mode 100644 index f2bbe733c..000000000 --- a/emulator/mksdcard/build.gradle +++ /dev/null @@ -1,54 +0,0 @@ -apply plugin: 'c' -apply plugin: 'sdk-files' -apply plugin: 'native-setup' - -executables { - mksdcard {} -} - -sources { - mksdcard { - c { - source { - srcDir "src/source" - include "**/*.c" - } - } - } -} - -binaries.all { - cCompiler.args "-D_FILE_OFFSET_BITS=64" - if (Os.isFamily(Os.FAMILY_WINDOWS)) { - linker.args "-static-libgcc" - } -} - -sdk { - mac { - item( { getExeName("darwin") } ) { - executable true - builtBy 'darwinMksdcardExecutable' - } - } - linux { - item( { getExeName("linux") } ) { - executable true - builtBy 'linuxMksdcardExecutable' - } - } - windows { - item( { getExeName("windows32") } ) { - name 'mksdcard.exe' - builtBy 'windows32MksdcardExecutable' - } - } -} - -def getExeName(String platform) { - // binaries will return a set of binaries - def binaries = executables.mksdcard.binaries.matching { it.name == "${platform}MksdcardExecutable" } - // calling .exeFile on the set returns an array with the result from each item in the set... - return binaries.executableFile.get(0) -} - diff --git a/emulator/mksdcard/src/source/mksdcard.c b/emulator/mksdcard/src/source/mksdcard.c deleted file mode 100644 index ca23e6375..000000000 --- a/emulator/mksdcard/src/source/mksdcard.c +++ /dev/null @@ -1,364 +0,0 @@ -/* mksdcard.c -** -** Copyright 2007, The Android Open Source Project -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** * Neither the name of Google Inc. nor the names of its contributors may -** be used to endorse or promote products derived from this software -** without specific prior written permission. -** -** THIS SOFTWARE IS PROVIDED BY Google Inc. ``AS IS'' AND ANY EXPRESS OR -** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO -** EVENT SHALL Google Inc. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -** PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; -** OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR -** OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF -** ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/* a simple and portable program used to generate a blank FAT32 image file - * - * usage: mksdcard [-l label] <size> <filename> - */ - -#include <time.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <errno.h> -#include <unistd.h> - -/* believe me, you *don't* want to change these constants !! */ -#define BYTES_PER_SECTOR 512 -#define RESERVED_SECTORS 32 -#define BACKUP_BOOT_SECTOR 6 -#define NUM_FATS 2 - -/* sectors_per_disk is encoded as a signed int */ -#define MAX_SECTORS_PER_DISK 0x7FFFFFFF -#define MAX_DISK_SIZE ((Wide)MAX_SECTORS_PER_DISK * BYTES_PER_SECTOR) - -typedef long long Wide; /* might be something else if you don't use GCC */ -typedef unsigned char Byte; -typedef Byte* Bytes; - -#define BYTE_(p,i) (((Bytes)(p))[(i)]) - -#define POKEB(p,v) BYTE_(p,0) = (Byte)(v) -#define POKES(p,v) ( BYTE_(p,0) = (Byte)(v), BYTE_(p,1) = (Byte)((v) >> 8) ) -#define POKEW(p,v) ( BYTE_(p,0) = (Byte)(v), BYTE_(p,1) = (Byte)((v) >> 8), BYTE_(p,2) = (Byte)((v) >> 16), BYTE_(p,3) = (Byte)((v) >> 24) ) - -static Byte s_boot_sector [ BYTES_PER_SECTOR ]; /* boot sector */ -static Byte s_fsinfo_sector [ BYTES_PER_SECTOR ]; /* FS Info sector */ -static Byte s_fat_head [ BYTES_PER_SECTOR ]; /* first FAT sector */ -// static Byte s_zero_sector [ BYTES_PER_SECTOR ]; /* empty sector */ - -// For handling Unicode paths -#ifdef _WIN32 - #define WIDE_CHAR wchar_t - #define ARGC wargc - #define ARGV wargv - #define STRINGPRINT "%S" -#else - #define WIDE_CHAR char - #define ARGC argc - #define ARGV argv - #define STRINGPRINT "%s" -#endif - -/* this is the date and time when creating the disk */ -static int -get_serial_id( void ) -{ - unsigned short lo, hi; - time_t now = time(NULL); - struct tm tm = gmtime( &now )[0]; - - lo = (unsigned short)(tm.tm_mday + ((tm.tm_mon+1) << 8) + (tm.tm_sec << 8)); - hi = (unsigned short)(tm.tm_min + (tm.tm_hour << 8) + (tm.tm_year + 1900)); - - return lo + (hi << 16); -} - -static int -get_sectors_per_cluster( Wide disk_size ) -{ - Wide disk_MB = disk_size/(1024*1024); - - if (disk_MB < 260) - return 1; - - if (disk_MB < 8192) - return 4; - - if (disk_MB < 16384) - return 8; - - if (disk_MB < 32768) - return 16; - - return 32; -} - -static int -get_sectors_per_fat( Wide disk_size, int sectors_per_cluster ) -{ - Wide divider; - - /* weird computation from MS - see fatgen103.doc for details */ - disk_size -= RESERVED_SECTORS * BYTES_PER_SECTOR; /* don't count 32 reserved sectors */ - disk_size /= BYTES_PER_SECTOR; /* disk size in sectors */ - divider = ((256 * sectors_per_cluster) + NUM_FATS) / 2; - - return (int)( (disk_size + (divider-1)) / divider ); -} - -static void -boot_sector_init( Bytes boot, Bytes info, Wide disk_size, const char* label ) -{ - int sectors_per_cluster = get_sectors_per_cluster(disk_size); - int sectors_per_fat = get_sectors_per_fat(disk_size, sectors_per_cluster); - int sectors_per_disk = (int)(disk_size / BYTES_PER_SECTOR); - int serial_id = get_serial_id(); - int free_count; - - if (label == NULL) - label = "SDCARD"; - - POKEB(boot, 0xeb); - POKEB(boot+1, 0x5a); - POKEB(boot+2, 0x90); - strcpy( (char*)boot + 3, "MSWIN4.1" ); - POKES( boot + 0x0b, BYTES_PER_SECTOR ); /* sector size */ - POKEB( boot + 0xd, sectors_per_cluster ); /* sectors per cluster */ - POKES( boot + 0xe, RESERVED_SECTORS ); /* reserved sectors before first FAT */ - POKEB( boot + 0x10, NUM_FATS ); /* number of FATs */ - POKES( boot + 0x11, 0 ); /* max root directory entries for FAT12/FAT16, 0 for FAT32 */ - POKES( boot + 0x13, 0 ); /* total sectors, 0 to use 32-bit value at offset 0x20 */ - POKEB( boot + 0x15, 0xF8 ); /* media descriptor, 0xF8 == hard disk */ - POKES( boot + 0x16, 0 ); /* Sectors per FAT for FAT12/16, 0 for FAT32 */ - POKES( boot + 0x18, 9 ); /* Sectors per track (whatever) */ - POKES( boot + 0x1a, 2 ); /* Number of heads (whatever) */ - POKEW( boot + 0x1c, 0 ); /* Hidden sectors */ - POKEW( boot + 0x20, sectors_per_disk ); /* Total sectors */ - - /* extension */ - POKEW( boot + 0x24, sectors_per_fat ); /* Sectors per FAT */ - POKES( boot + 0x28, 0 ); /* FAT flags */ - POKES( boot + 0x2a, 0 ); /* version */ - POKEW( boot + 0x2c, 2 ); /* cluster number of root directory start */ - POKES( boot + 0x30, 1 ); /* sector number of FS information sector */ - POKES( boot + 0x32, BACKUP_BOOT_SECTOR ); /* sector number of a copy of this boot sector */ - POKEB( boot + 0x40, 0x80 ); /* physical drive number */ - POKEB( boot + 0x42, 0x29 ); /* extended boot signature ?? */ - POKEW( boot + 0x43, serial_id ); /* serial ID */ - strncpy( (char*)boot + 0x47, label, 11 ); /* Volume Label */ - memcpy( boot + 0x52, "FAT32 ", 8 ); /* FAT system type, padded with 0x20 */ - - POKEB( boot + BYTES_PER_SECTOR-2, 0x55 ); /* boot sector signature */ - POKEB( boot + BYTES_PER_SECTOR-1, 0xAA ); - - /* FSInfo sector */ - free_count = sectors_per_disk - 32 - 2*sectors_per_fat; - - POKEW( info + 0, 0x41615252 ); - POKEW( info + 484, 0x61417272 ); - POKEW( info + 488, free_count ); /* number of free clusters */ - POKEW( info + 492, 3 ); /* next free clusters, 0-1 reserved, 2 is used for the root dir */ - POKEW( info + 508, 0xAA550000 ); -} - -static void -fat_init( Bytes fat ) -{ - POKEW( fat, 0x0ffffff8 ); /* reserve cluster 1, media id in low byte */ - POKEW( fat + 4, 0x0fffffff ); /* reserve cluster 2 */ - POKEW( fat + 8, 0x0fffffff ); /* end of clust chain for root dir */ -} - - -static int -write_sector( FILE* file, Bytes sector ) -{ - int result = fwrite( sector, 1, BYTES_PER_SECTOR, file ) != BYTES_PER_SECTOR; - if (result) { - fprintf(stderr, "Failed to write sector of %d bytes: %s\n", BYTES_PER_SECTOR, strerror(errno)); - } - return result; -} - -static int -write_empty( FILE* file, Wide count ) -{ - static Byte empty[256*1024]; - memset(empty, 0, sizeof(empty)); - - count *= BYTES_PER_SECTOR; - while (count > 0) { - int len = sizeof(empty); - if (len > count) - len = count; - if ( fwrite( empty, 1, len, file ) != (size_t)len ) { - fprintf(stderr, "Failed to write %d bytes: %s\n", len, strerror(errno)); - return 1; - } - - count -= len; - } - return 0; -} - -static void usage (void) -{ - fprintf(stderr, "mksdcard: create a blank FAT32 image to be used with the Android emulator\n" ); - fprintf(stderr, "usage: mksdcard [-l label] <size> <file>\n\n"); - fprintf(stderr, " if <size> is a simple integer, it specifies a size in bytes\n" ); - fprintf(stderr, " if <size> is an integer followed by 'K', it specifies a size in KiB\n" ); - fprintf(stderr, " if <size> is an integer followed by 'M', it specifies a size in MiB\n" ); - fprintf(stderr, " if <size> is an integer followed by 'G', it specifies a size in GiB\n" ); - fprintf(stderr, "\nMinimum size is 9M. The Android emulator cannot use smaller images.\n" ); - fprintf(stderr, "Maximum size is %lld bytes, %lldK, %lldM or %lldG\n", - MAX_DISK_SIZE, MAX_DISK_SIZE >> 10, MAX_DISK_SIZE >> 20, MAX_DISK_SIZE >> 30); - exit(1); -} - -int main( int argc, char** argv ) -{ - Wide disk_size; - int sectors_per_fat; - int sectors_per_disk; - WIDE_CHAR* end; - const WIDE_CHAR* label = NULL; - FILE* f = NULL; - -#ifdef _WIN32 - int wargc; - WIDE_CHAR** wargv; - WIDE_CHAR** unused_environment; - WIDE_CHAR** unused_startupinfo; - - __wgetmainargs(&wargc, &wargv, &unused_environment, 0, &unused_startupinfo); -#endif - - for ( ; ARGC > 1 && ARGV[1][0] == '-'; ARGC--, ARGV++ ) - { - WIDE_CHAR* arg = ARGV[1] + 1; - switch (arg[0]) { - case 'l': - if (arg[1] != 0) - arg += 2; - else { - ARGC--; - ARGV++; - if (ARGC <= 1) - usage(); - arg = ARGV[1]; - } - label = arg; - break; - - default: - usage(); - } - } - - if (ARGC != 3) - usage(); - -#ifdef _WIN32 - disk_size = wcstoll( ARGV[1], &end, 10 ); -#else - disk_size = strtoll( ARGV[1], &end, 10 ); -#endif - - if (disk_size <= 0 || errno == EINVAL || errno == ERANGE) { - fprintf(stderr, "Invalid argument size '" STRINGPRINT "'\n\n", ARGV[1]); - usage(); - } - - if (*end == 'K') - disk_size *= 1024; - else if (*end == 'M') - disk_size *= 1024*1024; - else if (*end == 'G') - disk_size *= 1024*1024*1024; - - if (disk_size < 9*1024*1024) { - fprintf(stderr, "Invalid argument: size '" STRINGPRINT "' is too small.\n\n", ARGV[1]); - usage(); - } else if (disk_size > MAX_DISK_SIZE) { - fprintf(stderr, "Invalid argument: size '" STRINGPRINT "' is too large.\n\n", ARGV[1]); - usage(); - } - - sectors_per_disk = disk_size / BYTES_PER_SECTOR; - sectors_per_fat = get_sectors_per_fat( disk_size, get_sectors_per_cluster( disk_size ) ); - - boot_sector_init( s_boot_sector, s_fsinfo_sector, disk_size, NULL ); - fat_init( s_fat_head ); - -#ifdef _WIN32 - f = _wfopen( ARGV[2], L"wb" ); -#else - f = fopen( ARGV[2], "wb" ); -#endif - if ( !f ) { - fprintf(stderr, "Could not create file '" STRINGPRINT "': %s\n", ARGV[2], strerror(errno)); - goto FailWrite; - } - - /* here's the layout: - * - * boot_sector - * fsinfo_sector - * empty - * backup boot sector - * backup fsinfo sector - * RESERVED_SECTORS - 4 empty sectors (if backup sectors), or RESERVED_SECTORS - 2 (if no backup) - * first fat - * second fat - * zero sectors - */ - - if ( write_sector( f, s_boot_sector ) ) goto FailWrite; - if ( write_sector( f, s_fsinfo_sector ) ) goto FailWrite; - if ( BACKUP_BOOT_SECTOR > 0 ) { - if ( write_empty( f, BACKUP_BOOT_SECTOR - 2 ) ) goto FailWrite; - if ( write_sector( f, s_boot_sector ) ) goto FailWrite; - if ( write_sector( f, s_fsinfo_sector ) ) goto FailWrite; - if ( write_empty( f, RESERVED_SECTORS - 2 - BACKUP_BOOT_SECTOR ) ) goto FailWrite; - } - else if ( write_empty( f, RESERVED_SECTORS - 2 ) ) goto FailWrite; - - if ( write_sector( f, s_fat_head ) ) goto FailWrite; - if ( write_empty( f, sectors_per_fat-1 ) ) goto FailWrite; - - if ( write_sector( f, s_fat_head ) ) goto FailWrite; - if ( write_empty( f, sectors_per_fat-1 ) ) goto FailWrite; - - if ( write_empty( f, sectors_per_disk - RESERVED_SECTORS - 2*sectors_per_fat ) ) goto FailWrite; - - fclose(f); - return 0; - -FailWrite: - if (f != NULL) { - fclose(f); -#ifdef _WIN32 - _wunlink( ARGV[2] ); -#else - unlink( ARGV[2] ); -#endif - fprintf(stderr, "File '" STRINGPRINT "' was not created.\n", ARGV[2]); - } - return 1; -} diff --git a/emulator/mksdcard/vfat-empty-32MB.img.gz b/emulator/mksdcard/vfat-empty-32MB.img.gz Binary files differdeleted file mode 100644 index b205da34d..000000000 --- a/emulator/mksdcard/vfat-empty-32MB.img.gz +++ /dev/null |