Hello community, here is the log from the commit of package exfatprogs for openSUSE:Factory checked in at 2020-05-13 22:56:09 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/exfatprogs (Old) and /work/SRC/openSUSE:Factory/.exfatprogs.new.2738 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "exfatprogs" Wed May 13 22:56:09 2020 rev:2 rq:804462 version:1.0.3 Changes: -------- --- /work/SRC/openSUSE:Factory/exfatprogs/exfatprogs.changes 2020-04-25 20:28:51.058087195 +0200 +++ /work/SRC/openSUSE:Factory/.exfatprogs.new.2738/exfatprogs.changes 2020-05-13 22:56:10.659020170 +0200 @@ -1,0 +2,15 @@ +Tue May 12 15:36:26 UTC 2020 - Ismail Dönmez <[email protected]> + +- Update to version 1.0.3 + * libexfat0 library is no longer installed + * Rename label.exfat to tune.exfat. + * tune.exfat: change argument style + (-l option for print level, -L option for setting label) + * mkfs.exfat: harmonize set volume label option with tune.exfat. + * Fix the reported build warnings/errors. + * Add memset to clean garbage in allocation. + * Fix wrong volume label array size. + * Open a device using O_EXCL to avoid formatting it while it is mounted. + * Add man page. + +------------------------------------------------------------------- Old: ---- exfatprogs-1.0.2.tar.gz New: ---- exfatprogs-1.0.3.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ exfatprogs.spec ++++++ --- /var/tmp/diff_new_pack.2Qu28x/_old 2020-05-13 22:56:11.115021060 +0200 +++ /var/tmp/diff_new_pack.2Qu28x/_new 2020-05-13 22:56:11.119021068 +0200 @@ -17,7 +17,7 @@ Name: exfatprogs -Version: 1.0.2 +Version: 1.0.3 Release: 0 Summary: Utilities for exFAT file system maintenance License: GPL-2.0-or-later @@ -28,6 +28,7 @@ BuildRequires: libtool BuildRequires: pkgconfig Conflicts: exfat-utils +Obsoletes: libexfat0 < %{version} ExclusiveArch: aarch64 x86_64 %description @@ -49,30 +50,21 @@ %build autoreconf -fi -%configure --disable-static +%configure %make_build %install %make_install -find %{buildroot} -type f -name "*.la" -delete -print - -# There is no header yet, so this is unusable for now. -rm %{buildroot}%{_libdir}/libexfat.so - -%post -n libexfat0 -p /sbin/ldconfig -%postun -n libexfat0 -p /sbin/ldconfig - -%files -n libexfat0 -%license COPYING -%{_libdir}/libexfat.so.0* - %files %license COPYING %doc README.md +%{_mandir}/man8/fsck.exfat.8%{?ext_man} +%{_mandir}/man8/mkfs.exfat.8%{?ext_man} +%{_mandir}/man8/tune.exfat.8%{?ext_man} %{_sbindir}/fsck.exfat -%{_sbindir}/label.exfat %{_sbindir}/mkfs.exfat +%{_sbindir}/tune.exfat %changelog ++++++ exfatprogs-1.0.2.tar.gz -> exfatprogs-1.0.3.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/exfatprogs-1.0.2/.travis.yml new/exfatprogs-1.0.3/.travis.yml --- old/exfatprogs-1.0.2/.travis.yml 2020-04-23 10:22:33.000000000 +0200 +++ new/exfatprogs-1.0.3/.travis.yml 2020-05-12 07:29:27.000000000 +0200 @@ -16,7 +16,6 @@ - ./configure > /dev/null - make -j$((`nproc`+1)) > /dev/null - sudo make install > /dev/null - - sudo cp lib/.libs/libexfat.so* /lib/ - cd exfat_oot - make > /dev/null - sudo make install > /dev/null diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/exfatprogs-1.0.2/Makefile.am new/exfatprogs-1.0.3/Makefile.am --- old/exfatprogs-1.0.2/Makefile.am 2020-04-23 10:22:33.000000000 +0200 +++ new/exfatprogs-1.0.3/Makefile.am 2020-05-12 07:29:27.000000000 +0200 @@ -2,4 +2,20 @@ ACLOCAL_AMFLAGS = -I m4 -SUBDIRS = lib mkfs fsck label +SUBDIRS = lib mkfs fsck tune + +# manpages +dist_man8_MANS = \ + manpages/fsck.exfat.8 \ + manpages/tune.exfat.8 \ + manpages/mkfs.exfat.8 + +# other stuff +EXTRA_DIST = \ + include \ + Android.bp \ + lib/Android.bp \ + mkfs/Android.bp \ + tune/Android.bp \ + fsck/Android.bp \ + README.md diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/exfatprogs-1.0.2/NEWS new/exfatprogs-1.0.3/NEWS --- old/exfatprogs-1.0.2/NEWS 1970-01-01 01:00:00.000000000 +0100 +++ new/exfatprogs-1.0.3/NEWS 2020-05-12 07:29:27.000000000 +0200 @@ -0,0 +1,46 @@ +exfatprogs 1.0.3 - released 2020-05-12 +====================================== + +CHANGES : + * Rename label.exfat to tune.exfat. + * tune.exfat: change argument style(-l option for print level, + -L option for setting label) + * mkfs.exfat: harmonize set volume label option with tune.exfat. + +NEW FEATURES : + * Add man page. + +BUG FIXES : + * Fix the reported build warnings/errors. + * Add memset to clean garbage in allocation. + * Fix wrong volume label array size. + * Open a device using O_EXCL to avoid formatting it while it is mounted. + * Fix incomplete "make dist" generated tarball. + + +exfatprogs 1.0.2 - released 2020-04-23 +====================================== + +CHANGES : + * Rename project name to exfatprogs. + * Replace iconv library by standard C functions mbstowcs() and wcrtomb(). + +NEW FEATURES : + * Add support for Android build system. + * label.exfat: Add support for label.exfat to set/get exfat volume label. + +BUG FIXES : + * Fix the build warnings/errors and add warning options. + * Fix several bugs(memory leak, wrong endian conversion, zero out beyond + end of file) and cleanup codes + * Fix issues on big endian system and on 32bit system. + + +exfatprogs 1.0.1 - released 2020-04-09 +====================================== + +NEW FEATURES : + * mkfs.exfat: quick/full format support + * mkfs.exfat: specify cluster size + * mkfs.exfat: set volume label + * fsck.exfat: consistency check support diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/exfatprogs-1.0.2/README.md new/exfatprogs-1.0.3/README.md --- old/exfatprogs-1.0.2/README.md 2020-04-23 10:22:33.000000000 +0200 +++ new/exfatprogs-1.0.3/README.md 2020-05-12 07:29:27.000000000 +0200 @@ -1,10 +1,11 @@ ## exfatprogs -exfatprogs is userspace utilities for exfat filesystem under GNU GPL version 2. - -## Maintainers -* Namjae Jeon <[email protected]> -* Hyunchul Lee <[email protected]> +As new exfat filesystem is merged into linux-5.7 kernel, exfatprogs is +created as an official userspace utilities that contain all of the standard +utilities for creating and fixing and debugging exfat filesystem in linux +system. The goal of exfatprogs is to provide high performance and quality +at the level of exfat utilities in windows. And this software is licensed +under the GNU General Public License Version 2. ## Building exfatprogs Install prerequisite packages: @@ -40,7 +41,7 @@ 3. For full format(zero out) mkfs.exfat -f /dev/sda1 4. For set volume label, use -l option with string user want. - mkfs.exfat -l "my usb" /dev/sda1 + mkfs.exfat -L "my usb" /dev/sda1 - fsck.exfat: Check the consistency of your exfat filesystem and optionally repair a corrupted device formatted by exfat. @@ -50,12 +51,20 @@ fsck.exfat /dev/sda1 2. repair and fix.(preparing) -- label.exfat: - Get or set volume label from a given device that formatted by exfat filesystem. +- tune.exfat: + Adjust tunable filesystem parameters on an exFAT filesystem Usage example: - 1. get volume label. - label.exfat -g /dev/sda1 + 1. print current volume label. + tune.exfat -l /dev/sda1 2. set new volume label. - label.exfat -s "new label" /dev/sda1 + tune.exfat -L "new label" /dev/sda1 ``` + +## Sending feedback +If you have any issues, please create [issues][1] or contact to [Namjae Jeon](mailto:[email protected]) and +[Hyunchul Lee](mailto:[email protected]). +[Contributions][2] are also welcome. + +[1]: https://github.com/exfatprogs/exfatprogs/issues +[2]: https://github.com/exfatprogs/exfatprogs/pulls diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/exfatprogs-1.0.2/configure.ac new/exfatprogs-1.0.3/configure.ac --- old/exfatprogs-1.0.2/configure.ac 2020-04-23 10:22:33.000000000 +0200 +++ new/exfatprogs-1.0.3/configure.ac 2020-05-12 07:29:27.000000000 +0200 @@ -14,7 +14,7 @@ AC_CONFIG_HEADER([config.h]) AC_CONFIG_MACRO_DIR([m4]) AC_CONFIG_AUX_DIR([build-aux]) -AM_INIT_AUTOMAKE([foreign tar-pax dist-xz subdir-objects]) +AM_INIT_AUTOMAKE([foreign tar-pax subdir-objects]) AC_LANG([C]) AC_PROG_CC @@ -24,14 +24,12 @@ AC_SYS_LARGEFILE AC_C_BIGENDIAN -PKG_PROG_PKG_CONFIG([0.9]) - AC_CONFIG_FILES([ Makefile lib/Makefile mkfs/Makefile fsck/Makefile - label/Makefile + tune/Makefile ]) AC_OUTPUT diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/exfatprogs-1.0.2/fsck/Makefile.am new/exfatprogs-1.0.3/fsck/Makefile.am --- old/exfatprogs-1.0.2/fsck/Makefile.am 2020-04-23 10:22:33.000000000 +0200 +++ new/exfatprogs-1.0.3/fsck/Makefile.am 2020-05-12 07:29:27.000000000 +0200 @@ -1,8 +1,6 @@ -AM_CFLAGS = -Wall -Werror -Wunused-parameter \ - -Wno-address-of-packed-member \ - -include $(top_srcdir)/config.h -I$(top_srcdir)/include -fno-common -fsck_exfat_LDADD = $(top_builddir)/lib/libexfat.la +AM_CFLAGS = -Wall -include $(top_builddir)/config.h -I$(top_srcdir)/include -fno-common +fsck_exfat_LDADD = $(top_builddir)/lib/libexfat.a sbin_PROGRAMS = fsck.exfat -fsck_exfat_SOURCES = fsck.c repair.c +fsck_exfat_SOURCES = fsck.c repair.c fsck.h repair.h diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/exfatprogs-1.0.2/fsck/fsck.c new/exfatprogs-1.0.3/fsck/fsck.c --- old/exfatprogs-1.0.2/fsck/fsck.c 2020-04-23 10:22:33.000000000 +0200 +++ new/exfatprogs-1.0.3/fsck/fsck.c 2020-05-12 07:29:27.000000000 +0200 @@ -8,6 +8,7 @@ #include <stdlib.h> #include <stdio.h> #include <getopt.h> +#include <inttypes.h> #include <string.h> #include <errno.h> #include <locale.h> @@ -107,11 +108,12 @@ INIT_LIST_HEAD(&node->sibling); INIT_LIST_HEAD(&node->list); + node->last_pclus = EXFAT_EOF_CLUSTER; + node->attr = attr; if (attr & ATTR_SUBDIR) exfat_stat.dir_count++; else exfat_stat.file_count++; - node->attr = attr; return node; } @@ -193,6 +195,10 @@ if (exfat) { if (exfat->bs) free(exfat->bs); + if (exfat->de_iter.dentries) + free(exfat->de_iter.dentries); + if (exfat->alloc_bitmap) + free(exfat->alloc_bitmap); free(exfat); } } @@ -322,7 +328,7 @@ ssize_t read_size; size_t remain_size; - if (file_offset >= node->size) + if (file_offset >= (off_t)node->size) return EOF; clus_size = EXFAT_CLUSTER_SIZE(exfat->bs); @@ -332,10 +338,16 @@ if (remain_size == 0) return 0; - p_clus = node->first_clus; - clus_offset = file_offset % clus_size; start_l_clus = file_offset / clus_size; - l_clus = 0; + clus_offset = file_offset % clus_size; + if (start_l_clus >= node->last_lclus && + node->last_pclus != EXFAT_EOF_CLUSTER) { + l_clus = node->last_lclus; + p_clus = node->last_pclus; + } else { + l_clus = 0; + p_clus = node->first_clus; + } while (p_clus != EXFAT_EOF_CLUSTER) { if (exfat_invalid_clus(exfat, p_clus)) @@ -353,7 +365,7 @@ buf = (char *)buf + read_size; remain_size -= read_size; if (remain_size == 0) - return total_size; + goto out; next_clus: l_clus++; @@ -361,6 +373,9 @@ if (ret) return ret; } +out: + node->last_lclus = l_clus; + node->last_pclus = p_clus; return total_size - remain_size; } @@ -369,7 +384,7 @@ __le32 checksum; unsigned short size; void *sect; - int i; + unsigned int i; size = EXFAT_SECTOR_SIZE(exfat->bs); sect = malloc(size); @@ -467,7 +482,7 @@ if (le64_to_cpu(bs->bsx.vol_length) * EXFAT_SECTOR_SIZE(bs) > exfat->blk_dev->size) { - exfat_err("too large sector count: %llu\n, expected: %llu\n", + exfat_err("too large sector count: %" PRIu64 "\n, expected: %llu\n", le64_to_cpu(bs->bsx.vol_length), exfat->blk_dev->num_sectors); goto err; @@ -585,7 +600,7 @@ return ret; } -int exfat_de_iter_init(struct exfat_de_iter *iter, struct exfat *exfat, +static int exfat_de_iter_init(struct exfat_de_iter *iter, struct exfat *exfat, struct exfat_inode *dir) { ssize_t ret; @@ -613,16 +628,11 @@ return 0; } -void exfat_de_iter_fini(struct exfat_de_iter *iter) -{ - free(iter->dentries); -} - -int exfat_de_iter_get(struct exfat_de_iter *iter, - int ith, struct exfat_dentry **dentry) +static int exfat_de_iter_get(struct exfat_de_iter *iter, + int ith, struct exfat_dentry **dentry) { off_t de_next_file_offset; - int de_next_offset; + unsigned int de_next_offset; bool need_read_1_clus = false; int ret; @@ -674,7 +684,7 @@ * @skip_dentries must be the largest @ith + 1 of exfat_de_iter_get * since the last call of exfat_de_iter_advance */ -int exfat_de_iter_advance(struct exfat_de_iter *iter, int skip_dentries) +static int exfat_de_iter_advance(struct exfat_de_iter *iter, int skip_dentries) { if (skip_dentries != iter->max_skip_dentries) return -EINVAL; @@ -685,7 +695,7 @@ return 0; } -off_t exfat_de_iter_file_offset(struct exfat_de_iter *iter) +static off_t exfat_de_iter_file_offset(struct exfat_de_iter *iter) { return iter->de_file_offset; } @@ -712,7 +722,7 @@ if (node->size > le32_to_cpu(exfat->bs->bsx.clu_count) * EXFAT_CLUSTER_SIZE(exfat->bs)) { resolve_path_parent(&path_resolve_ctx, parent, node); - exfat_err("size %llu is greater than cluster heap: %s\n", + exfat_err("size %" PRIu64 " is greater than cluster heap: %s\n", node->size, path_resolve_ctx.local_path); ret = false; } @@ -727,7 +737,7 @@ if ((node->attr & ATTR_SUBDIR) && node->size % EXFAT_CLUSTER_SIZE(exfat->bs) != 0) { resolve_path_parent(&path_resolve_ctx, parent, node); - exfat_err("directory size %llu is not divisible by %d: %s\n", + exfat_err("directory size %" PRIu64 " is not divisible by %d: %s\n", node->size, EXFAT_CLUSTER_SIZE(exfat->bs), path_resolve_ctx.local_path); ret = false; @@ -746,7 +756,7 @@ static void dentry_calc_checksum(struct exfat_dentry *dentry, __le16 *checksum, bool primary) { - int i; + unsigned int i; uint8_t *bytes; bytes = (uint8_t *)dentry; @@ -791,12 +801,12 @@ ret = exfat_de_iter_get(iter, 0, &file_de); if (ret || file_de->type != EXFAT_FILE) { exfat_err("failed to get file dentry. %d\n", ret); - return ret; + return -EINVAL; } ret = exfat_de_iter_get(iter, 1, &stream_de); if (ret || stream_de->type != EXFAT_STREAM) { exfat_err("failed to get stream dentry. %d\n", ret); - return ret; + return -EINVAL; } *new_node = NULL; @@ -815,6 +825,7 @@ ret = exfat_de_iter_get(iter, i, &name_de); if (ret || name_de->type != EXFAT_NAME) { exfat_err("failed to get name dentry. %d\n", ret); + ret = -EINVAL; goto err; } @@ -839,9 +850,10 @@ if (le64_to_cpu(stream_de->stream_valid_size) > node->size) { resolve_path_parent(&path_resolve_ctx, iter->parent, node); - exfat_err("valid size %llu greater than size %llu: %s\n", + exfat_err("valid size %" PRIu64 " greater than size %" PRIu64 ": %s\n", le64_to_cpu(stream_de->stream_valid_size), node->size, path_resolve_ctx.local_path); + ret = -EINVAL; goto err; } @@ -855,7 +867,7 @@ return ret; } -static int read_child(struct exfat_de_iter *de_iter, +static int read_file(struct exfat_de_iter *de_iter, struct exfat_inode **new_node, int *dentry_count) { struct exfat_inode *node; @@ -885,6 +897,7 @@ { struct exfat *exfat; struct exfat_dentry *dentry; + __le16 disk_label[VOLUME_LABEL_MAX_LEN]; exfat = iter->exfat; if (exfat_de_iter_get(iter, 0, &dentry)) @@ -898,7 +911,8 @@ return false; } - if (exfat_utf16_dec(dentry->vol_label, dentry->vol_char_cnt*2, + memcpy(disk_label, dentry->vol_label, sizeof(disk_label)); + if (exfat_utf16_dec(disk_label, dentry->vol_char_cnt*2, exfat->volume_label, sizeof(exfat->volume_label)) < 0) { exfat_err("failed to decode volume label\n"); return false; @@ -912,13 +926,13 @@ { struct exfat_dentry *dentry; struct exfat *exfat; - size_t alloc_bitmap_size; + ssize_t alloc_bitmap_size; exfat = iter->exfat; if (exfat_de_iter_get(iter, 0, &dentry)) return false; - exfat_debug("start cluster %#x, size %#llx\n", + exfat_debug("start cluster %#x, size %#" PRIx64 "\n", le32_to_cpu(dentry->bitmap_start_clu), le64_to_cpu(dentry->bitmap_size)); @@ -926,7 +940,7 @@ if (le64_to_cpu(dentry->bitmap_size) < DIV_ROUND_UP(exfat->bit_count, 8)) { - exfat_err("invalid size of allocation bitmap. 0x%llx\n", + exfat_err("invalid size of allocation bitmap. 0x%" PRIx64 "\n", le64_to_cpu(dentry->bitmap_size)); return false; } @@ -962,7 +976,7 @@ { struct exfat_dentry *dentry; struct exfat *exfat; - size_t size; + ssize_t size; __le16 *upcase; __le32 checksum; @@ -977,10 +991,10 @@ return false; } - size = (size_t)le64_to_cpu(dentry->upcase_size); - if (size > EXFAT_MAX_UPCASE_CHARS * sizeof(__le16) || + size = (ssize_t)le64_to_cpu(dentry->upcase_size); + if (size > (ssize_t)(EXFAT_MAX_UPCASE_CHARS * sizeof(__le16)) || size == 0 || size % sizeof(__le16)) { - exfat_err("invalid size of upcase table. 0x%llx\n", + exfat_err("invalid size of upcase table. 0x%" PRIx64 "\n", le64_to_cpu(dentry->upcase_size)); return false; } @@ -1015,7 +1029,7 @@ static int read_children(struct exfat *exfat, struct exfat_inode *dir) { int ret; - struct exfat_inode *node; + struct exfat_inode *node = NULL; struct exfat_dentry *dentry; int dentry_count; struct list_head sub_dir_list; @@ -1043,7 +1057,7 @@ switch (dentry->type) { case EXFAT_FILE: - ret = read_child(de_iter, &node, &dentry_count); + ret = read_file(de_iter, &node, &dentry_count); if (ret) { exfat_err("failed to verify file. %d\n", ret); goto err; @@ -1166,7 +1180,7 @@ root->size = clus_count * EXFAT_CLUSTER_SIZE(exfat->bs); exfat->root = root; - exfat_debug("root directory: start cluster[0x%x] size[0x%llx]\n", + exfat_debug("root directory: start cluster[0x%x] size[0x%" PRIx64 "]\n", root->first_clus, root->size); return true; err: @@ -1201,11 +1215,14 @@ int main(int argc, char * const argv[]) { int c, ret; - struct fsck_user_input ui = {0,}; - struct exfat_blk_dev bd = {0,}; + struct fsck_user_input ui; + struct exfat_blk_dev bd; struct exfat *exfat = NULL; bool version_only = false; + memset(&ui, 0, sizeof(ui)); + memset(&bd, 0, sizeof(bd)); + print_level = EXFAT_ERROR; if (!setlocale(LC_CTYPE, "")) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/exfatprogs-1.0.2/fsck/fsck.h new/exfatprogs-1.0.3/fsck/fsck.h --- old/exfatprogs-1.0.2/fsck/fsck.h 2020-04-23 10:22:33.000000000 +0200 +++ new/exfatprogs-1.0.3/fsck/fsck.h 2020-05-12 07:29:27.000000000 +0200 @@ -5,8 +5,6 @@ #ifndef _FSCK_H #define _FSCK_H -#include <limits.h> - #include "list.h" typedef __u32 clus_t; @@ -17,15 +15,16 @@ struct list_head sibling; struct list_head list; clus_t first_clus; + clus_t last_lclus; + clus_t last_pclus; __u16 attr; - __u64 size; + uint64_t size; bool is_contiguous; off_t dentry_file_offset; __le16 name[0]; /* only for directory */ }; #define EXFAT_NAME_MAX 255 -#define VOLUME_LABEL_BUFFER_SIZE (VOLUME_LABEL_MAX_LEN*MB_LEN_MAX+1) #define NAME_BUFFER_SIZE ((EXFAT_NAME_MAX+1)*2) struct exfat_de_iter { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/exfatprogs-1.0.2/fsck/repair.c new/exfatprogs-1.0.3/fsck/repair.c --- old/exfatprogs-1.0.2/fsck/repair.c 2020-04-23 10:22:33.000000000 +0200 +++ new/exfatprogs-1.0.3/fsck/repair.c 2020-05-12 07:29:27.000000000 +0200 @@ -21,7 +21,7 @@ union exfat_repair_context *rctx) { unsigned int size; - int i; + unsigned int i; size = EXFAT_SECTOR_SIZE(exfat->bs); for (i = 0; i < size/sizeof(__le32); i++) { @@ -47,7 +47,7 @@ static struct exfat_repair_problem *find_problem(er_problem_code_t prcode) { - int i; + unsigned int i; for (i = 0; i < sizeof(problems)/sizeof(problems[0]); i++) { if (problems[i].prcode == prcode) { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/exfatprogs-1.0.2/include/exfat_ondisk.h new/exfatprogs-1.0.3/include/exfat_ondisk.h --- old/exfatprogs-1.0.2/include/exfat_ondisk.h 2020-04-23 10:22:33.000000000 +0200 +++ new/exfatprogs-1.0.3/include/exfat_ondisk.h 2020-05-12 07:29:27.000000000 +0200 @@ -26,9 +26,9 @@ #define cpu_to_le64(x) (x) #endif -#define le64_to_cpu(x) cpu_to_le64(x) -#define le32_to_cpu(x) cpu_to_le32(x) -#define le16_to_cpu(x) cpu_to_le16(x) +#define le64_to_cpu(x) ((uint64_t)cpu_to_le64(x)) +#define le32_to_cpu(x) ((uint32_t)cpu_to_le32(x)) +#define le16_to_cpu(x) ((uint16_t)cpu_to_le16(x)) #define PBR_SIGNATURE 0xAA55 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/exfatprogs-1.0.2/include/libexfat.h new/exfatprogs-1.0.3/include/libexfat.h --- old/exfatprogs-1.0.2/include/libexfat.h 2020-04-23 10:22:33.000000000 +0200 +++ new/exfatprogs-1.0.3/include/libexfat.h 2020-05-12 07:29:27.000000000 +0200 @@ -6,7 +6,9 @@ #ifndef _LIBEXFAT_H #include <stdbool.h> +#include <sys/types.h> #include <wchar.h> +#include <limits.h> #define KB (1024) #define MB (1024*1024) @@ -26,6 +28,10 @@ #define EXFAT_MAX_NUM_CLUSTER (0xFFFFFFF5) +#define DEFAULT_SECTOR_SIZE (512) + +#define VOLUME_LABEL_BUFFER_SIZE (VOLUME_LABEL_MAX_LEN*MB_LEN_MAX+1) + /* Upcase tabel macro */ #define EXFAT_UPCASE_TABLE_SIZE (5836) @@ -54,7 +60,7 @@ unsigned int cluster_size; unsigned int sec_per_clu; bool quick; - __u16 volume_label[11]; + __u16 volume_label[VOLUME_LABEL_MAX_LEN]; int volume_label_len; }; @@ -83,9 +89,9 @@ extern unsigned int print_level; -#define EXFAT_ERROR (0) -#define EXFAT_INFO (1) -#define EXFAT_DEBUG (2) +#define EXFAT_ERROR (1) +#define EXFAT_INFO (2) +#define EXFAT_DEBUG (3) #define exfat_msg(level, fmt, ...) \ do { \ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/exfatprogs-1.0.2/include/mkfs.h new/exfatprogs-1.0.3/include/mkfs.h --- old/exfatprogs-1.0.2/include/mkfs.h 2020-04-23 10:22:33.000000000 +0200 +++ new/exfatprogs-1.0.3/include/mkfs.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,34 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-or-later */ -/* - * Copyright (C) 2019 Namjae Jeon <[email protected]> - */ - -#ifndef _MKFS_H - -#define DEFAULT_CLUSTER_SIZE (1024*1024) -#define DEFAULT_SECTOR_SIZE (512) -#define MIN_NUM_SECTOR (2048) -#define EXFAT_MAX_CLUSTER_SIZE (32*1024*1024) - -struct exfat_mkfs_info { - unsigned int total_clu_cnt; - unsigned int used_clu_cnt; - unsigned int fat_byte_off; - unsigned int fat_byte_len; - unsigned int clu_byte_off; - unsigned int bitmap_byte_off; - unsigned int bitmap_byte_len; - unsigned int ut_byte_off; - unsigned int ut_start_clu; - unsigned int ut_clus_off; - unsigned int ut_byte_len; - unsigned int root_byte_off; - unsigned int root_byte_len; - unsigned int root_start_clu; -}; - -extern struct exfat_mkfs_info finfo; - -int exfat_create_upcase_table(struct exfat_blk_dev *bd); - -#endif /* !_MKFS_H */ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/exfatprogs-1.0.2/include/version.h new/exfatprogs-1.0.3/include/version.h --- old/exfatprogs-1.0.2/include/version.h 2020-04-23 10:22:33.000000000 +0200 +++ new/exfatprogs-1.0.3/include/version.h 2020-05-12 07:29:27.000000000 +0200 @@ -5,6 +5,6 @@ #ifndef _VERSION_H -#define EXFAT_PROGS_VERSION "1.0.2" +#define EXFAT_PROGS_VERSION "1.0.3" #endif /* !_VERSION_H */ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/exfatprogs-1.0.2/label/Android.bp new/exfatprogs-1.0.3/label/Android.bp --- old/exfatprogs-1.0.2/label/Android.bp 2020-04-23 10:22:33.000000000 +0200 +++ new/exfatprogs-1.0.3/label/Android.bp 1970-01-01 01:00:00.000000000 +0100 @@ -1,11 +0,0 @@ -// Copyright 2020 The Android Open Source Project - -cc_binary { - name: "label.exfat", - - srcs: [ - "label.c", - ], - defaults: ["exfatprogs-defaults"], - static_libs: ["libexfat"], -} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/exfatprogs-1.0.2/label/Makefile.am new/exfatprogs-1.0.3/label/Makefile.am --- old/exfatprogs-1.0.2/label/Makefile.am 2020-04-23 10:22:33.000000000 +0200 +++ new/exfatprogs-1.0.3/label/Makefile.am 1970-01-01 01:00:00.000000000 +0100 @@ -1,8 +0,0 @@ -AM_CFLAGS = -Wall -Werror -Wunused-parameter \ - -Wno-address-of-packed-member \ - -include $(top_srcdir)/config.h -I$(top_srcdir)/include -fno-common -label_exfat_LDADD = $(top_builddir)/lib/libexfat.la - -sbin_PROGRAMS = label.exfat - -label_exfat_SOURCES = label.c diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/exfatprogs-1.0.2/label/label.c new/exfatprogs-1.0.3/label/label.c --- old/exfatprogs-1.0.2/label/label.c 2020-04-23 10:22:33.000000000 +0200 +++ new/exfatprogs-1.0.3/label/label.c 1970-01-01 01:00:00.000000000 +0100 @@ -1,196 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later -/* - * Copyright (C) 2019 Namjae Jeon <[email protected]> - */ - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> -#include <getopt.h> -#include <errno.h> -#include <locale.h> - -#include "exfat_ondisk.h" -#include "libexfat.h" - -static void usage(void) -{ - fprintf(stderr, "Usage: label.exfat\n"); - fprintf(stderr, "\t-g | --get-label Get volume label\n"); - fprintf(stderr, "\t-s | --set-label Set volume label\n"); - fprintf(stderr, "\t-V | --version Show version\n"); - fprintf(stderr, "\t-v | --verbose Print debug\n"); - fprintf(stderr, "\t-h | --help Show help\n"); - - exit(EXIT_FAILURE); -} - -static struct option opts[] = { - {"get-label", no_argument, NULL, 'g' }, - {"set-label", required_argument, NULL, 's' }, - {"version", no_argument, NULL, 'V' }, - {"verbose", no_argument, NULL, 'v' }, - {"help", no_argument, NULL, 'h' }, - {"?", no_argument, NULL, '?' }, - {NULL, 0, NULL, 0 } -}; - -static off_t exfat_get_root_entry_offset(struct exfat_blk_dev *bd) -{ - struct pbr *bs; - int nbytes; - unsigned int cluster_size; - off_t root_clu_off; - - bs = (struct pbr *)malloc(sizeof(struct pbr)); - if (!bs) { - exfat_err("failed to allocate memory\n"); - return -ENOMEM; - } - - nbytes = exfat_read(bd->dev_fd, bs, sizeof(struct pbr), 0); - if (nbytes != sizeof(struct pbr)) { - exfat_err("boot sector read failed: %d\n", errno); - return -1; - } - - cluster_size = (1 << bs->bsx.sect_per_clus_bits) * bd->sector_size; - root_clu_off = le32_to_cpu(bs->bsx.clu_offset) * bd->sector_size + - le32_to_cpu(bs->bsx.root_cluster - EXFAT_REVERVED_CLUSTERS) - * cluster_size; - free(bs); - - exfat_debug("root cluster offset : %ld\n", root_clu_off); - return root_clu_off; -} - -static int exfat_get_volume_label(struct exfat_blk_dev *bd, off_t root_clu_off) -{ - struct exfat_dentry *vol_entry; - char volume_label[11]; - int nbytes; - - vol_entry = malloc(sizeof(struct exfat_dentry)); - if (!vol_entry) { - exfat_err("failed to allocate memory\n"); - return -ENOMEM; - } - - nbytes = exfat_read(bd->dev_fd, vol_entry, - sizeof(struct exfat_dentry), root_clu_off); - if (nbytes != sizeof(struct exfat_dentry)) { - exfat_err("volume entry read failed: %d\n", errno); - return -1; - } - - if (exfat_utf16_dec(vol_entry->vol_label, vol_entry->vol_char_cnt*2, - volume_label, sizeof(volume_label)) < 0) { - exfat_err("failed to decode volume label\n"); - return -1; - } - - exfat_info("label: %s\n", volume_label); - return 0; -} - -static int exfat_set_volume_label(struct exfat_blk_dev *bd, - char *label_input, off_t root_clu_off) -{ - struct exfat_dentry vol; - int nbytes; - __u16 volume_label[11]; - int volume_label_len; - - volume_label_len = exfat_utf16_enc(label_input, - volume_label, sizeof(volume_label)); - if (volume_label_len < 0) { - exfat_err("failed to encode volume label\n"); - return -1; - } - - vol.type = EXFAT_VOLUME; - memset(vol.vol_label, 0, 22); - memcpy(vol.vol_label, volume_label, volume_label_len); - vol.vol_char_cnt = volume_label_len/2; - - nbytes = exfat_write(bd->dev_fd, &vol, sizeof(struct exfat_dentry), - root_clu_off); - if (nbytes != sizeof(struct exfat_dentry)) { - exfat_err("volume entry write failed: %d\n", errno); - return -1; - } - fsync(bd->dev_fd); - - exfat_info("new label: %s\n", label_input); - return 0; -} - -#define EXFAT_GET_LABEL 0x1 -#define EXFAT_SET_LABEL 0x2 - -int main(int argc, char *argv[]) -{ - int c; - int ret = EXIT_FAILURE; - struct exfat_blk_dev bd; - struct exfat_user_input ui; - bool version_only = false; - int flags = 0; - char label_input[11]; - off_t root_clu_off; - - init_user_input(&ui); - - if (!setlocale(LC_CTYPE, "")) - exfat_err("failed to init locale/codeset\n"); - - opterr = 0; - while ((c = getopt_long(argc, argv, "s:gVvh", opts, NULL)) != EOF) - switch (c) { - case 'g': - flags = EXFAT_GET_LABEL; - break; - case 's': - snprintf(label_input, 11, "%s", optarg); - flags = EXFAT_SET_LABEL; - break; - case 'V': - version_only = true; - break; - case 'v': - print_level = EXFAT_DEBUG; - break; - case '?': - case 'h': - default: - usage(); - } - - show_version(); - if (version_only) - exit(EXIT_FAILURE); - - if (argc - optind != 1) { - usage(); - } - - memset(ui.dev_name, 0, sizeof(ui.dev_name)); - snprintf(ui.dev_name, sizeof(ui.dev_name), "%s", argv[optind]); - - ret = exfat_get_blk_dev_info(&ui, &bd); - if (ret < 0) - goto out; - - root_clu_off = exfat_get_root_entry_offset(&bd); - if (root_clu_off < 0) - goto out; - - if (flags == EXFAT_GET_LABEL) - ret = exfat_get_volume_label(&bd, root_clu_off); - else if (flags == EXFAT_SET_LABEL) - ret = exfat_set_volume_label(&bd, label_input, root_clu_off); - -out: - return ret; -} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/exfatprogs-1.0.2/lib/Makefile.am new/exfatprogs-1.0.3/lib/Makefile.am --- old/exfatprogs-1.0.2/lib/Makefile.am 2020-04-23 10:22:33.000000000 +0200 +++ new/exfatprogs-1.0.3/lib/Makefile.am 2020-05-12 07:29:27.000000000 +0200 @@ -1,7 +1,4 @@ -AM_CFLAGS = -Wall -Werror -Wunused-parameter \ - -Wno-address-of-packed-member \ - -include $(top_srcdir)/config.h -I$(top_srcdir)/include -fno-common -LIBS = -lc -lib_LTLIBRARIES = libexfat.la +AM_CFLAGS = -Wall -include $(top_builddir)/config.h -I$(top_srcdir)/include -fno-common +noinst_LIBRARIES = libexfat.a -libexfat_la_SOURCES = libexfat.c +libexfat_a_SOURCES = libexfat.c diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/exfatprogs-1.0.2/lib/libexfat.c new/exfatprogs-1.0.3/lib/libexfat.c --- old/exfatprogs-1.0.2/lib/libexfat.c 2020-04-23 10:22:33.000000000 +0200 +++ new/exfatprogs-1.0.3/lib/libexfat.c 2020-05-12 07:29:27.000000000 +0200 @@ -17,7 +17,6 @@ #include "exfat_ondisk.h" #include "libexfat.h" -#include "mkfs.h" #include "version.h" #ifdef WORDS_BIGENDIAN @@ -146,10 +145,10 @@ int fd, ret = -1; off_t blk_dev_size; - fd = open(ui->dev_name, ui->writeable ? O_RDWR : O_RDONLY); + fd = open(ui->dev_name, ui->writeable ? O_RDWR|O_EXCL : O_RDONLY); if (fd < 0) { - exfat_err("open failed : %s, errno : %d\n", ui->dev_name, - errno); + exfat_err("open failed : %s, %s\n", ui->dev_name, + strerror(errno)); return -1; } blk_dev_size = lseek(fd, 0, SEEK_END); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/exfatprogs-1.0.2/manpages/fsck.exfat.8 new/exfatprogs-1.0.3/manpages/fsck.exfat.8 --- old/exfatprogs-1.0.2/manpages/fsck.exfat.8 1970-01-01 01:00:00.000000000 +0100 +++ new/exfatprogs-1.0.3/manpages/fsck.exfat.8 2020-05-12 07:29:27.000000000 +0200 @@ -0,0 +1,44 @@ +.TH fsck.exfat 8 +.SH NAME +fsck.exfat \- check an exFAT filesystem +.SH SYNOPSIS +.B fsck.exfat +[ +.B \-n +] [ +.B \-r +] [ +.B \-v +] [ +.B \-y +] [ +.B \-v +] +.I device +.br +.B fsck.exfat \-V +.SH DESCRIPTION +.B fsck.exfat +checks an exFAT filesystem and repairs the filesytem +depending on the options passed. +.PP +.SH OPTIONS +.TP +.BI \-n +Check the filesystem but do not attempt to repair the filesystem. +.TP +.BI \-r +Repair the filesystem interactively. +.TP +.BI \-v +Prints verbose debugging information while checking the exFAT filesystem. +.TP +.BI \-V +Prints the version number and exits. +.TP +.B \-y +Repair the filesystem answering yes to all questions. +.TP +.SH SEE ALSO +.BR fsck (8), +.BR fstab (5), diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/exfatprogs-1.0.2/manpages/mkfs.exfat.8 new/exfatprogs-1.0.3/manpages/mkfs.exfat.8 --- old/exfatprogs-1.0.2/manpages/mkfs.exfat.8 1970-01-01 01:00:00.000000000 +0100 +++ new/exfatprogs-1.0.3/manpages/mkfs.exfat.8 2020-05-12 07:29:27.000000000 +0200 @@ -0,0 +1,60 @@ +.TH mkfs.exfat 8 +.SH NAME +mkfs.exfat \- create an exFAT filesystem +.SH SYNOPSIS +.B mkfs.exfat +[ +.B \-c +.I cluster_size +] [ +.B \-f +] [ +.B \-h +] [ +.B \-L +.I volume_label +] [ +.B \-v +] +.I device +.br +.B mkfs.exfat \-V +.SH DESCRIPTION +.B mkfs.exfat +creates an exFAT filesystem by writing on a special +file using the values found in the arguments of the command line. +It is invoked automatically by +.BR mkfs (8) +when it is given the +.B \-t exfat +option. +.PP +As an example, to make a filesystem on the first partition on the first +SCSI disk, use: +.IP +.B mkfs.exfat /dev/sda1 +.PP +.SH OPTIONS +.TP +.BI \-c " cluster_size" +Specify the cluster size. Cluster size can be specified in m/M for megabytes +and k/K for kilobytes. +.TP +.BI \-f +Performs a full format. This zeros the entire disk device while +creating the exFAT filesystem. +.TP +.BI \-h +Prints the help and exit. +.TP +.BI \-L " volume_label" +Specifies the volume label associated with the exFAT filesystem. +.TP +.BI \-v +Prints verbose debugging information while creating the exFAT filesystem. +.TP +.B \-V +Prints the version number and exits. +.SH SEE ALSO +.BR mkfs (8), +.BR mount (8), diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/exfatprogs-1.0.2/manpages/tune.exfat.8 new/exfatprogs-1.0.3/manpages/tune.exfat.8 --- old/exfatprogs-1.0.2/manpages/tune.exfat.8 1970-01-01 01:00:00.000000000 +0100 +++ new/exfatprogs-1.0.3/manpages/tune.exfat.8 2020-05-12 07:29:27.000000000 +0200 @@ -0,0 +1,34 @@ +.TH tune.exfat 8 +.SH NAME +tune.exfat \- adjust tunable filesystem parameters on an exFAT filesystem +.SH SYNOPSIS +.B tune.exfat +[ +.B \-l +] [ +.B \-L volume_label +.I volume_label +] [ +.B \-v +] +.I device +.br +.B tune.exfat \-V +.SH DESCRIPTION +.B tune.exfat +adjust tunable ondisk parameters of an existing exFAT filesystem. +.PP +.SH OPTIONS +.TP +.BI \-l +Print the volume label of the exFAT filesystem. +.TP +.BI \-L" volume_label" +Set the volume label of the filesystem to the provided argument. +.TP +.BI \-v +Prints verbose debugging information while extracting or tuning parameters of the exFAT filesystem. +.TP +.B \-V +Prints the version number and exits. +.TP diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/exfatprogs-1.0.2/mkfs/Makefile.am new/exfatprogs-1.0.3/mkfs/Makefile.am --- old/exfatprogs-1.0.2/mkfs/Makefile.am 2020-04-23 10:22:33.000000000 +0200 +++ new/exfatprogs-1.0.3/mkfs/Makefile.am 2020-05-12 07:29:27.000000000 +0200 @@ -1,9 +1,7 @@ -AM_CFLAGS = -Wall -Werror -Wunused-parameter \ - -Wno-address-of-packed-member \ - -include $(top_srcdir)/config.h -I$(top_srcdir)/include -fno-common +AM_CFLAGS = -Wall -include $(top_builddir)/config.h -I$(top_srcdir)/include -fno-common LIBS = -lm -mkfs_exfat_LDADD = $(top_builddir)/lib/libexfat.la +mkfs_exfat_LDADD = $(top_builddir)/lib/libexfat.a sbin_PROGRAMS = mkfs.exfat -mkfs_exfat_SOURCES = mkfs.c upcase.c +mkfs_exfat_SOURCES = mkfs.c upcase.c mkfs.h diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/exfatprogs-1.0.2/mkfs/mkfs.c new/exfatprogs-1.0.3/mkfs/mkfs.c --- old/exfatprogs-1.0.2/mkfs/mkfs.c 2020-04-23 10:22:33.000000000 +0200 +++ new/exfatprogs-1.0.3/mkfs/mkfs.c 2020-05-12 07:29:27.000000000 +0200 @@ -13,6 +13,7 @@ #include <sys/ioctl.h> #include <fcntl.h> #include <getopt.h> +#include <inttypes.h> #include <errno.h> #include <math.h> #include <locale.h> @@ -57,7 +58,7 @@ memset(ppbr->boot_code, 0, 390); ppbr->signature = cpu_to_le16(PBR_SIGNATURE); - exfat_debug("Volume Length(sectors) : %llu\n", + exfat_debug("Volume Length(sectors) : %" PRIu64 "\n", le64_to_cpu(pbsx->vol_length)); exfat_debug("FAT Offset(sector offset) : %u\n", le32_to_cpu(pbsx->fat_offset)); @@ -83,7 +84,7 @@ lseek(bd->dev_fd, offset, SEEK_SET); bytes = write(bd->dev_fd, buf, bd->sector_size); - if (bytes != bd->sector_size) { + if (bytes != (int)bd->sector_size) { exfat_err("write failed, sec_off : %u, bytes : %d\n", sec_off, bytes); return -1; @@ -198,7 +199,8 @@ unsigned int checksum, bool is_backup) { __le32 *checksum_buf; - int i, ret = 0; + int ret = 0; + unsigned int i; unsigned int sec_idx = CHECKSUM_SEC_IDX; checksum_buf = malloc(bd->sector_size); @@ -322,9 +324,9 @@ static int exfat_create_bitmap(struct exfat_blk_dev *bd) { char *bitmap; - int i, nbytes; + unsigned int i, nbytes; - bitmap = malloc(finfo.bitmap_byte_len); + bitmap = calloc(finfo.bitmap_byte_len, sizeof(*bitmap)); if (!bitmap) return -1; @@ -336,9 +338,11 @@ if (nbytes != finfo.bitmap_byte_len) { exfat_err("write failed, nbytes : %d, bitmap_len : %d\n", nbytes, finfo.bitmap_byte_len); + free(bitmap); return -1; } + free(bitmap); return 0; } @@ -381,18 +385,18 @@ static void usage(void) { fprintf(stderr, "Usage: mkfs.exfat\n"); - fprintf(stderr, "\t-l string | --volume-label=string Set volume label\n"); - fprintf(stderr, "\t-c | --cluster-size Set cluster size\n"); - fprintf(stderr, "\t-f | --full-format Full format\n"); - fprintf(stderr, "\t-V | --version Show version\n"); - fprintf(stderr, "\t-v | --verbose Print debug\n"); - fprintf(stderr, "\t-h | --help Show help\n"); + fprintf(stderr, "\t-L | --volume-label=label Set volume label\n"); + fprintf(stderr, "\t-c | --cluster-size=size(or suffixed by 'K' or 'M') Specify cluster size\n"); + fprintf(stderr, "\t-f | --full-format Full format\n"); + fprintf(stderr, "\t-V | --version Show version\n"); + fprintf(stderr, "\t-v | --verbose Print debug\n"); + fprintf(stderr, "\t-h | --help Show help\n"); exit(EXIT_FAILURE); } static struct option opts[] = { - {"volume-label", required_argument, NULL, 'l' }, + {"volume-label", required_argument, NULL, 'L' }, {"cluster-size", required_argument, NULL, 'c' }, {"full-format", no_argument, NULL, 'f' }, {"version", no_argument, NULL, 'V' }, @@ -529,7 +533,8 @@ switch (*data_unit) { case 'M': case 'm': - byte_size <<= 10; + byte_size <<= 20; + break; case 'K': case 'k': byte_size <<= 10; @@ -557,14 +562,14 @@ exfat_err("failed to init locale/codeset\n"); opterr = 0; - while ((c = getopt_long(argc, argv, "n:l:c:fVvh", opts, NULL)) != EOF) + while ((c = getopt_long(argc, argv, "n:L:c:fVvh", opts, NULL)) != EOF) switch (c) { /* - * Make 'n' option fallthrough to 'l' option for for backward + * Make 'n' option fallthrough to 'L' option for for backward * compatibility with old utils. */ case 'n': - case 'l': + case 'L': { ret = exfat_utf16_enc(optarg, ui.volume_label, sizeof(ui.volume_label)); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/exfatprogs-1.0.2/mkfs/mkfs.h new/exfatprogs-1.0.3/mkfs/mkfs.h --- old/exfatprogs-1.0.2/mkfs/mkfs.h 1970-01-01 01:00:00.000000000 +0100 +++ new/exfatprogs-1.0.3/mkfs/mkfs.h 2020-05-12 07:29:27.000000000 +0200 @@ -0,0 +1,33 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Copyright (C) 2019 Namjae Jeon <[email protected]> + */ + +#ifndef _MKFS_H + +#define DEFAULT_CLUSTER_SIZE (1024*1024) +#define MIN_NUM_SECTOR (2048) +#define EXFAT_MAX_CLUSTER_SIZE (32*1024*1024) + +struct exfat_mkfs_info { + unsigned int total_clu_cnt; + unsigned int used_clu_cnt; + unsigned int fat_byte_off; + unsigned int fat_byte_len; + unsigned int clu_byte_off; + unsigned int bitmap_byte_off; + unsigned int bitmap_byte_len; + unsigned int ut_byte_off; + unsigned int ut_start_clu; + unsigned int ut_clus_off; + unsigned int ut_byte_len; + unsigned int root_byte_off; + unsigned int root_byte_len; + unsigned int root_start_clu; +}; + +extern struct exfat_mkfs_info finfo; + +int exfat_create_upcase_table(struct exfat_blk_dev *bd); + +#endif /* !_MKFS_H */ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/exfatprogs-1.0.2/tune/Android.bp new/exfatprogs-1.0.3/tune/Android.bp --- old/exfatprogs-1.0.2/tune/Android.bp 1970-01-01 01:00:00.000000000 +0100 +++ new/exfatprogs-1.0.3/tune/Android.bp 2020-05-12 07:29:27.000000000 +0200 @@ -0,0 +1,11 @@ +// Copyright 2020 The Android Open Source Project + +cc_binary { + name: "tune.exfat", + + srcs: [ + "tune.c", + ], + defaults: ["exfatprogs-defaults"], + static_libs: ["libexfat"], +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/exfatprogs-1.0.2/tune/Makefile.am new/exfatprogs-1.0.3/tune/Makefile.am --- old/exfatprogs-1.0.2/tune/Makefile.am 1970-01-01 01:00:00.000000000 +0100 +++ new/exfatprogs-1.0.3/tune/Makefile.am 2020-05-12 07:29:27.000000000 +0200 @@ -0,0 +1,6 @@ +AM_CFLAGS = -Wall -include $(top_builddir)/config.h -I$(top_srcdir)/include -fno-common +tune_exfat_LDADD = $(top_builddir)/lib/libexfat.a + +sbin_PROGRAMS = tune.exfat + +tune_exfat_SOURCES = tune.c diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/exfatprogs-1.0.2/tune/tune.c new/exfatprogs-1.0.3/tune/tune.c --- old/exfatprogs-1.0.2/tune/tune.c 1970-01-01 01:00:00.000000000 +0100 +++ new/exfatprogs-1.0.3/tune/tune.c 2020-05-12 07:29:27.000000000 +0200 @@ -0,0 +1,198 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (C) 2019 Namjae Jeon <[email protected]> + */ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include <getopt.h> +#include <errno.h> +#include <locale.h> + +#include "exfat_ondisk.h" +#include "libexfat.h" + +static void usage(void) +{ + fprintf(stderr, "Usage: tune.exfat\n"); + fprintf(stderr, "\t-l | --print-label Print volume label\n"); + fprintf(stderr, "\t-L | --volume-label=label Set volume label\n"); + fprintf(stderr, "\t-V | --version Show version\n"); + fprintf(stderr, "\t-v | --verbose Print debug\n"); + fprintf(stderr, "\t-h | --help Show help\n"); + + exit(EXIT_FAILURE); +} + +static struct option opts[] = { + {"print-label", no_argument, NULL, 'l' }, + {"set-label", required_argument, NULL, 'L' }, + {"version", no_argument, NULL, 'V' }, + {"verbose", no_argument, NULL, 'v' }, + {"help", no_argument, NULL, 'h' }, + {"?", no_argument, NULL, '?' }, + {NULL, 0, NULL, 0 } +}; + +static off_t exfat_get_root_entry_offset(struct exfat_blk_dev *bd) +{ + struct pbr *bs; + int nbytes; + unsigned int cluster_size; + off_t root_clu_off; + + bs = (struct pbr *)malloc(sizeof(struct pbr)); + if (!bs) { + exfat_err("failed to allocate memory\n"); + return -ENOMEM; + } + + nbytes = exfat_read(bd->dev_fd, bs, sizeof(struct pbr), 0); + if (nbytes != sizeof(struct pbr)) { + exfat_err("boot sector read failed: %d\n", errno); + return -1; + } + + cluster_size = (1 << bs->bsx.sect_per_clus_bits) * bd->sector_size; + root_clu_off = le32_to_cpu(bs->bsx.clu_offset) * bd->sector_size + + le32_to_cpu(bs->bsx.root_cluster - EXFAT_REVERVED_CLUSTERS) + * cluster_size; + free(bs); + + return root_clu_off; +} + +static int exfat_get_volume_label(struct exfat_blk_dev *bd, off_t root_clu_off) +{ + struct exfat_dentry *vol_entry; + char volume_label[VOLUME_LABEL_BUFFER_SIZE]; + __le16 disk_label[VOLUME_LABEL_MAX_LEN]; + int nbytes; + + vol_entry = malloc(sizeof(struct exfat_dentry)); + if (!vol_entry) { + exfat_err("failed to allocate memory\n"); + return -ENOMEM; + } + + nbytes = exfat_read(bd->dev_fd, vol_entry, + sizeof(struct exfat_dentry), root_clu_off); + if (nbytes != sizeof(struct exfat_dentry)) { + exfat_err("volume entry read failed: %d\n", errno); + return -1; + } + + memcpy(disk_label, vol_entry->vol_label, sizeof(disk_label)); + memset(volume_label, 0, sizeof(volume_label)); + if (exfat_utf16_dec(disk_label, vol_entry->vol_char_cnt*2, + volume_label, sizeof(volume_label)) < 0) { + exfat_err("failed to decode volume label\n"); + return -1; + } + + exfat_info("label: %s\n", volume_label); + return 0; +} + +static int exfat_set_volume_label(struct exfat_blk_dev *bd, + char *label_input, off_t root_clu_off) +{ + struct exfat_dentry vol; + int nbytes; + __u16 volume_label[VOLUME_LABEL_MAX_LEN]; + int volume_label_len; + + volume_label_len = exfat_utf16_enc(label_input, + volume_label, sizeof(volume_label)); + if (volume_label_len < 0) { + exfat_err("failed to encode volume label\n"); + return -1; + } + + vol.type = EXFAT_VOLUME; + memset(vol.vol_label, 0, sizeof(vol.vol_label)); + memcpy(vol.vol_label, volume_label, volume_label_len); + vol.vol_char_cnt = volume_label_len/2; + + nbytes = exfat_write(bd->dev_fd, &vol, sizeof(struct exfat_dentry), + root_clu_off); + if (nbytes != sizeof(struct exfat_dentry)) { + exfat_err("volume entry write failed: %d\n", errno); + return -1; + } + fsync(bd->dev_fd); + + exfat_info("new label: %s\n", label_input); + return 0; +} + +#define EXFAT_GET_LABEL 0x1 +#define EXFAT_SET_LABEL 0x2 + +int main(int argc, char *argv[]) +{ + int c; + int ret = EXIT_FAILURE; + struct exfat_blk_dev bd; + struct exfat_user_input ui; + bool version_only = false; + int flags = 0; + char label_input[VOLUME_LABEL_BUFFER_SIZE]; + off_t root_clu_off; + + init_user_input(&ui); + + if (!setlocale(LC_CTYPE, "")) + exfat_err("failed to init locale/codeset\n"); + + opterr = 0; + while ((c = getopt_long(argc, argv, "L:lVvh", opts, NULL)) != EOF) + switch (c) { + case 'l': + flags = EXFAT_GET_LABEL; + break; + case 'L': + snprintf(label_input, sizeof(label_input), "%s", + optarg); + flags = EXFAT_SET_LABEL; + break; + case 'V': + version_only = true; + break; + case 'v': + print_level = EXFAT_DEBUG; + break; + case '?': + case 'h': + default: + usage(); + } + + show_version(); + if (version_only) + exit(EXIT_FAILURE); + + if (argc < 3) + usage(); + + memset(ui.dev_name, 0, sizeof(ui.dev_name)); + snprintf(ui.dev_name, sizeof(ui.dev_name), "%s", argv[argc - 1]); + + ret = exfat_get_blk_dev_info(&ui, &bd); + if (ret < 0) + goto out; + + root_clu_off = exfat_get_root_entry_offset(&bd); + if (root_clu_off < 0) + goto out; + + if (flags == EXFAT_GET_LABEL) + ret = exfat_get_volume_label(&bd, root_clu_off); + else if (flags == EXFAT_SET_LABEL) + ret = exfat_set_volume_label(&bd, label_input, root_clu_off); + +out: + return ret; +}
