summaryrefslogtreecommitdiffstats
path: root/exfat/mkfs
diff options
context:
space:
mode:
authorMatt Mower <mowerm@gmail.com>2015-12-13 18:29:45 +0100
committerEthan Yonker <dees_troy@teamw.in>2015-12-23 16:56:56 +0100
commit09ef1e410970b74df384047fcf4c0e18a6ec3643 (patch)
tree6e88024c45cfb5a66220f2910f853e774f07fb16 /exfat/mkfs
parentexfat: Build fsck and update path to mkfs (diff)
downloadandroid_bootable_recovery-09ef1e410970b74df384047fcf4c0e18a6ec3643.tar
android_bootable_recovery-09ef1e410970b74df384047fcf4c0e18a6ec3643.tar.gz
android_bootable_recovery-09ef1e410970b74df384047fcf4c0e18a6ec3643.tar.bz2
android_bootable_recovery-09ef1e410970b74df384047fcf4c0e18a6ec3643.tar.lz
android_bootable_recovery-09ef1e410970b74df384047fcf4c0e18a6ec3643.tar.xz
android_bootable_recovery-09ef1e410970b74df384047fcf4c0e18a6ec3643.tar.zst
android_bootable_recovery-09ef1e410970b74df384047fcf4c0e18a6ec3643.zip
Diffstat (limited to 'exfat/mkfs')
-rw-r--r--exfat/mkfs/Android.mk8
-rw-r--r--exfat/mkfs/cbm.c27
-rw-r--r--exfat/mkfs/cbm.h2
-rw-r--r--exfat/mkfs/fat.c10
-rw-r--r--exfat/mkfs/fat.h2
-rw-r--r--exfat/mkfs/main.c31
-rw-r--r--exfat/mkfs/mkexfat.c28
-rw-r--r--exfat/mkfs/mkexfat.h12
-rw-r--r--exfat/mkfs/mkexfatfs.89
-rw-r--r--exfat/mkfs/rootdir.c8
-rw-r--r--exfat/mkfs/rootdir.h2
-rw-r--r--exfat/mkfs/uct.c6
-rw-r--r--exfat/mkfs/uct.h2
-rw-r--r--exfat/mkfs/uctc.c2
-rw-r--r--exfat/mkfs/uctc.h2
-rw-r--r--exfat/mkfs/vbr.c10
-rw-r--r--exfat/mkfs/vbr.h2
17 files changed, 84 insertions, 79 deletions
diff --git a/exfat/mkfs/Android.mk b/exfat/mkfs/Android.mk
index 2cae2c8ba..0b81aa49b 100644
--- a/exfat/mkfs/Android.mk
+++ b/exfat/mkfs/Android.mk
@@ -1,16 +1,16 @@
LOCAL_PATH := $(call my-dir)
-
include $(CLEAR_VARS)
LOCAL_MODULE := mkexfatfs
+LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin
LOCAL_CFLAGS = -D_FILE_OFFSET_BITS=64
-LOCAL_SRC_FILES = cbm.c fat.c main.c mkexfat.c rootdir.c uct.c uctc.c vbr.c
+LOCAL_SRC_FILES = cbm.c fat.c main.c mkexfat.c rootdir.c uct.c uctc.c vbr.c
LOCAL_C_INCLUDES += $(LOCAL_PATH) \
$(commands_recovery_local_path)/exfat/libexfat \
$(commands_recovery_local_path)/fuse/include
-LOCAL_SHARED_LIBRARIES += libz libc libexfat_twrp libdl
-LOCAL_STATIC_LIBRARIES += libfusetwrp
+LOCAL_SHARED_LIBRARIES := libexfat_twrp
+LOCAL_STATIC_LIBRARIES := libfusetwrp
include $(BUILD_EXECUTABLE)
diff --git a/exfat/mkfs/cbm.c b/exfat/mkfs/cbm.c
index 0110b4065..025057132 100644
--- a/exfat/mkfs/cbm.c
+++ b/exfat/mkfs/cbm.c
@@ -3,7 +3,7 @@
Clusters Bitmap creation code.
Free exFAT implementation.
- Copyright (C) 2011-2013 Andrew Nayenko
+ Copyright (C) 2011-2015 Andrew Nayenko
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
@@ -20,18 +20,19 @@
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#include <limits.h>
#include "cbm.h"
#include "fat.h"
#include "uct.h"
#include "rootdir.h"
+#include <limits.h>
+#include <string.h>
-static off64_t cbm_alignment(void)
+static off_t cbm_alignment(void)
{
return get_cluster_size();
}
-static off64_t cbm_size(void)
+static off_t cbm_size(void)
{
return DIV_ROUND_UP(
(get_volume_size() - get_position(&cbm)) / get_cluster_size(),
@@ -44,24 +45,26 @@ static int cbm_write(struct exfat_dev* dev)
DIV_ROUND_UP(cbm.get_size(), get_cluster_size()) +
DIV_ROUND_UP(uct.get_size(), get_cluster_size()) +
DIV_ROUND_UP(rootdir.get_size(), get_cluster_size());
- size_t bitmap_size = DIV_ROUND_UP(allocated_clusters, CHAR_BIT);
- uint8_t* bitmap = malloc(bitmap_size);
+ size_t bitmap_size = ROUND_UP(allocated_clusters, CHAR_BIT);
+ bitmap_t* bitmap = malloc(BMAP_SIZE(bitmap_size));
size_t i;
if (bitmap == NULL)
{
- exfat_error("failed to allocate bitmap of %zu bytes", bitmap_size);
+ exfat_error("failed to allocate bitmap of %zu bytes",
+ BMAP_SIZE(bitmap_size));
return 1;
}
+ memset(bitmap, 0, BMAP_SIZE(bitmap_size));
- for (i = 0; i < bitmap_size * CHAR_BIT; i++)
+ for (i = 0; i < bitmap_size; i++)
if (i < allocated_clusters)
BMAP_SET(bitmap, i);
- else
- BMAP_CLR(bitmap, i);
- if (exfat_write(dev, bitmap, bitmap_size) < 0)
+ if (exfat_write(dev, bitmap, bitmap_size / CHAR_BIT) < 0)
{
- exfat_error("failed to write bitmap of %zu bytes", bitmap_size);
+ free(bitmap);
+ exfat_error("failed to write bitmap of %zu bytes",
+ bitmap_size / CHAR_BIT);
return 1;
}
free(bitmap);
diff --git a/exfat/mkfs/cbm.h b/exfat/mkfs/cbm.h
index b9d285013..414b0d722 100644
--- a/exfat/mkfs/cbm.h
+++ b/exfat/mkfs/cbm.h
@@ -3,7 +3,7 @@
Clusters Bitmap creation code.
Free exFAT implementation.
- Copyright (C) 2011-2013 Andrew Nayenko
+ Copyright (C) 2011-2015 Andrew Nayenko
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
diff --git a/exfat/mkfs/fat.c b/exfat/mkfs/fat.c
index 9ed90223e..c70dc8637 100644
--- a/exfat/mkfs/fat.c
+++ b/exfat/mkfs/fat.c
@@ -3,7 +3,7 @@
File Allocation Table creation code.
Free exFAT implementation.
- Copyright (C) 2011-2013 Andrew Nayenko
+ Copyright (C) 2011-2015 Andrew Nayenko
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
@@ -20,18 +20,18 @@
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#include <unistd.h>
#include "fat.h"
#include "cbm.h"
#include "uct.h"
#include "rootdir.h"
+#include <unistd.h>
-static off64_t fat_alignment(void)
+static off_t fat_alignment(void)
{
- return (off64_t) 128 * get_sector_size();
+ return (off_t) 128 * get_sector_size();
}
-static off64_t fat_size(void)
+static off_t fat_size(void)
{
return get_volume_size() / get_cluster_size() * sizeof(cluster_t);
}
diff --git a/exfat/mkfs/fat.h b/exfat/mkfs/fat.h
index 1327f0acc..9370cf399 100644
--- a/exfat/mkfs/fat.h
+++ b/exfat/mkfs/fat.h
@@ -3,7 +3,7 @@
File Allocation Table creation code.
Free exFAT implementation.
- Copyright (C) 2011-2013 Andrew Nayenko
+ Copyright (C) 2011-2015 Andrew Nayenko
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
diff --git a/exfat/mkfs/main.c b/exfat/mkfs/main.c
index 3c3c3829f..2ee6da6ac 100644
--- a/exfat/mkfs/main.c
+++ b/exfat/mkfs/main.c
@@ -3,7 +3,7 @@
Creates exFAT file system.
Free exFAT implementation.
- Copyright (C) 2011-2013 Andrew Nayenko
+ Copyright (C) 2011-2015 Andrew Nayenko
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
@@ -20,6 +20,13 @@
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
+#include "mkexfat.h"
+#include "vbr.h"
+#include "fat.h"
+#include "cbm.h"
+#include "uct.h"
+#include "rootdir.h"
+#include <exfat.h>
#include <sys/types.h>
#include <sys/time.h>
#include <unistd.h>
@@ -27,13 +34,6 @@
#include <stdio.h>
#include <string.h>
#include <limits.h>
-#include <exfat.h>
-#include "mkexfat.h"
-#include "vbr.h"
-#include "fat.h"
-#include "cbm.h"
-#include "uct.h"
-#include "rootdir.h"
const struct fs_object* objects[] =
{
@@ -51,7 +51,7 @@ static struct
{
int sector_bits;
int spc_bits;
- off64_t volume_size;
+ off_t volume_size;
le16_t volume_label[EXFAT_ENAME_MAX + 1];
uint32_t volume_serial;
uint64_t first_sector;
@@ -68,7 +68,7 @@ int get_spc_bits(void)
return param.spc_bits;
}
-off64_t get_volume_size(void)
+off_t get_volume_size(void)
{
return param.volume_size;
}
@@ -98,13 +98,13 @@ int get_cluster_size(void)
return get_sector_size() << get_spc_bits();
}
-static int setup_spc_bits(int sector_bits, int user_defined, off64_t volume_size)
+static int setup_spc_bits(int sector_bits, int user_defined, off_t volume_size)
{
int i;
if (user_defined != -1)
{
- off64_t cluster_size = 1 << sector_bits << user_defined;
+ off_t cluster_size = 1 << sector_bits << user_defined;
if (volume_size / cluster_size > EXFAT_LAST_DATA_CLUSTER)
{
struct exfat_human_bytes chb, vhb;
@@ -204,8 +204,7 @@ int main(int argc, char* argv[])
uint64_t first_sector = 0;
struct exfat_dev* dev;
- printf("mkexfatfs %u.%u.%u\n",
- EXFAT_VERSION_MAJOR, EXFAT_VERSION_MINOR, EXFAT_VERSION_PATCH);
+ printf("mkexfatfs %s\n", VERSION);
while ((opt = getopt(argc, argv, "i:n:p:s:V")) != -1)
{
@@ -224,12 +223,12 @@ int main(int argc, char* argv[])
spc_bits = logarithm2(atoi(optarg));
if (spc_bits < 0)
{
- exfat_error("invalid option value: `%s'", optarg);
+ exfat_error("invalid option value: '%s'", optarg);
return 1;
}
break;
case 'V':
- puts("Copyright (C) 2011-2013 Andrew Nayenko");
+ puts("Copyright (C) 2011-2015 Andrew Nayenko");
return 0;
default:
usage(argv[0]);
diff --git a/exfat/mkfs/mkexfat.c b/exfat/mkfs/mkexfat.c
index c5c86d9b8..4b7a344c8 100644
--- a/exfat/mkfs/mkexfat.c
+++ b/exfat/mkfs/mkexfat.c
@@ -3,7 +3,7 @@
FS creation engine.
Free exFAT implementation.
- Copyright (C) 2011-2013 Andrew Nayenko
+ Copyright (C) 2011-2015 Andrew Nayenko
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
@@ -20,17 +20,17 @@
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
+#include "mkexfat.h"
#include <sys/types.h>
#include <unistd.h>
#include <inttypes.h>
#include <stdio.h>
#include <string.h>
-#include "mkexfat.h"
-static int check_size(off64_t volume_size)
+static int check_size(off_t volume_size)
{
const struct fs_object** pp;
- off64_t position = 0;
+ off_t position = 0;
for (pp = objects; *pp; pp++)
{
@@ -52,12 +52,12 @@ static int check_size(off64_t volume_size)
}
static int erase_object(struct exfat_dev* dev, const void* block,
- size_t block_size, off64_t start, off64_t size)
+ size_t block_size, off_t start, off_t size)
{
- const off64_t block_count = DIV_ROUND_UP(size, block_size);
- off64_t i;
+ const off_t block_count = DIV_ROUND_UP(size, block_size);
+ off_t i;
- if (exfat_seek(dev, start, SEEK_SET) == (off64_t) -1)
+ if (exfat_seek(dev, start, SEEK_SET) == (off_t) -1)
{
exfat_error("seek to 0x%"PRIx64" failed", start);
return 1;
@@ -77,7 +77,7 @@ static int erase_object(struct exfat_dev* dev, const void* block,
static int erase(struct exfat_dev* dev)
{
const struct fs_object** pp;
- off64_t position = 0;
+ off_t position = 0;
const size_t block_size = 1024 * 1024;
void* block = malloc(block_size);
@@ -107,12 +107,12 @@ static int erase(struct exfat_dev* dev)
static int create(struct exfat_dev* dev)
{
const struct fs_object** pp;
- off64_t position = 0;
+ off_t position = 0;
for (pp = objects; *pp; pp++)
{
position = ROUND_UP(position, (*pp)->get_alignment());
- if (exfat_seek(dev, position, SEEK_SET) == (off64_t) -1)
+ if (exfat_seek(dev, position, SEEK_SET) == (off_t) -1)
{
exfat_error("seek to 0x%"PRIx64" failed", position);
return 1;
@@ -124,7 +124,7 @@ static int create(struct exfat_dev* dev)
return 0;
}
-int mkfs(struct exfat_dev* dev, off64_t volume_size)
+int mkfs(struct exfat_dev* dev, off_t volume_size)
{
if (check_size(volume_size) != 0)
return 1;
@@ -146,10 +146,10 @@ int mkfs(struct exfat_dev* dev, off64_t volume_size)
return 0;
}
-off64_t get_position(const struct fs_object* object)
+off_t get_position(const struct fs_object* object)
{
const struct fs_object** pp;
- off64_t position = 0;
+ off_t position = 0;
for (pp = objects; *pp; pp++)
{
diff --git a/exfat/mkfs/mkexfat.h b/exfat/mkfs/mkexfat.h
index d0685afa7..8d2b5e393 100644
--- a/exfat/mkfs/mkexfat.h
+++ b/exfat/mkfs/mkexfat.h
@@ -3,7 +3,7 @@
FS creation engine.
Free exFAT implementation.
- Copyright (C) 2011-2013 Andrew Nayenko
+ Copyright (C) 2011-2015 Andrew Nayenko
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
@@ -27,8 +27,8 @@
struct fs_object
{
- off64_t (*get_alignment)(void);
- off64_t (*get_size)(void);
+ off_t (*get_alignment)(void);
+ off_t (*get_size)(void);
int (*write)(struct exfat_dev* dev);
};
@@ -36,14 +36,14 @@ extern const struct fs_object* objects[];
int get_sector_bits(void);
int get_spc_bits(void);
-off64_t get_volume_size(void);
+off_t get_volume_size(void);
const le16_t* get_volume_label(void);
uint32_t get_volume_serial(void);
uint64_t get_first_sector(void);
int get_sector_size(void);
int get_cluster_size(void);
-int mkfs(struct exfat_dev* dev, off64_t volume_size);
-off64_t get_position(const struct fs_object* object);
+int mkfs(struct exfat_dev* dev, off_t volume_size);
+off_t get_position(const struct fs_object* object);
#endif /* ifndef MKFS_MKEXFAT_H_INCLUDED */
diff --git a/exfat/mkfs/mkexfatfs.8 b/exfat/mkfs/mkexfatfs.8
index 5f6ba3db7..e3394688d 100644
--- a/exfat/mkfs/mkexfatfs.8
+++ b/exfat/mkfs/mkexfatfs.8
@@ -1,4 +1,4 @@
-.\" Copyright (C) 2011 Andrew Nayenko
+.\" Copyright (C) 2011-2015 Andrew Nayenko
.\"
.TH MKEXFATFS 8 "January 2011"
.SH NAME
@@ -31,7 +31,10 @@
.B mkexfatfs
creates an exFAT file system on a block device.
.I device
-is a special file corresponding to the device.
+is a special file corresponding to the partition on the device. Note that if
+this is an MBR partition then the file system type should be set to 0x07
+(NTFS/exFAT) otherwise other operating systems may refuse to mount the
+file system.
.SH OPTIONS
Command line options available:
@@ -65,4 +68,4 @@ Zero is returned on successful creation. Any other code means an error.
Andrew Nayenko
.SH SEE ALSO
-.BR mkfs (8)
+.BR mkfs (8), fdisk (8)
diff --git a/exfat/mkfs/rootdir.c b/exfat/mkfs/rootdir.c
index 49d364324..84fa31f40 100644
--- a/exfat/mkfs/rootdir.c
+++ b/exfat/mkfs/rootdir.c
@@ -3,7 +3,7 @@
Root directory creation code.
Free exFAT implementation.
- Copyright (C) 2011-2013 Andrew Nayenko
+ Copyright (C) 2011-2015 Andrew Nayenko
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
@@ -20,18 +20,18 @@
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#include <string.h>
#include "rootdir.h"
#include "uct.h"
#include "cbm.h"
#include "uctc.h"
+#include <string.h>
-static off64_t rootdir_alignment(void)
+static off_t rootdir_alignment(void)
{
return get_cluster_size();
}
-static off64_t rootdir_size(void)
+static off_t rootdir_size(void)
{
return get_cluster_size();
}
diff --git a/exfat/mkfs/rootdir.h b/exfat/mkfs/rootdir.h
index 2d1d3453c..56db5b026 100644
--- a/exfat/mkfs/rootdir.h
+++ b/exfat/mkfs/rootdir.h
@@ -3,7 +3,7 @@
Root directory creation code.
Free exFAT implementation.
- Copyright (C) 2011-2013 Andrew Nayenko
+ Copyright (C) 2011-2015 Andrew Nayenko
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
diff --git a/exfat/mkfs/uct.c b/exfat/mkfs/uct.c
index 5f173233c..d1deb2d02 100644
--- a/exfat/mkfs/uct.c
+++ b/exfat/mkfs/uct.c
@@ -3,7 +3,7 @@
Upper Case Table creation code.
Free exFAT implementation.
- Copyright (C) 2011-2013 Andrew Nayenko
+ Copyright (C) 2011-2015 Andrew Nayenko
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
@@ -23,12 +23,12 @@
#include "uct.h"
#include "uctc.h"
-static off64_t uct_alignment(void)
+static off_t uct_alignment(void)
{
return get_cluster_size();
}
-static off64_t uct_size(void)
+static off_t uct_size(void)
{
return sizeof(upcase_table);
}
diff --git a/exfat/mkfs/uct.h b/exfat/mkfs/uct.h
index ef3339218..3a08db967 100644
--- a/exfat/mkfs/uct.h
+++ b/exfat/mkfs/uct.h
@@ -3,7 +3,7 @@
Upper Case Table creation code.
Free exFAT implementation.
- Copyright (C) 2011-2013 Andrew Nayenko
+ Copyright (C) 2011-2015 Andrew Nayenko
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
diff --git a/exfat/mkfs/uctc.c b/exfat/mkfs/uctc.c
index 1ee8efe3f..5849f3777 100644
--- a/exfat/mkfs/uctc.c
+++ b/exfat/mkfs/uctc.c
@@ -3,7 +3,7 @@
Upper Case Table contents.
Free exFAT implementation.
- Copyright (C) 2011-2013 Andrew Nayenko
+ Copyright (C) 2011-2015 Andrew Nayenko
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
diff --git a/exfat/mkfs/uctc.h b/exfat/mkfs/uctc.h
index 3e7dee0ef..3e200f154 100644
--- a/exfat/mkfs/uctc.h
+++ b/exfat/mkfs/uctc.h
@@ -3,7 +3,7 @@
Upper Case Table declaration.
Free exFAT implementation.
- Copyright (C) 2011-2013 Andrew Nayenko
+ Copyright (C) 2011-2015 Andrew Nayenko
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
diff --git a/exfat/mkfs/vbr.c b/exfat/mkfs/vbr.c
index bbf1304d9..702aa6d14 100644
--- a/exfat/mkfs/vbr.c
+++ b/exfat/mkfs/vbr.c
@@ -3,7 +3,7 @@
Volume Boot Record creation code.
Free exFAT implementation.
- Copyright (C) 2011-2013 Andrew Nayenko
+ Copyright (C) 2011-2015 Andrew Nayenko
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
@@ -20,19 +20,19 @@
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#include <string.h>
#include "vbr.h"
#include "fat.h"
#include "cbm.h"
#include "uct.h"
#include "rootdir.h"
+#include <string.h>
-static off64_t vbr_alignment(void)
+static off_t vbr_alignment(void)
{
return get_sector_size();
}
-static off64_t vbr_size(void)
+static off_t vbr_size(void)
{
return 12 * get_sector_size();
}
@@ -43,7 +43,7 @@ static void init_sb(struct exfat_super_block* sb)
uint32_t fat_sectors;
clusters_max = get_volume_size() / get_cluster_size();
- fat_sectors = DIV_ROUND_UP((off64_t) clusters_max * sizeof(cluster_t),
+ fat_sectors = DIV_ROUND_UP((off_t) clusters_max * sizeof(cluster_t),
get_sector_size());
memset(sb, 0, sizeof(struct exfat_super_block));
diff --git a/exfat/mkfs/vbr.h b/exfat/mkfs/vbr.h
index fec88bc1e..74e60e50c 100644
--- a/exfat/mkfs/vbr.h
+++ b/exfat/mkfs/vbr.h
@@ -3,7 +3,7 @@
Volume Boot Record creation code.
Free exFAT implementation.
- Copyright (C) 2011-2013 Andrew Nayenko
+ Copyright (C) 2011-2015 Andrew Nayenko
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