summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CleanSpec.mk49
-rw-r--r--yaffs2/utils/mkyaffs2image.c99
2 files changed, 113 insertions, 35 deletions
diff --git a/CleanSpec.mk b/CleanSpec.mk
new file mode 100644
index 0000000..b84e1b6
--- /dev/null
+++ b/CleanSpec.mk
@@ -0,0 +1,49 @@
+# Copyright (C) 2007 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.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# 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.
+#
+
+# If you don't need to do a full clean build but would like to touch
+# a file or delete some intermediate files, add a clean step to the end
+# of the list. These steps will only be run once, if they haven't been
+# run before.
+#
+# E.g.:
+# $(call add-clean-step, touch -c external/sqlite/sqlite3.h)
+# $(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/STATIC_LIBRARIES/libz_intermediates)
+#
+# Always use "touch -c" and "rm -f" or "rm -rf" to gracefully deal with
+# files that are missing or have been moved.
+#
+# Use $(PRODUCT_OUT) to get to the "out/target/product/blah/" directory.
+# Use $(OUT_DIR) to refer to the "out" directory.
+#
+# If you need to re-do something that's already mentioned, just copy
+# the command and add it to the bottom of the list. E.g., if a change
+# that you made last week required touching a file and a change you
+# made today requires touching the same file, just copy the old
+# touch step and add it to the end of the list.
+#
+# ************************************************
+# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
+# ************************************************
+
+# For example:
+#$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/APPS/AndroidTests_intermediates)
+#$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/core_intermediates)
+#$(call add-clean-step, find $(OUT_DIR) -type f -name "IGTalkSession*" -print0 | xargs -0 rm -f)
+#$(call add-clean-step, rm -rf $(PRODUCT_OUT)/data/*)
+
+# ************************************************
+# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
+# ************************************************
diff --git a/yaffs2/utils/mkyaffs2image.c b/yaffs2/utils/mkyaffs2image.c
index 820a238..7b989f6 100644
--- a/yaffs2/utils/mkyaffs2image.c
+++ b/yaffs2/utils/mkyaffs2image.c
@@ -45,8 +45,8 @@ unsigned yaffs_traceMask=0;
#define MAX_OBJECTS 50000
-#define chunkSize 2048
-#define spareSize 64
+unsigned chunkSize = 2048;
+unsigned spareSize = 64;
const char * mkyaffsimage_c_version = "$Id: mkyaffs2image.c,v 1.2 2005/12/13 00:34:58 tpoynor Exp $";
@@ -455,75 +455,104 @@ static int process_directory(int parent, const char *path, int fixstats)
}
+static void usage(void)
+{
+ fprintf(stderr,"mkyaffs2image: image building tool for YAFFS2 built "__DATE__"\n");
+ fprintf(stderr,"usage: mkyaffs2image [-f] [-c <size>] [-s <size>] dir image_file [convert]\n");
+ fprintf(stderr," -f fix file stat (mods, user, group) for device\n");
+ fprintf(stderr," -c <size> set the chunk (NAND page) size. default: 2048\n");
+ fprintf(stderr," -s <size> set the spare (NAND OOB) size. default: 64\n");
+ fprintf(stderr," dir the directory tree to be converted\n");
+ fprintf(stderr," image_file the output file to hold the image\n");
+ fprintf(stderr," 'convert' produce a big-endian image from a little-endian machine\n");
+}
int main(int argc, char *argv[])
{
- int fixstats = 0;
+ int fixstats = 0;
struct stat stats;
-
- if (argc > 1) {
- if (strcmp(argv[1], "-f") == 0) {
- fixstats = 1;
- argc--;
- argv++;
- }
- }
+ int opt;
+ char *image;
+ char *dir;
+
+ while ((opt = getopt(argc, argv, "fc:s:")) != -1) {
+ switch (opt) {
+ case 'f':
+ fixstats = 1;
+ break;
+ case 'c':
+ chunkSize = (unsigned)strtoul(optarg, NULL, 0);
+ break;
+ case 's':
+ spareSize = (unsigned)strtoul(optarg, NULL, 0);
+ break;
+ default:
+ usage();
+ exit(1);
+ }
+ }
- if(argc < 3)
- {
- fprintf(stderr,"mkyaffs2image: image building tool for YAFFS2 built "__DATE__"\n");
- fprintf(stderr,"usage: mkyaffs2image [-f] dir image_file [convert]\n");
- fprintf(stderr," -f fix file stat (mods, user, group) for device\n");
- fprintf(stderr," dir the directory tree to be converted\n");
- fprintf(stderr," image_file the output file to hold the image\n");
- fprintf(stderr," 'convert' produce a big-endian image from a little-endian machine\n");
+ if (!chunkSize || !spareSize) {
+ usage();
exit(1);
}
- if ((argc == 4) && (!strncmp(argv[3], "convert", strlen("convert"))))
- {
- convert_endian = 1;
- }
-
- if(stat(argv[1],&stats) < 0)
+ if ((argc - optind < 2) || (argc - optind > 3)) {
+ usage();
+ exit(1);
+ }
+
+ dir = argv[optind];
+ image = argv[optind + 1];
+
+ if (optind + 2 < argc) {
+ if (!strncmp(argv[optind + 2], "convert", strlen("convert")))
+ convert_endian = 1;
+ else {
+ usage();
+ exit(1);
+ }
+ }
+
+ if(stat(dir,&stats) < 0)
{
- fprintf(stderr,"Could not stat %s\n",argv[1]);
+ fprintf(stderr,"Could not stat %s\n",dir);
exit(1);
}
if(!S_ISDIR(stats.st_mode))
{
- fprintf(stderr," %s is not a directory\n",argv[1]);
+ fprintf(stderr," %s is not a directory\n",dir);
exit(1);
}
- outFile = open(argv[2],O_CREAT | O_TRUNC | O_WRONLY, S_IREAD | S_IWRITE);
+ outFile = open(image,O_CREAT | O_TRUNC | O_WRONLY, S_IREAD | S_IWRITE);
if(outFile < 0)
{
- fprintf(stderr,"Could not open output file %s\n",argv[2]);
+ fprintf(stderr,"Could not open output file %s\n",image);
exit(1);
}
if (fixstats) {
- int len = strlen(argv[1]);
+ int len = strlen(dir);
- if((len >= 4) && (!strcmp(argv[1] + len - 4, "data"))) {
+ if((len >= 4) && (!strcmp(dir + len - 4, "data"))) {
source_path_len = len - 4;
- } else if((len >= 6) && (!strcmp(argv[1] + len - 6, "system"))) {
+ } else if((len >= 6) && (!strcmp(dir + len - 6, "system"))) {
source_path_len = len - 6;
} else {
fprintf(stderr,"Fixstats (-f) option requested but filesystem is not data or android!\n");
exit(1);
}
- fix_stat(argv[1], &stats);
+ fix_stat(dir, &stats);
}
- //printf("Processing directory %s into image file %s\n",argv[1],argv[2]);
+ //printf("Processing directory %s into image file %s\n",dir,image);
error = write_object_header(1, YAFFS_OBJECT_TYPE_DIRECTORY, &stats, 1,"", -1, NULL);
if(error)
- error = process_directory(YAFFS_OBJECTID_ROOT,argv[1],fixstats);
+ error = process_directory(YAFFS_OBJECTID_ROOT,dir,fixstats);
close(outFile);