fatsort-1.3.365/0000775000175000017500000000000012321036745012666 5ustar feanorfeanorfatsort-1.3.365/LICENSE.txt0000664000175000017500000004325412321036666014523 0ustar feanorfeanor GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Lesser General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. fatsort-1.3.365/README0000664000175000017500000000005612321036670013544 0ustar feanorfeanorPlease have a look at man page man/fatsort.1. fatsort-1.3.365/Makefile0000664000175000017500000000067012321036670014326 0ustar feanorfeanorMANDIR=/usr/local/share/man/man1 INSTALL_FLAGS=-m 0755 -p -D #detect Mac OS X UNAME=$(shell uname -s) ifeq ($(UNAME),Darwin) INSTALL_FLAGS=-m 0755 -p endif all: man src: $(MAKE) -C src/ man: src $(MAKE) -C man/ clean: $(MAKE) -C src/ clean ${MAKE} -C tests/ clean install: install $(INSTALL_FLAGS) man/fatsort.1 $(DESTDIR)$(MANDIR)/fatsort.1 $(MAKE) -C src/ install tests: all $(MAKE) -C tests/ .PHONY: src man tests clean fatsort-1.3.365/CHANGES0000664000175000017500000001155712321036670013667 0ustar feanorfeanor02/28/2014 v1.3 * added option -a for ASCIIbetical sorting * added test cases for option -a 07/12/2013 v1.2 * fatsort now sychronizes filesystems after sorting each directory * added long options --version and --help * updated version and help output for help2man * added Makefile for manpage * minor changes 06/09/2013 v1.1.1 * fixed character conversion for non-UTF-8 systems 05/23/2013 v1.1 * New option -t to sort by last modification date time. Thanks to Charles Anthony for the patch. * More and updated tests * Minor changes 05/17/2013 v1.0.1 * FIX: big endian issue for FAT12/16 in function getFATEntry * FIX: big endian issue for BS_SecPerClus * FIX: Stack overflow in cmpentries * FIX: checkLongDirEntries now ignores deleted entries * added check for maximum clusters according to MS Q184006 * considered -Wextra warnings * make fatsort detect cluster chain loops * implemented regression tests * updated fatsort help information * Option combination -l and -m now also print long AND short file names * changed DE_FREE to u_char * additional cluster size check * Optimized calculation of file system information * Minor changes and code cleaning 03/11/2013 v1.0 * FIX: exit critical sections on error * FIX: Natural order sorting works again (without collation ordering though) * ENHANCEMENT: Added support for FAT12 * Added checks for broken clusterchains * Added cluster usage information for option -i * Checksums for LongDirEntries are now verified * Added integrity check that verifies whether all FATs are the same 04/04/2012 v0.9.17 * Collation ordering for the current locale is now considered during sorting * Fixed some random bugs found with a static code analysis tools 12/07/2011 v0.9.16 * Updated address in GPL license 08/15/2011 v0.9.15 * Multiple directories can now be included and excluded for sorting using options -d, -D, -x, and -X. Thanks to Renaud Métrich for the idea. * Added option -I which allows to ignore filename prefixes during sorting. Thanks to Matthew Altus for the idea. * Added support for memory leak detection in debug modes 2-4 * Fixed a bug in function randomizeDirEntryList. Thanks to Renaud Métrich for reporting the bug. * Updated Makefiles for better Max OS X support. Thanks to Tom Freiberger for the Makefiles. * Minor change to remove a compiler warning in FAT_fs.c. * Minor change to remove a redundant option check. 06/11/2010 v0.9.14.1 * Check for last directory entry in FAT_fs.c was fixed. thanks to Peter De Wachter for the hint. 14/05/2010 v0.9.14 * Included a patch for an iconv issue under Mac and FreeBSD. Thanks to Max Campos. 28/12/2009 v0.9.13.1 * Fixed a pointer initialization in insertLongDirEntryList 23/12/2009 v0.9.13 * Added random order sorting (option -R) * Updated manpage * manpage is now installed via make install 29/09/2009 v0.9.12 * locale is now set to locale of environment 27/09/2009 v0.9.11 * segmentation fault in parseClusterChain fixed * LFNs are now correctly converted from UTF-16 to UTF-8 12/05/2008 v0.9.10 * Options -d and -D added * natural order comparison algorithm reimplemented 12/02/2008 v0.9.9.1 * Small Makefile update 11/28/2008 v0.9.9 * Martin Pool's natural order comparison algorithm is now included into FATSort * Makefile patches 07/08/2008 v0.9.8.3 * bug in check_mounted fixed 06/11/2008 v0.9.8.2 * minor fixes in header files and make files * modified README 06/10/2008 v0.9.8.1 * some minor fixes. Thanks to Till Maas. 09/25/2007 v0.9.8 * splitted fatsort into several source files * implemented exclusive file lock (not mandatory) * signals are blocked while writing to file (implemented critial sections) * sorting of special directory entries (".", ".." and volume label) is now prevented * enhanced mount check feature * -f option to force sorting introduced * small updates * thanks to Joe Forster/STA for some fixes 04/30/2007 v0.9.7.1 * support for files >4GB * thanks to Sebastian Biallas for the patch 02/01/2007 v0.9.7 * fatsort now checks if device is mounted (only BSD and linux) * thanks to Sebastian Dröge for the patch 01/08/2006 v0.9.6.2 * added option for sorting in reverse order * fixed some memory leaks * thanks to Giorgio Moscardi for both patches 07/01/2006 v0.9.6.1 * removed unused variables, minor changes 06/26/2006 v0.9.6 * big-endian support added * getopt fix for PPC * cluster chains are dynamic structures now * small fixes * error handling in FSInfo 05/27/2006 v0.9.5 * fixed volume label bug * tidied up some code * added function assertions * added error handlings * changed error messages 09/09/2005 v0.9.4 * fixed integer issues, included stdlib.h 01/13/2005 v0.9.3 * fixed some data types because of bugs on opteron systems 01/13/2005 v0.9.2 * fixed some bugs * FATSort is now put under GPL 02/06/2004 v0.9.1 * major bug concerning FAT specification fixed fatsort-1.3.365/man/0000775000175000017500000000000012321036670013436 5ustar feanorfeanorfatsort-1.3.365/man/Makefile0000664000175000017500000000020312321036670015071 0ustar feanorfeanorHELP2MAN=help2man all: fatsort.1 fatsort.1: ../src/fatsort ${HELP2MAN} --name "FAT sorting tool" ../src/fatsort -o fatsort.1 -N fatsort-1.3.365/src/0000775000175000017500000000000012321036670013452 5ustar feanorfeanorfatsort-1.3.365/src/errors.c0000664000175000017500000000233612321036670015136 0ustar feanorfeanor/* FATSort, utility for sorting FAT directory structures Copyright (C) 2004 Boris Leidner This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /* This file contains/describes functions for error handling and messaging. */ #include #include #include "errors.h" #include "mallocv.h" void errormsg(const char *func, const char *str, ...) { /* error messages with function name and argument list */ char msg[129]; va_list argptr; va_start(argptr,str); vsnprintf(msg, 128, str, argptr); fprintf(stderr, "%s: %s\n", func, msg); va_end(argptr); } fatsort-1.3.365/src/natstrcmp.h0000664000175000017500000000222612321036670015640 0ustar feanorfeanor/* FATSort, utility for sorting FAT directory structures Copyright (C) 2008 Boris Leidner This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /* This file contains/describes functions for natural order sorting. */ #ifndef __natstrcmp_h__ #define __natstrcmp_h__ #include // natural order comparison int32_t natstrcmp(const char *str1, const char *str2); // natural order comparison ignoring case int32_t natstrcasecmp(const char *str1, const char *str2); #endif // __natstrcmp_h__ fatsort-1.3.365/src/signal.c0000664000175000017500000000256612321036670015104 0ustar feanorfeanor/* FATSort, utility for sorting FAT directory structures Copyright (C) 2004 Boris Leidner This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /* This file contains/describes function for signal handling. */ #include "signal.h" #include #include #include "mallocv.h" sigset_t blocked_signals_set; void init_signal_handling(void) { /* initialize signal handling for critical sections */ sigfillset(&blocked_signals_set); } void start_critical_section(void) { /* blocks signals for critical section */ sigprocmask(SIG_BLOCK, &blocked_signals_set, NULL); } void end_critical_section(void) { /* unblocks signals after critical section */ sigprocmask(SIG_UNBLOCK, &blocked_signals_set, NULL); } fatsort-1.3.365/src/mallocv.c0000664000175000017500000000737512321036670015267 0ustar feanorfeanor/* FATSort, utility for sorting FAT directory structures Copyright (C) 2004 Boris Leidner This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /* This file contains/describes debug versions for malloc and free */ #include #include #include #include "mallocv.h" #include "errors.h" #undef malloc #undef realloc #undef free int64_t mem_used=0; struct sList { void *ptr; size_t size; char*file; u_int32_t line; struct sList *next; }; struct sList list={0}; void add(struct sList *list, void *ptr, size_t size, char *filename, u_int32_t line) { assert(list != NULL); assert(ptr != NULL); while(list->next != NULL) { list = list->next; } list->next = malloc(sizeof(struct sList)); if (list->next == NULL) { stderror(); exit(1); } list->next->ptr=ptr; list->next->size=size; size_t flen=strlen(filename); list->next->file=malloc(flen+1); if (list->next->file == NULL) { stderror(); exit(1); } strncpy(list->next->file, filename, flen); list->next->file[flen] = '\0'; list->next->line=line; list->next->next=NULL; } size_t del(struct sList *list, void *ptr) { assert(list != NULL); assert(ptr != NULL); size_t size; struct sList *tmp; while(list->next != NULL) { if (list->next->ptr == ptr) { size=list->next->size; //free(list->next->ptr); free(list->next->file); tmp=list->next->next; free(list->next); list->next=tmp; return size; } list=list->next; } return 0; } void *mallocv(char *filename, u_int32_t line, size_t size) { void* ptr = malloc(size); if (size && (ptr == NULL)) { stderror(); exit(1); } add(&list, ptr, size, filename, line); mem_used += size; #if DEBUG >= 3 myerror("%d bytes allocated in %s:%u, ptr=%x (total memory %d)!", size, filename, line, ptr, mem_used); #endif return ptr; } void *reallocv(char *filename, u_int32_t line, void *ptr, size_t size) { size_t delSize=0; if (ptr) { delSize=del(&list, ptr); if (!delSize) { #if DEBUG >= 4 myerror("No memory allocated for ptr %x freed (realloc) at %s:%u!", ptr, filename, line); #endif } mem_used -= delSize; } void* newPtr = realloc(ptr, size); if (size && (newPtr == NULL)) { stderror(); exit(1); } if (newPtr) add(&list, newPtr, size, filename, line); mem_used += size; #if DEBUG >= 3 myerror("%d bytes reallocated in %s:%u, old ptr=%x, new ptr=%x (total memory %d)!", size-delSize, filename, line, ptr, newPtr, mem_used); #endif return newPtr; } void freev(char *filename, u_int32_t line, void *ptr) { size_t size=del(&list, ptr); if (size) { mem_used-=size; free(ptr); #if DEBUG >= 3 myerror("%d bytes freed in %s:%u (total memory %d)!", size, filename, line, mem_used); #endif } else { #if DEBUG >= 4 myerror("No memory allocated for ptr %x freed at %s:%u!", ptr, filename, line); #endif } } void reportLeaks() { struct sList *tmp=&list; while(tmp->next != NULL) { myerror("%d bytes allocated for ptr %x at %s:%u were not freed!", tmp->next->size, tmp->next->ptr, tmp->next->file, tmp->next->line); tmp = tmp->next; } myerror("Total bytes not freed: %d", mem_used); } fatsort-1.3.365/src/FAT_fs.h0000664000175000017500000001744412321036670014737 0ustar feanorfeanor/* FATDefrag, utility for defragmentation of FAT file systems Copyright (C) 2013 Boris Leidner This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /* This file contains/describes functions that are used to read, write, check, and use FAT filesystems. */ #ifndef __FAT_fs_h__ #define __FAT_fs_h__ // FS open mode bits #define FS_MODE_RO 1 #define FS_MODE_RO_EXCL 2 #define FS_MODE_RW 3 #define FS_MODE_RW_EXCL 4 // FAT types #define FATTYPE_FAT12 12 #define FATTYPE_FAT16 16 #define FATTYPE_FAT32 32 // file attributes #define ATTR_READ_ONLY 0x01 #define ATTR_HIDDEN 0x02 #define ATTR_SYSTEM 0x04 #define ATTR_VOLUME_ID 0x08 #define ATTR_DIRECTORY 0x10 #define ATTR_ARCHIVE 0x20 #define ATTR_LONG_NAME (ATTR_READ_ONLY | ATTR_HIDDEN | ATTR_SYSTEM | ATTR_VOLUME_ID) #define ATTR_LONG_NAME_MASK (ATTR_READ_ONLY | ATTR_HIDDEN | ATTR_SYSTEM | ATTR_VOLUME_ID | ATTR_DIRECTORY | ATTR_ARCHIVE) // constants for the LDIR structure #define DE_FREE 0xe5 #define DE_FOLLOWING_FREE 0x00 #define LAST_LONG_ENTRY 0x40 #define DIR_ENTRY_SIZE 32 // maximum path len on FAT file systems (above specification) #define MAX_PATH_LEN 512 // maximum file len // (specification: file < 4GB which is // maximum clusters in chain * cluster size) #define MAX_FILE_LEN 0xFFFFFFFF #define MAX_DIR_ENTRIES 65536 #include #include #include #include "platform.h" // Directory entry structures // Structure for long directory names struct sLongDirEntry { u_char LDIR_Ord; // Order of entry in sequence char LDIR_Name1[10]; // Chars 1-5 of long name u_char LDIR_Attr; // Attributes (ATTR_LONG_NAME must be set) u_char LDIR_Type; // Type u_char LDIR_Checksum; // Short name checksum char LDIR_Name2[12]; // Chars 6-11 of long name u_int16_t LDIR_FstClusLO; // Zero char LDIR_Name3[4]; // Chars 12-13 of long name } __attribute__((packed)); // Structure for old short directory names struct sShortDirEntry { char DIR_Name[11]; // Short name u_char DIR_Atrr; // File attributes u_char DIR_NTRes; // Reserved for NT u_char DIR_CrtTimeTenth; // Time of creation in ms u_int16_t DIR_CrtTime; // Time of creation u_int16_t DIR_CrtDate; // Date of creation u_int16_t DIR_LstAccDate; // Last access date u_int16_t DIR_FstClusHI; // Hiword of first cluster u_int16_t DIR_WrtTime; // Time of last write u_int16_t DIR_WrtDate; // Date of last write u_int16_t DIR_FstClusLO; // Loword of first cluster u_int32_t DIR_FileSize; // file size in bytes } __attribute__((packed)); union sDirEntry { struct sShortDirEntry ShortDirEntry; struct sLongDirEntry LongDirEntry; } __attribute__((packed)); // Bootsector structures // FAT12 and FAT16 struct sFAT12_16 { u_char BS_DrvNum; // Physical drive number u_char BS_Reserved; // Current head u_char BS_BootSig; // Signature u_int32_t BS_VolID; // Volume ID char BS_VolLab[11]; // Volume Label char BS_FilSysType[8]; // FAT file system type (e.g. FAT, FAT12, FAT16, FAT32) u_char unused[448]; // unused space in bootsector } __attribute__((packed)); // FAT32 struct sFAT32 { u_int32_t BS_FATSz32; // Sectors per FAT u_int16_t BS_ExtFlags; // Flags u_int16_t BS_FSVer; // Version u_int32_t BS_RootClus; // Root Directory Cluster u_int16_t BS_FSInfo; // Sector of FSInfo structure u_int16_t BS_BkBootSec; // Sector number of the boot sector copy in reserved sectors char BS_Reserved[12]; // for future expansion char BS_DrvNum; // see fat12/16 char BS_Reserved1; // see fat12/16 char BS_BootSig; // ... u_int32_t BS_VolID; char BS_VolLab[11]; char BS_FilSysType[8]; u_char unused[420]; // unused space in bootsector } __attribute__((packed)); union sFATxx { struct sFAT12_16 FAT12_16; struct sFAT32 FAT32; } __attribute__((packed)); // First sector = boot sector struct sBootSector { u_char BS_JmpBoot[3]; // Jump instruction (to skip over header on boot) char BS_OEMName[8]; // OEM Name (padded with spaces) u_int16_t BS_BytesPerSec; // Bytes per sector u_char BS_SecPerClus; // Sectors per cluster u_int16_t BS_RsvdSecCnt; // Reserved sector count (including boot sector) u_char BS_NumFATs; // Number of file allocation tables u_int16_t BS_RootEntCnt; // Number of root directory entries u_int16_t BS_TotSec16; // Total sectors (bits 0-15) u_char BS_Media; // Media descriptor u_int16_t BS_FATSz16; // Sectors per file allocation table u_int16_t BS_SecPerTrk; // Sectors per track u_int16_t BS_NumHeads; // Number of heads u_int32_t BS_HiddSec; // Hidden sectors u_int32_t BS_TotSec32; // Total sectors (bits 16-47) union sFATxx FATxx; u_int16_t BS_EndOfBS; // marks end of bootsector } __attribute__((packed)); // FAT32 FSInfo structure struct sFSInfo { u_int32_t FSI_LeadSig; u_int8_t FSI_Reserved1[480]; u_int32_t FSI_StrucSig; u_int32_t FSI_Free_Count; u_int32_t FSI_Nxt_Free; u_int8_t FSI_Reserved2[12]; u_int32_t FSI_TrailSig; } __attribute__((packed)); // holds information about the file system struct sFileSystem { FILE *fd; int32_t rfd; u_int32_t mode; char path[MAX_PATH_LEN+1]; struct sBootSector bs; int32_t FATType; u_int32_t clusterCount; u_int16_t sectorSize; u_int32_t totalSectors; u_int32_t clusterSize; int32_t clusters; u_int32_t FATSize; u_int64_t FSSize; u_int32_t maxDirEntriesPerCluster; u_int32_t maxClusterChainLength; u_int32_t firstDataSector; iconv_t cd; }; // functions // opens file system and calculates file system information int32_t openFileSystem(char *path, u_int32_t mode, struct sFileSystem *fs); // update boot sector int32_t writeBootSector(struct sFileSystem *fs); // sync file system int32_t syncFileSystem(struct sFileSystem *fs); // closes file system int32_t closeFileSystem(struct sFileSystem *fs); // lazy check if this is really a FAT bootsector int32_t check_bootsector(struct sBootSector *bs); // retrieves FAT entry for a cluster number int32_t getFATEntry(struct sFileSystem *fs, u_int32_t cluster, u_int32_t *data); // read FAT from file system void *readFAT(struct sFileSystem *fs, u_int16_t nr); // write FAT to file system int32_t writeFAT(struct sFileSystem *fs, void *fat); // read cluster from file systen void *readCluster(struct sFileSystem *fs, u_int32_t cluster); // write cluster to file systen int32_t writeCluster(struct sFileSystem *fs, u_int32_t cluster, void *data); // checks whether data marks a free cluster u_int16_t isFreeCluster(const u_int32_t data); // checks whether data marks the end of a cluster chain u_int16_t isEOC(struct sFileSystem *fs, const u_int32_t data); // checks whether data marks a bad cluster u_int16_t isBadCluster(struct sFileSystem *fs, const u_int32_t data); // returns the offset of a specific cluster in the data region of the file system off_t getClusterOffset(struct sFileSystem *fs, u_int32_t cluster); // parses one directory entry int32_t parseEntry(struct sFileSystem *fs, union sDirEntry *de); // calculate checksum for short dir entry name u_char calculateChecksum (char *sname); // checks whether all FATs have the same content int32_t checkFATs(struct sFileSystem *fs); // reads FSInfo structure int32_t readFSInfo(struct sFileSystem *fs, struct sFSInfo *fsInfo); // write FSInfo structure int32_t writeFSInfo(struct sFileSystem *fs, struct sFSInfo *fsInfo); #endif // __FAT_fs_h__ fatsort-1.3.365/src/entrylist.c0000664000175000017500000002241412321036670015656 0ustar feanorfeanor/* FATSort, utility for sorting FAT directory structures Copyright (C) 2004 Boris Leidner This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /* This file contains/describes some ADOs which are used to represent the structures of FAT directory entries and entry lists. */ #include #include #include #include #include "entrylist.h" #include "options.h" #include "errors.h" #include "natstrcmp.h" #include "mallocv.h" #include "stringlist.h" // random number u_int32_t irand( u_int32_t b, u_int32_t e) { double r = e - b + 1; return b + (u_int32_t)(r * rand()/(RAND_MAX+1.0)); } // List functions struct sDirEntryList * newDirEntryList(void) { /* create new dir entry list */ struct sDirEntryList *tmp; if ((tmp=malloc(sizeof(struct sDirEntryList)))==NULL) { stderror(); return NULL; } memset(tmp, 0, sizeof(struct sDirEntryList)); return tmp; } struct sDirEntryList * newDirEntry(char *sname, char *lname, struct sShortDirEntry *sde, struct sLongDirEntryList *ldel, u_int32_t entries) { /* create a new directory entry holder */ assert(sname != NULL); assert(lname != NULL); assert(sde != NULL); struct sDirEntryList *tmp; if ((tmp=malloc(sizeof(struct sDirEntryList)))==NULL) { stderror(); return NULL; } if ((tmp->sname=malloc(strlen(sname)+1))==NULL) { stderror(); free(tmp); return NULL; } strcpy(tmp->sname, sname); if ((tmp->lname=malloc(strlen(lname)+1))==NULL) { stderror(); free(tmp->sname); free(tmp); return NULL; } strcpy(tmp->lname, lname); if ((tmp->sde=malloc(sizeof(struct sShortDirEntry)))==NULL) { stderror(); free(tmp->lname); free(tmp->sname); free(tmp); return NULL; } memcpy(tmp->sde, sde, DIR_ENTRY_SIZE); tmp->ldel=ldel; tmp->entries=entries; tmp->next = NULL; return tmp; } struct sLongDirEntryList * insertLongDirEntryList(struct sLongDirEntry *lde, struct sLongDirEntryList *list) { /* insert a long directory entry to list */ assert(lde != NULL); struct sLongDirEntryList *tmp, *new; if ((new=malloc(sizeof(struct sLongDirEntryList)))==NULL) { stderror(); return NULL; } if ((new->lde=malloc(sizeof(struct sLongDirEntry)))==NULL) { stderror(); free(new); return NULL; } memcpy(new->lde, lde, DIR_ENTRY_SIZE); new->next=NULL; if (list != NULL) { tmp=list; while(tmp->next != NULL) { tmp=tmp->next; } tmp->next=new; return list; } else { return new; } } int32_t stripSpecialPrefixes(char *old, char *new) { /* strip special prefixes "a" and "the" */ assert(old != NULL); assert(new != NULL); struct sStringList *prefix=OPT_IGNORE_PREFIXES_LIST; int32_t len, len_old; len_old=strlen(old); while(prefix->next != NULL) { len=strlen(prefix->next->str); DEBUGMSG("prefix: %s", prefix->next->str); if (strncasecmp(old, prefix->next->str, len) == 0) { strncpy(new, old+len, len_old-len); new[len_old-len] = '\0'; return 1; } prefix=prefix->next; } return 0; } int32_t cmpEntries(struct sDirEntryList *de1, struct sDirEntryList *de2) { /* compare two directory entries */ assert(de1 != NULL); assert(de2 != NULL); char s1[MAX_PATH_LEN+1]; char s2[MAX_PATH_LEN+1]; char s1_col[MAX_PATH_LEN*2+1]; char s2_col[MAX_PATH_LEN*2+1]; // the volume label must always remain at the beginning of the (root) directory if ((de1->sde->DIR_Atrr & (ATTR_READ_ONLY | ATTR_HIDDEN | ATTR_SYSTEM | ATTR_VOLUME_ID | ATTR_DIRECTORY)) == ATTR_VOLUME_ID) { return(-1); } else if ((de2->sde->DIR_Atrr & (ATTR_READ_ONLY | ATTR_HIDDEN | ATTR_SYSTEM | ATTR_VOLUME_ID | ATTR_DIRECTORY)) == ATTR_VOLUME_ID) { return(1); // the special "." and ".." directories must always remain at the beginning of directories, in this order } else if (strcmp(de1->sname, ".") == 0) { return(-1); } else if (strcmp(de2->sname, ".") == 0) { return(1); } else if (strcmp(de1->sname, "..") == 0) { return(-1); } else if (strcmp(de2->sname, "..") == 0) { return(1); // deleted entries should be moved to the end of the directory } else if ((u_char) de1->sname[0] == DE_FREE) { return(1); } else if ((u_char) de2->sname[0] == DE_FREE) { return(-1); } char *ss1,*ss2; if ((de1->lname != NULL) && (de1->lname[0] != '\0')) { ss1=de1->lname; } else { ss1=de1->sname; } if ((de2->lname != NULL) && (de2->lname[0] != '\0')) { ss2=de2->lname; } else { ss2=de2->sname; } // it's not necessary to compare files for listing and randomization, // each entry will be put to the end of the list if (OPT_LIST || OPT_RANDOM) return 1; // directories will be put above normal files if (OPT_ORDER == 0) { if ((de1->sde->DIR_Atrr & ATTR_DIRECTORY) && !(de2->sde->DIR_Atrr & ATTR_DIRECTORY)) { return -1; } else if (!(de1->sde->DIR_Atrr & ATTR_DIRECTORY) && (de2->sde->DIR_Atrr & ATTR_DIRECTORY)) { return 1; } } else if (OPT_ORDER == 1) { if ((de1->sde->DIR_Atrr & ATTR_DIRECTORY) && !(de2->sde->DIR_Atrr & ATTR_DIRECTORY)) { return 1; } else if (!(de1->sde->DIR_Atrr & ATTR_DIRECTORY) && (de2->sde->DIR_Atrr & ATTR_DIRECTORY)) { return -1; } } // consider last modification time if (OPT_MODIFICATION) { u_int32_t md1, md2; md1 = de1->sde->DIR_WrtDate<<16 | de1->sde->DIR_WrtTime; md2 = de2->sde->DIR_WrtDate<<16 | de2->sde->DIR_WrtTime; // printf("md1: %x, md2: %x\n", md1, md2); if (md1 < md2) return -OPT_REVERSE; else if (md1 > md2) return OPT_REVERSE; else return 0; } // strip special prefixes if (OPT_IGNORE_PREFIXES_LIST->next != NULL) { if (stripSpecialPrefixes(ss1, s1)) { ss1=s1; } if (stripSpecialPrefixes(ss2, s2)) { ss2=s2; } } if (!OPT_ASCII) { // consider locale for comparison if ((strxfrm(s1_col, ss1, MAX_PATH_LEN*2) == MAX_PATH_LEN*2) || (strxfrm(s2_col, ss2, MAX_PATH_LEN*2) == MAX_PATH_LEN*2)) { myerror("String collation error!"); exit(1); } } //printf("Orig S1: %s, Orig S2: %s, Locale S1: %s, Locale S2: %s\n", ss1, ss2, s1_col, s2_col); if (OPT_NATURAL_SORT) { if (OPT_IGNORE_CASE) { return natstrcasecmp(ss1, ss2) * OPT_REVERSE; } else { return natstrcmp(ss1, ss2) * OPT_REVERSE; } } else if (OPT_ASCII) { // use plain ASCII corder if (OPT_IGNORE_CASE) { return strcasecmp(ss1, ss2) * OPT_REVERSE; } else { return strcmp(ss1, ss2) * OPT_REVERSE; } } else { if (OPT_IGNORE_CASE) { return strcasecmp(s1_col, s2_col) * OPT_REVERSE; } else { return strcmp(s1_col, s2_col) * OPT_REVERSE; } } } void insertDirEntryList(struct sDirEntryList *new, struct sDirEntryList *list) { /* insert a directory entry into list */ assert(new != NULL); assert(list != NULL); struct sDirEntryList *tmp, *dummy; tmp=list; while ((tmp->next != NULL) && (cmpEntries(new, tmp->next) >= 0)) { tmp=tmp->next; } dummy=tmp->next; tmp->next=new; new->next=dummy; } void freeDirEntryList(struct sDirEntryList *list) { /* free dir entry list */ /* char *sname, *lname; // short and long name strings struct sShortDirEntry *sde; // short dir entry struct sLongDirEntryList *ldel; // long name entries in a list int32_t entries; // number of entries struct sDirEntryList *next; // next dir entry */ assert(list != NULL); struct sDirEntryList *tmp; struct sLongDirEntryList *ldelist, *tmp2; while(list != NULL) { if (list->sname) free(list->sname); if (list->lname) free(list->lname); if (list->sde) free(list->sde); ldelist=list->ldel; while(ldelist != NULL) { free(ldelist->lde); tmp2=ldelist; ldelist = ldelist->next; free(tmp2); } tmp=list; list=list->next; free(tmp); } } void randomizeDirEntryList(struct sDirEntryList *list, u_int32_t entries) { /* randomize entry list */ assert(list != NULL); struct sDirEntryList *randlist, *tmp, *dummy1, *dummy2; u_int32_t i, j, pos; u_int32_t skip=0; randlist=list; // the volume label must always remain at the beginning of the (root) directory // the special "." and ".." directories must always remain at the beginning of directories, so skip them while (randlist->next && (((randlist->next->sde->DIR_Atrr & (ATTR_READ_ONLY | ATTR_HIDDEN | ATTR_SYSTEM | ATTR_VOLUME_ID | ATTR_DIRECTORY)) == ATTR_VOLUME_ID) || (strcmp(randlist->next->sname, ".") == 0) || (strcmp(randlist->next->sname, "..") == 0))) { DEBUGMSG("skipping randomization for %s", randlist->next->sname) randlist=randlist->next; skip++; } for (i=skip; i < entries; i++) { pos=irand(0, entries - 1 - i); tmp=randlist; // after the loop tmp->next is the selected item for (j=0; jnext; } // put selected entry to top of list dummy1=tmp->next; tmp->next=dummy1->next; dummy2=randlist->next; randlist->next=dummy1; dummy1->next=dummy2; randlist=randlist->next; } } fatsort-1.3.365/src/Makefile0000664000175000017500000000525412321036670015120 0ustar feanorfeanorCC=gcc LD=gcc ifdef DEBUG CFLAGS += -g -DDEBUG=$(DEBUG) -fstack-protector-all DEBUG_OBJ=mallocv.o else LDFLAGS += -s endif CFLAGS += -Wall -Wextra override CFLAGS+= -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 INSTALL_FLAGS=-m 0755 -p -D # Detect Mac OS X ($OSTYPE = darwin9.0 for Mac OS X 10.5 and darwin10.0 for Mac OS X 10.6) UNAME=$(shell uname -s) ifeq ($(UNAME),Darwin) NEED_ICONV_LIB = 1 # OS X's install does not support the '-D' flag. INSTALL_FLAGS=-m 0755 -p endif ifeq ($(OSTYPE),FreeBSD) override CFLAGS += -I/usr/local/include LDFLAGS += -L/usr/local/lib NEED_ICONV_LIB = 1 endif ifdef NEED_ICONV_LIB LDFLAGS += -liconv endif # Mac OS X does not have a "/usr/local/sbin" ifeq ($(UNAME),Darwin) SBINDIR=/usr/local/bin else SBINDIR=/usr/local/sbin endif OBJ=fatsort.o FAT_fs.o fileio.o endianness.o signal.o entrylist.o errors.o options.o clusterchain.o sort.o misc.o natstrcmp.o stringlist.o all: fatsort fatsort: $(OBJ) $(DEBUG_OBJ) Makefile ${LD} ${LDFLAGS} $(OBJ) $(DEBUG_OBJ) -o $@ fatsort.o: fatsort.c endianness.h signal.h FAT_fs.h platform.h options.h \ stringlist.h errors.h sort.h clusterchain.h misc.h mallocv.h Makefile $(CC) ${CFLAGS} -c $< -o $@ FAT_fs.o: FAT_fs.c FAT_fs.h platform.h errors.h endianness.h fileio.h \ mallocv.h Makefile $(CC) ${CFLAGS} -c $< -o $@ fileio.o: fileio.c fileio.h platform.h Makefile $(CC) ${CFLAGS} -c $< -o $@ endianness.o: endianness.c endianness.h mallocv.h Makefile $(CC) ${CFLAGS} -c $< -o $@ signal.o: signal.c signal.h mallocv.h Makefile $(CC) ${CFLAGS} -c $< -o $@ entrylist.o: entrylist.c entrylist.h FAT_fs.h platform.h options.h \ stringlist.h errors.h natstrcmp.h mallocv.h Makefile $(CC) ${CFLAGS} -c $< -o $@ errors.o: errors.c errors.h mallocv.h Makefile $(CC) ${CFLAGS} -c $< -o $@ options.o: options.c options.h platform.h FAT_fs.h stringlist.h errors.h \ mallocv.h Makefile $(CC) ${CFLAGS} -c $< -o $@ clusterchain.o: clusterchain.c clusterchain.h platform.h errors.h \ mallocv.h Makefile $(CC) ${CFLAGS} -c $< -o $@ sort.o: sort.c sort.h FAT_fs.h platform.h clusterchain.h entrylist.h \ errors.h options.h stringlist.h endianness.h signal.h misc.h fileio.h \ mallocv.h Makefile $(CC) ${CFLAGS} -c $< -o $@ misc.o: misc.c misc.h options.h platform.h FAT_fs.h stringlist.h \ mallocv.h Makefile $(CC) ${CFLAGS} -c $< -o $@ natstrcmp.o: natstrcmp.c natstrcmp.h mallocv.h Makefile $(CC) ${CFLAGS} -c $< -o $@ stringlist.o: stringlist.c stringlist.h platform.h FAT_fs.h errors.h \ mallocv.h Makefile $(CC) ${CFLAGS} -c $< -o $@ mallocv.o: mallocv.c mallocv.h errors.h $(CC) ${CFLAGS} -c $< -o $@ install: install $(INSTALL_FLAGS) fatsort $(DESTDIR)$(SBINDIR)/fatsort clean: rm -f *.o fatsort .PHONY: all clean fatsort-1.3.365/src/FAT_fs.c0000664000175000017500000004643112321036670014730 0ustar feanorfeanor/* FATDefrag, utility for defragmentation of FAT file systems Copyright (C) 2013 Boris Leidner This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /* This file contains/describes functions that are used to read, write, check, and use FAT filesystems. */ #include "FAT_fs.h" #include #include #include #include #include #include #include #include "errors.h" #include "endianness.h" #include "fileio.h" #include "mallocv.h" // used to check if device is mounted #if defined(__LINUX__) #include #elif defined (__BSD__) #include #include #endif int32_t check_mounted(char *filename) { /* check if filesystem is already mounted */ #if defined(__LINUX__) FILE *fd; struct mntent *mnt; int32_t ret = 0; char rp_filename[MAXPATHLEN+1], rp_mnt_fsname[MAXPATHLEN+1]; if ((fd = setmntent("/etc/mtab", "r")) == NULL) { stderror(); return -1; } // get real path if (realpath(filename, rp_filename) == NULL) { myerror("Unable to get realpath of filename!"); return -1; } while ((mnt = getmntent(fd)) != NULL) { if (realpath(mnt->mnt_fsname, rp_mnt_fsname) != NULL) { if (strcmp(rp_mnt_fsname, rp_filename) == 0) { ret = 1; break; } } } if (endmntent(fd) != 1) { myerror("Closing mtab failed!"); return -1; } return ret; #elif defined(__BSD__) struct statfs *mntbuf; int i, mntsize; int32_t ret = 0; char rp_filename[MAXPATHLEN], rp_mnt_fsname[MAXPATHLEN+1]; // get real path if (realpath(filename, rp_filename) == NULL) { myerror("Unable to get realpath of filename!"); return -1; } mntsize = getmntinfo(&mntbuf, MNT_NOWAIT); if (mntsize == 0) { stderror(); return -1; } for (i = mntsize - 1; i >= 0; i--) { realpath(mntbuf[i].f_mntfromname, rp_mnt_fsname); if (strcmp(rp_mnt_fsname, rp_filename) == 0) { ret = 1; break; } } return ret; #else // ok, we don't know how to check this on an unknown platform myerror("Don't know how to check whether filesystem is mounted! Use option '-f' to sort nonetheless."); return -1; #endif } int32_t check_bootsector(struct sBootSector *bs) { /* lazy check if this is really a FAT bootsector */ assert(bs != NULL); if (!((bs->BS_JmpBoot[0] == 0xeb) && (bs->BS_JmpBoot[2] == 0x90)) && !(bs->BS_JmpBoot[0] == 0xe9)) { // boot sector does not begin with specific instruction myerror("Boot sector does not begin with jump instruction!"); return -1; } else if (SwapInt16(bs->BS_EndOfBS) != 0xaa55) { // end of bootsector marker is missing myerror("End of boot sector marker is missing!"); return -1; } else if (SwapInt16(bs->BS_BytesPerSec) == 0) { myerror("Sectors have a size of zero!"); return -1; } else if (SwapInt16(bs->BS_BytesPerSec) % 512 != 0) { myerror("Sector size is not a multiple of 512 (%u)!", SwapInt16(bs->BS_BytesPerSec)); return -1; } else if (bs->BS_SecPerClus == 0) { myerror("Cluster size is zero!"); return -1; } else if (bs->BS_SecPerClus * SwapInt16(bs->BS_BytesPerSec) > 32768) { myerror("Cluster size is larger than 32k!"); return -1; } else if (SwapInt16(bs->BS_RsvdSecCnt) == 0) { myerror("Reserved sector count is zero!"); return -1; } else if (bs->BS_NumFATs == 0) { myerror("Number of FATs is zero!"); return -1; } else if (SwapInt16(bs->BS_RootEntCnt) % DIR_ENTRY_SIZE != 0) { myerror("Count of root directory entries must be zero or a multiple or 32! (%u)", SwapInt16(bs->BS_RootEntCnt)); return -1; } return 0; } int32_t read_bootsector(FILE *fd, struct sBootSector *bs) { /* reads bootsector */ assert(fd != NULL); assert(bs != NULL); // seek to beginning of fs if (fs_seek(fd, 0, SEEK_SET) == -1) { stderror(); return -1; } if (fs_read(bs, sizeof(struct sBootSector), 1, fd) < 1) { if (feof(fd)) { myerror("Boot sector is too short!"); } else { myerror("Failed to read from file!"); } return -1; } if (check_bootsector(bs)) { myerror("This is not a FAT boot sector or sector is damaged!"); return -1; } return 0; } int32_t writeBootSector(struct sFileSystem *fs) { /* write boot sector */ // seek to beginning of fs if (fs_seek(fs->fd, 0, SEEK_SET) == -1) { stderror(); return -1; } // write boot sector if (fs_write(&(fs->bs), sizeof(struct sBootSector), 1, fs->fd) < 1) { stderror(); return -1; } // update backup boot sector for FAT32 file systems if (fs->FATType == FATTYPE_FAT32) { // seek to beginning of backup boot sector if (fs_seek(fs->fd, SwapInt16(fs->bs.FATxx.FAT32.BS_BkBootSec) * fs->sectorSize, SEEK_SET) == -1) { stderror(); return -1; } // write backup boot sector if (fs_write(&(fs->bs), sizeof(struct sBootSector), 1, fs->fd) < 1) { stderror(); return -1; } } return 0; } int32_t readFSInfo(struct sFileSystem *fs, struct sFSInfo *fsInfo) { /* reads FSInfo structure */ assert(fs != NULL); assert(fsInfo != NULL); // seek to beginning of FSInfo structure if (fs_seek(fs->fd, SwapInt16(fs->bs.FATxx.FAT32.BS_FSInfo) * fs->sectorSize, SEEK_SET) == -1) { stderror(); return -1; } if (fs_read(fsInfo, sizeof(struct sFSInfo), 1, fs->fd) < 1) { stderror(); return -1; } return 0; } int32_t writeFSInfo(struct sFileSystem *fs, struct sFSInfo *fsInfo) { /* write FSInfo structure */ assert(fs != NULL); assert(fsInfo != NULL); // seek to beginning of FSInfo structure if (fs_seek(fs->fd, SwapInt16(fs->bs.FATxx.FAT32.BS_FSInfo) * fs->sectorSize, SEEK_SET) == -1) { stderror(); return -1; } // write boot sector if (fs_write(fsInfo, sizeof(struct sFSInfo), 1, fs->fd) < 1) { stderror(); return -1; } return 0; } int32_t getCountOfClusters(struct sBootSector *bs) { /* calculates count of clusters */ assert(bs != NULL); u_int32_t RootDirSectors, FATSz, TotSec, DataSec; int32_t retvalue; RootDirSectors = ((SwapInt16(bs->BS_RootEntCnt) * DIR_ENTRY_SIZE) + (SwapInt16(bs->BS_BytesPerSec) - 1)); RootDirSectors = RootDirSectors / SwapInt16(bs->BS_BytesPerSec); if (bs->BS_FATSz16 != 0) { FATSz = SwapInt16(bs->BS_FATSz16); } else { FATSz = SwapInt32(bs->FATxx.FAT32.BS_FATSz32); } if (SwapInt16(bs->BS_TotSec16) != 0) { TotSec = SwapInt16(bs->BS_TotSec16); } else { TotSec = SwapInt32(bs->BS_TotSec32); } DataSec = TotSec - (SwapInt16(bs->BS_RsvdSecCnt) + (bs->BS_NumFATs * FATSz) + RootDirSectors); retvalue = DataSec / bs->BS_SecPerClus; if (retvalue <= 0) { myerror("Failed to calculate count of clusters!"); return -1; } return retvalue; } int32_t getFATType(struct sBootSector *bs) { /* retrieves FAT type from bootsector */ assert(bs != NULL); int32_t CountOfClusters; CountOfClusters=getCountOfClusters(bs); if (CountOfClusters == -1) { myerror("Failed to get count of clusters!"); return -1; } else if (CountOfClusters < 4096) { // FAT12! return FATTYPE_FAT12; } else if (CountOfClusters < 65525) { // FAT16! return FATTYPE_FAT16; } else { // FAT32! return FATTYPE_FAT32; } } u_int16_t isFreeCluster(const u_int32_t data) { /* checks whether data marks a free cluster */ return (data & 0x0FFFFFFF) == 0; } u_int16_t isEOC(struct sFileSystem *fs, const u_int32_t data) { /* checks whether data marks the end of a cluster chain */ assert(fs != NULL); if(fs->FATType == FATTYPE_FAT12) { if(data >= 0x0FF8) return 1; } else if(fs->FATType == FATTYPE_FAT16) { if(data >= 0xFFF8) return 1; } else if (fs->FATType == FATTYPE_FAT32) { if((data & 0x0FFFFFFF) >= 0x0FFFFFF8) return 1; } return 0; } u_int16_t isBadCluster(struct sFileSystem *fs, const u_int32_t data) { /* checks whether data marks a bad cluster */ assert(fs != NULL); if(fs->FATType == FATTYPE_FAT12) { if(data == 0xFF7) return 1; } else if(fs->FATType == FATTYPE_FAT16) { if(data == 0xFFF7) return 1; } else if (fs->FATType == FATTYPE_FAT32) { if ((data & 0x0FFFFFFF) == 0x0FFFFFF7) return 1; } return 0; } void *readFAT(struct sFileSystem *fs, u_int16_t nr) { /* reads a FAT from file system fs */ assert(fs != NULL); assert(nr < fs->bs.BS_NumFATs); u_int32_t FATSizeInBytes; off_t BSOffset; void *FAT; FATSizeInBytes = fs->FATSize * fs->sectorSize; if ((FAT=malloc(FATSizeInBytes))==NULL) { stderror(); return NULL; } BSOffset = (off_t)SwapInt16(fs->bs.BS_RsvdSecCnt) * SwapInt16(fs->bs.BS_BytesPerSec); if (fs_seek(fs->fd, BSOffset + nr * FATSizeInBytes, SEEK_SET) == -1) { myerror("Seek error!"); free(FAT); return NULL; } if (fs_read(FAT, FATSizeInBytes, 1, fs->fd) < 1) { myerror("Failed to read from file!"); free(FAT); return NULL; } return FAT; } int32_t writeFAT(struct sFileSystem *fs, void *fat) { /* write FAT to file system */ assert(fs != NULL); assert(fat != NULL); u_int32_t FATSizeInBytes, nr; off_t BSOffset; FATSizeInBytes = fs->FATSize * fs->sectorSize; BSOffset = (off_t)SwapInt16(fs->bs.BS_RsvdSecCnt) * SwapInt16(fs->bs.BS_BytesPerSec); // write all FATs! for(nr=0; nr< fs->bs.BS_NumFATs; nr++) { if (fs_seek(fs->fd, BSOffset + nr * FATSizeInBytes, SEEK_SET) == -1) { myerror("Seek error!"); return -1; } if (fs_write(fat, FATSizeInBytes, 1, fs->fd) < 1) { myerror("Failed to read from file!"); return -1; } } return 0; } int32_t checkFATs(struct sFileSystem *fs) { /* checks whether all FATs have the same content */ assert(fs != NULL); u_int32_t FATSizeInBytes; int32_t result=0; int32_t i; off_t BSOffset; char *FAT1, *FATx; // if there is just one FAT, we don't have to check anything if (fs->bs.BS_NumFATs < 2) { return 0; } FATSizeInBytes = fs->FATSize * fs->sectorSize; if ((FAT1=malloc(FATSizeInBytes))==NULL) { stderror(); return -1; } if ((FATx=malloc(FATSizeInBytes))==NULL) { stderror(); free(FAT1); return -1; } BSOffset = (off_t)SwapInt16(fs->bs.BS_RsvdSecCnt) * SwapInt16(fs->bs.BS_BytesPerSec); if (fs_seek(fs->fd, BSOffset, SEEK_SET) == -1) { myerror("Seek error!"); free(FAT1); free(FATx); return -1; } if (fs_read(FAT1, FATSizeInBytes, 1, fs->fd) < 1) { myerror("Failed to read from file!"); free(FAT1); free(FATx); return -1; } for(i=1; i < fs->bs.BS_NumFATs; i++) { if (fs_seek(fs->fd, BSOffset+FATSizeInBytes, SEEK_SET) == -1) { myerror("Seek error!"); free(FAT1); free(FATx); return -1; } if (fs_read(FATx, FATSizeInBytes, 1, fs->fd) < 1) { myerror("Failed to read from file!"); free(FAT1); free(FATx); return -1; } //printf("FAT1: %08lx FATx: %08lx\n", FAT1[0], FATx[0]); result = memcmp(FAT1, FATx, FATSizeInBytes) != 0; if (result) break; // FATs don't match } free(FAT1); free(FATx); return result; } int32_t getFATEntry(struct sFileSystem *fs, u_int32_t cluster, u_int32_t *data) { /* retrieves FAT entry for a cluster number */ assert(fs != NULL); assert(data != NULL); off_t FATOffset, BSOffset; *data=0; switch(fs->FATType) { case FATTYPE_FAT32: FATOffset = (off_t)cluster * 4; BSOffset = (off_t)SwapInt16(fs->bs.BS_RsvdSecCnt) * SwapInt16(fs->bs.BS_BytesPerSec) + FATOffset; if (fs_seek(fs->fd, BSOffset, SEEK_SET) == -1) { myerror("Seek error!"); return -1; } if (fs_read(data, 4, 1, fs->fd) < 1) { myerror("Failed to read from file!"); return -1; } *data=SwapInt32(*data); *data = *data & 0x0fffffff; break; case FATTYPE_FAT16: FATOffset = (off_t)cluster * 2; BSOffset = (off_t) SwapInt16(fs->bs.BS_RsvdSecCnt) * SwapInt16(fs->bs.BS_BytesPerSec) + FATOffset; if (fs_seek(fs->fd, BSOffset, SEEK_SET) == -1) { myerror("Seek error!"); return -1; } if (fs_read(data, 2, 1, fs->fd)<1) { myerror("Failed to read from file!"); return -1; } *data=SwapInt32(*data); break; case FATTYPE_FAT12: FATOffset = (off_t) cluster + (cluster / 2); BSOffset = (off_t) SwapInt16(fs->bs.BS_RsvdSecCnt) * SwapInt16(fs->bs.BS_BytesPerSec) + FATOffset; if (fs_seek(fs->fd, BSOffset, SEEK_SET) == -1) { myerror("Seek error!"); return -1; } if (fs_read(data, 2, 1, fs->fd)<1) { myerror("Failed to read from file!"); return -1; } *data=SwapInt32(*data); if (cluster & 1) { *data = *data >> 4; /* cluster number is odd */ } else { *data = *data & 0x0FFF; /* cluster number is even */ } break; default: myerror("Failed to get FAT type!"); return -1; } return 0; } off_t getClusterOffset(struct sFileSystem *fs, u_int32_t cluster) { /* returns the offset of a specific cluster in the data region of the file system */ assert(fs != NULL); assert(cluster > 1); return (((off_t)(cluster - 2) * fs->bs.BS_SecPerClus) + fs->firstDataSector) * fs->sectorSize; } void *readCluster(struct sFileSystem *fs, u_int32_t cluster) { /* read cluster from file system */ void *dummy; if (fs_seek(fs->fd, getClusterOffset(fs, cluster), SEEK_SET) != 0) { stderror(); return NULL; } if ((dummy = malloc(fs->clusterSize)) == NULL) { stderror(); return NULL; } if ((fs_read(dummy, fs->clusterSize, 1, fs->fd)<1)) { myerror("Failed to read cluster!"); return NULL; } return dummy; } int32_t writeCluster(struct sFileSystem *fs, u_int32_t cluster, void *data) { /* write cluster to file systen */ if (fs_seek(fs->fd, getClusterOffset(fs, cluster), SEEK_SET) != 0) { stderror(); return -1; } if (fs_write(data, fs->clusterSize, 1, fs->fd)<1) { stderror(); return -1; } return 0; } int32_t parseEntry(struct sFileSystem *fs, union sDirEntry *de) { /* parses one directory entry */ assert(fs != NULL); assert(de != NULL); if ((fs_read(de, DIR_ENTRY_SIZE, 1, fs->fd)<1)) { myerror("Failed to read from file!"); return -1; } if (de->ShortDirEntry.DIR_Name[0] == DE_FOLLOWING_FREE ) return 0; // no more entries // long dir entry if ((de->LongDirEntry.LDIR_Attr & ATTR_LONG_NAME_MASK) == ATTR_LONG_NAME) return 2; return 1; // short dir entry } u_char calculateChecksum (char *sname) { u_char len; u_char sum; sum = 0; for (len=11; len!=0; len--) { sum = ((sum & 1) ? 0x80 : 0) + (sum >> 1) + *sname++; } return sum; } int32_t openFileSystem(char *path, u_int32_t mode, struct sFileSystem *fs) { /* opens file system and assemlbes file system information into data structure */ assert(path != NULL); assert(fs != NULL); int32_t ret; fs->rfd=0; switch(mode) { case FS_MODE_RO: if ((fs->fd=fopen(path, "rb")) == NULL) { stderror(); return -1; } break; case FS_MODE_RW: if ((fs->fd=fopen(path, "r+b")) == NULL) { stderror(); return -1; } break; case FS_MODE_RO_EXCL: case FS_MODE_RW_EXCL: // this check is only done for user convenience // open would fail too if device is mounted, but without specific error message ret=check_mounted(path); switch (ret) { case 0: break; // filesystem not mounted case 1: // filesystem mounted myerror("Filesystem is mounted!"); return -1; case -1: // unable to check default: myerror("Could not check whether filesystem is mounted!"); return -1; } // opens the device exclusively. This is not mandatory! e.g. mkfs.vfat ignores it! if ((fs->rfd=open(path, (mode == FS_MODE_RO_EXCL) ? O_RDONLY | O_EXCL : O_RDWR | O_EXCL)) == -1) { stderror(); return -1; } // connect the file descriptor to a stream if ((fs->fd=fdopen(fs->rfd, (mode == FS_MODE_RO_EXCL) ? "rb" : "r+b")) == NULL) { stderror(); close(fs->rfd); return -1; } break; default: myerror("Mode not supported!"); return -1; } // read boot sector if (read_bootsector(fs->fd, &(fs->bs))) { myerror("Failed to read boot sector!"); fclose(fs->fd); close(fs->rfd); return -1; } strncpy(fs->path, path, MAX_PATH_LEN); fs->path[MAX_PATH_LEN] = '\0'; if (SwapInt16(fs->bs.BS_TotSec16) != 0) { fs->totalSectors = SwapInt16(fs->bs.BS_TotSec16); } else { fs->totalSectors = SwapInt32(fs->bs.BS_TotSec32); } if (fs->totalSectors == 0) { myerror("Count of total sectors must not be zero!"); fclose(fs->fd); close(fs->rfd); return -1; } fs->FATType = getFATType(&(fs->bs)); if (fs->FATType == -1) { myerror("Failed to get FAT type!"); fclose(fs->fd); close(fs->rfd); return -1; } if ((fs->FATType == FATTYPE_FAT32) && (fs->bs.FATxx.FAT32.BS_FATSz32 == 0)) { myerror("32-bit count of FAT sectors must not be zero for FAT32!"); fclose(fs->fd); close(fs->rfd); return -1; } else if (((fs->FATType == FATTYPE_FAT12) || (fs->FATType == FATTYPE_FAT16)) && (fs->bs.BS_FATSz16 == 0)) { myerror("16-bit count of FAT sectors must not be zero for FAT1x!"); fclose(fs->fd); close(fs->rfd); return -1; } if (fs->bs.BS_FATSz16 != 0) { fs->FATSize = SwapInt16(fs->bs.BS_FATSz16); } else { fs->FATSize = SwapInt32(fs->bs.FATxx.FAT32.BS_FATSz32); } // check whether count of root dir entries is ok for given FAT type if (((fs->FATType == FATTYPE_FAT16) || (fs->FATType == FATTYPE_FAT12)) && (SwapInt16(fs->bs.BS_RootEntCnt) == 0)) { myerror("Count of root directory entries must not be zero for FAT1x!"); fclose(fs->fd); close(fs->rfd); return -1; } else if ((fs->FATType == FATTYPE_FAT32) && (SwapInt16(fs->bs.BS_RootEntCnt) != 0)) { myerror("Count of root directory entries must be zero for FAT32 (%u)!", SwapInt16(fs->bs.BS_RootEntCnt)); fclose(fs->fd); close(fs->rfd); return -1; } fs->clusters=getCountOfClusters(&(fs->bs)); if (fs->clusters == -1) { myerror("Failed to get count of clusters!"); fclose(fs->fd); close(fs->rfd); return -1; } if (fs->clusters > 268435445) { myerror("Count of clusters should be less than 268435446, but is %d!", fs->clusters); fclose(fs->fd); close(fs->rfd); return -1; } fs->sectorSize=SwapInt16(fs->bs.BS_BytesPerSec); fs->clusterSize=fs->bs.BS_SecPerClus * SwapInt16(fs->bs.BS_BytesPerSec); fs->FSSize = (u_int64_t) fs->clusters * fs->clusterSize; fs->maxDirEntriesPerCluster = fs->clusterSize / DIR_ENTRY_SIZE; fs->maxClusterChainLength = (u_int32_t) MAX_FILE_LEN / fs->clusterSize; u_int32_t rootDirSectors; rootDirSectors = ((SwapInt16(fs->bs.BS_RootEntCnt) * DIR_ENTRY_SIZE) + (SwapInt16(fs->bs.BS_BytesPerSec) - 1)) / SwapInt16(fs->bs.BS_BytesPerSec); fs->firstDataSector = (SwapInt16(fs->bs.BS_RsvdSecCnt) + (fs->bs.BS_NumFATs * fs->FATSize) + rootDirSectors); // convert utf 16 le to local charset fs->cd = iconv_open("", "UTF-16LE"); if (fs->cd == (iconv_t)-1) { myerror("iconv_open failed!"); return -1; } return 0; } int32_t syncFileSystem(struct sFileSystem *fs) { /* sync file system */ if (fflush(fs->fd) != 0) { myerror("Could not flush stream!"); return -1; } if (fsync(fileno(fs->fd)) != 0) { myerror("Could not sync file descriptor!"); return -1; } return 0; } int32_t closeFileSystem(struct sFileSystem *fs) { /* closes file system */ assert(fs != NULL); fclose(fs->fd); if ((fs->mode == FS_MODE_RW_EXCL) || (fs->mode == FS_MODE_RO_EXCL)) close(fs->rfd); iconv_close(fs->cd); return 0; } fatsort-1.3.365/src/endianness.h0000664000175000017500000000240712321036670015755 0ustar feanorfeanor/* FATSort, utility for sorting FAT directory structures Copyright (C) 2004 Boris Leidner This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /* This functions are used to convert endianness of integers. */ #ifndef __endianness_h__ #define __endianness_h__ /* supports different byte-orders */ #ifndef __BIG_ENDIAN__ #define SwapInt16(i) i #define SwapInt32(i) i #else #include #include "platform.h" // swaps endianness of a 16 bit integer u_int16_t SwapInt16(u_int16_t value); // swaps endianness of a 32 bit integer u_int32_t SwapInt32(u_int32_t value); #endif #endif //__ endianness_h__ fatsort-1.3.365/src/mallocv.h0000664000175000017500000000265712321036670015272 0ustar feanorfeanor/* FATSort, utility for sorting FAT directory structures Copyright (C) 2004 Boris Leidner This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /* This file contains/describes debug versions for malloc and free */ #ifndef __mallocv_h__ #define __mallocv_h__ #include #if DEBUG >= 2 #define malloc(size) mallocv(__FILE__, __LINE__, size) #define realloc(ptr, size) reallocv(__FILE__, __LINE__, ptr, size) #define free(ptr) freev(__FILE__, __LINE__, ptr) #define REPORT_MEMORY_LEAKS reportLeaks(); void *mallocv(char *filename, u_int32_t line, size_t size); void *reallocv(char *filename, u_int32_t line, void *ptr, size_t size); void freev(char *filename, u_int32_t line, void *ptr); void reportLeaks(); #else #define REPORT_MEMORY_LEAKS #endif #endif // __mallocv_h__ fatsort-1.3.365/src/fileio.c0000664000175000017500000000244312321036670015070 0ustar feanorfeanor/* FATSort, utility for sorting FAT directory structures Copyright (C) 2004 Boris Leidner This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /* This file contains file io functions for UNIX/Linux */ #include "fileio.h" #include #include int fs_seek(FILE *stream, off_t offset, int whence) { return fseeko(stream, offset, whence); } off_t fs_read(void *ptr, u_int32_t size, u_int32_t n, FILE *stream) { return fread(ptr, size, n, stream); } off_t fs_write(const void *ptr, u_int32_t size, u_int32_t n, FILE *stream) { return fwrite(ptr, size, n, stream); } int fs_close(FILE* file) { return fclose(file); } fatsort-1.3.365/src/endianness.c0000664000175000017500000000301112321036670015740 0ustar feanorfeanor/* FATSort, utility for sorting FAT directory structures Copyright (C) 2004 Boris Leidner This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /* This functions are used to convert endianness of integers. */ #include "endianness.h" #include "mallocv.h" // Endian swap functions #ifdef __BIG_ENDIAN__ u_int16_t SwapInt16(u_int16_t value) { /* swaps endianness of a 16 bit integer */ union { u_int16_t ivalue; char cvalue[2]; } u; u.ivalue=value; char tmp; tmp=u.cvalue[0]; u.cvalue[0]=u.cvalue[1]; u.cvalue[1]=tmp; return u.ivalue; } u_int32_t SwapInt32(u_int32_t value) { /* swaps endianness of a 32 bit integer */ union { u_int32_t ivalue; char cvalue[4]; } u; u.ivalue=value; char tmp; tmp=u.cvalue[0]; u.cvalue[0]=u.cvalue[3]; u.cvalue[3]=tmp; tmp=u.cvalue[1]; u.cvalue[1]=u.cvalue[2]; u.cvalue[2]=tmp; return u.ivalue; } #endif fatsort-1.3.365/src/natstrcmp.c0000664000175000017500000000544412321036670015640 0ustar feanorfeanor/* FATSort, utility for sorting FAT directory structures Copyright (C) 2008 Boris Leidner This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /* This file contains/describes functions for natural order sorting. */ #include "natstrcmp.h" #include #include #include #include #include "mallocv.h" int32_t isDigit(const char c) { /* return true if c is a digit, otherwise false */ if ((c >= '0') && (c <= '9')) return 1; return 0; } int32_t parseNumber(char **s) { /* parse integer in string s */ int32_t value=0; if (!isDigit(**s)) return -1; while(isDigit(**s)) { value=value*10 + **s -'0'; (*s)++; } return value; } int32_t natstrcompare(const char *str1, const char *str2, const u_int32_t respectCase) { /* natural order string compare */ assert(str1 != NULL); assert(str2 != NULL); int32_t n1=0, n2=0; char *s1 = (char *) str1; char *s2 = (char *) str2; while(1) { //printf("Strings: %s %s\n", s1, s2); if ((*s1 == '\0') || (*s2 == '\0')) { return strcmp(s1, s2); } // compare characters until the first digit occurs while (1) { if (isDigit(*s1) || isDigit(*s2)) break; else if ((*s1 == '\0') && (*s2 == '\0')) return 0; else if ((*s2 == '\0') || (respectCase ? toupper(*s1) > toupper(*s2) : *s1 > *s2)) return 1; else if ((*s1 == '\0') || (respectCase ? toupper(*s1) < toupper(*s2) : *s1 < *s2)) return -1; s1++; s2++; } // at least one of the strings has a number in it n1=parseNumber(&s1); n2=parseNumber(&s2); //printf("Numbers: %d %d\n", n1, n2); // one of the strings had no number if ((n1 == -1) || (n2 == -1)) { if ((*s1 == '\0') && (n1 == -1)) return -1; else if ((*s1 == '\0') && (n2 == -1)) return '0' < *s2 ? -1 : 1; else if ((*s2 == '\0') && (n1 == -1)) return '0' < *s1 ? 1 : -1; else if ((*s2 == '\0') && (n2 == -1)) return 1; // both strings had numbers in it } else if (n1 != n2) return n1 > n2 ? 1 : -1; } } int32_t natstrcmp(const char *str1, const char *str2) { return natstrcompare(str1, str2, 0); } int32_t natstrcasecmp(const char *str1, const char *str2) { return natstrcompare(str1, str2, 1); } fatsort-1.3.365/src/stringlist.h0000664000175000017500000000357112321036670016033 0ustar feanorfeanor/* FATSort, utility for sorting FAT directory structures Copyright (C) 2004 Boris Leidner This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /* This file contains/describes functions to manage string lists. */ #ifndef __stringlist_h__ #define __stringlist_h__ #include #include "platform.h" #include "FAT_fs.h" struct sStringList { char *str; struct sStringList *next; }; // defines return values for function matchesStringList #define RETURN_NO_MATCH 0 #define RETURN_EXACT_MATCH 1 #define RETURN_SUB_MATCH 2 // create a new string list struct sStringList *newStringList(); // insert new directory path into directory path list int32_t addStringToStringList(struct sStringList *stringList, const char *str); // evaluates whether str is contained in strList int32_t matchesStringList(struct sStringList *stringList, const char *str); // evaluate whether str matches the include an exclude dir path lists or not int32_t matchesStringLists(struct sStringList *includes, struct sStringList *includes_recursion, struct sStringList *excludes, struct sStringList *excludes_recursion, const char *str); // free string list void freeStringList(struct sStringList *stringList); #endif //__stringlist_h__ fatsort-1.3.365/src/stringlist.c0000664000175000017500000000570012321036670016022 0ustar feanorfeanor/* FATSort, utility for sorting FAT directory structures Copyright (C) 2004 Boris Leidner This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /* This file contains/describes functions to manage string lists. */ #include "stringlist.h" #include #include #include #include "errors.h" #include "mallocv.h" struct sStringList *newStringList() { /* create a new string list */ struct sStringList *stringList; // create the dummy head element stringList = malloc(sizeof(struct sStringList)); if (stringList == NULL) { stderror(); return NULL; } stringList->str = NULL; stringList->next = NULL; return stringList; } int32_t addStringToStringList(struct sStringList *stringList, const char *str) { /* insert new string into string list */ assert(stringList != NULL); assert(stringList->str == NULL); assert(str != NULL); int32_t len; // find end of list while (stringList->next != NULL) { stringList = stringList->next; } // allocate memory for new entry stringList->next=malloc(sizeof(struct sStringList)); if (stringList->next == NULL) { stderror(); return -1; } stringList->next->next = NULL; len=strlen(str); // allocate memory for string stringList->next->str=malloc(len+1); if (stringList->next->str == NULL) { stderror(); return -1; } strncpy(stringList->next->str, str, len); stringList->next->str[len] = '\0'; return 0; } int32_t matchesStringList(struct sStringList *stringList, const char *str) { /* evaluates whether str is contained in stringList */ assert(stringList != NULL); assert(stringList->str == NULL); assert(str != NULL); int32_t ret=0; // not in list stringList=stringList->next; while (stringList != NULL) { if (strncmp(stringList->str, str, strlen(stringList->str)) == 0) { // contains a top level string of str ret=RETURN_SUB_MATCH; } if (strcmp(stringList->str, str) == 0) { // contains str exactly, so return immediately return RETURN_EXACT_MATCH; } stringList = stringList->next; } return ret; } void freeStringList(struct sStringList *stringList) { /* free directory list */ assert(stringList != NULL); struct sStringList *tmp; while (stringList != NULL) { if (stringList->str) free(stringList->str); tmp=stringList; stringList=stringList->next; free(tmp); } } fatsort-1.3.365/src/fileio.h0000664000175000017500000000231712321036670015075 0ustar feanorfeanor/* FATSort, utility for sorting FAT directory structures Copyright (C) 2004 Boris Leidner This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /* This file contains file io functions for UNIX/Linux */ #ifndef __fileio_h__ #define __fileio_h__ #include #include #include "platform.h" int fs_seek(FILE *stream, off_t offset, int whence); off_t fs_read(void *ptr, u_int32_t size, u_int32_t n, FILE *stream); off_t fs_write(const void *ptr, u_int32_t size, u_int32_t n, FILE *stream); int fs_close(FILE* file); #endif // __fileio_h__ fatsort-1.3.365/src/sort.h0000664000175000017500000000276712321036670014626 0ustar feanorfeanor/* FATSort, utility for sorting FAT directory structures Copyright (C) 2004 Boris Leidner This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /* This file contains/describes functions for sorting of FAT filesystems. */ #ifndef __sort_h__ #define __sort_h__ #include #include #include "FAT_fs.h" #include "clusterchain.h" // sorts FAT file system int32_t sortFileSystem(char *filename); // sorts the root directory of a FAT12 or FAT16 file system int32_t sortFAT1xRootDirectory(struct sFileSystem *fs); // sorts directory entries in a cluster int32_t sortClusterChain(struct sFileSystem *fs, u_int32_t cluster, const char (*path)[MAX_PATH_LEN+1]); // returns cluster chain for a given start cluster int32_t getClusterChain(struct sFileSystem *fs, u_int32_t startCluster, struct sClusterChain *chain); #endif // __sort_h__ fatsort-1.3.365/src/misc.c0000664000175000017500000000223712321036670014555 0ustar feanorfeanor/* FATSort, utility for sorting FAT directory structures Copyright (C) 2004 Boris Leidner This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /* This file contains/describes miscellaneous functions. */ #include "misc.h" #include #include #include "options.h" #include "mallocv.h" void infomsg(char *str, ...) { /* info messages that can be muted with a command line option */ va_list argptr; if (!OPT_QUIET) { va_start(argptr,str); vprintf(str,argptr); va_end(argptr); } } fatsort-1.3.365/src/misc.h0000664000175000017500000000200612321036670014554 0ustar feanorfeanor/* FATSort, utility for sorting FAT directory structures Copyright (C) 2004 Boris Leidner This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /* This file contains/describes miscellaneous functions. */ #ifndef __misc_h__ #define __misc_h__ // info messages that can be muted with a command line option void infomsg(char *str, ...); #endif // __misc_h__ fatsort-1.3.365/src/fatsort.c0000664000175000017500000001744312321036670015311 0ustar feanorfeanor/* FATSort, utility for sorting FAT directory structures Copyright (C) 2004 Boris Leidner This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /* This file contains the main function of fatsort. */ #include #include #include #include #include #include #include #include #include #include // project includes #include "endianness.h" #include "signal.h" #include "FAT_fs.h" #include "options.h" #include "errors.h" #include "sort.h" #include "clusterchain.h" #include "misc.h" #include "platform.h" #include "mallocv.h" // program information #define INFO_PROGRAM "fatsort" #define INFO_VERSION "1.3" #define INFO_AUTHOR "Written by Boris Leidner.\n" #define INFO_COPYRIGHT "Copyright (C) 2004-2014 Boris Leidner.\n" #define INFO_LICENSE "License GPLv2: GNU GPL version 2 (see LICENSE.txt)\n" \ "This is free software: you are free to change and redistribute it.\n" \ "There is NO WARRANTY, to the extent permitted by law.\n" #define INFO_DESCRIPTION "FATSort sorts directory structures of FAT file systems. " \ "Many MP3 hardware players don't sort files automatically " \ "but play them in the order they were transferred to the " \ "device. FATSort can help here.\n" #define INFO_USAGE "Usage: fatsort [OPTIONS] DEVICE\n" \ "\n" \ "Options:\n\n" \ "\t-a\t Use ASCIIbetical order for sorting\n\n" \ "\t-c\t Ignore case of file names\n\n" \ "\t-f\t Force sorting even if file system is mounted\n\n" \ "\t-h, --help\n\n" \ "\t\tPrint some help\n\n" \ "\t-i\t Print file system information only\n\n" \ "\t-I=PFX\t Ignore file name PFX\n\n" \ "\t-l\t Print current order of files only\n\n" \ "\t-o=FLAG\t Sort order of files where FLAG is one of\n\n" \ "\t\t\td : directories first (default)\n\n" \ "\t\t\tf : files first\n\n" \ "\t\t\ta : files and directories are not differentiated\n\n" \ "\t-n\t Natural order sorting\n\n" \ "\t-q\t Be quiet\n\n" \ "\t-r\t Sort in reverse order\n\n" \ "\t-R\t Sort in random order\n\n" \ "\t-t\t Sort by last modification date and time\n\n" \ "\t-v, --version\n\n" \ "\t\tPrint version information\n\n" \ "\tThe following options can be specified multiple times:\n\n" \ "\t-d=DIR\t Sort directory DIR only\n\n" \ "\t-D=DIR\t Sort directory DIR and all subdirectories\n\n" \ "\t-x=DIR\t Don't sort directory DIR\n\n" \ "\t-X=DIR\t Don't sort directory DIR and its subdirectories\n\n" \ "DEVICE must be a FAT12, FAT16 or FAT32 file system.\n\n" \ "WARNING: THE FILESYSTEM MUST BE CONSISTENT, OTHERWISE YOU MAY DAMAGE IT!\n" \ "IF SOMEONE ELSE HAS ACCESS TO THE DEVICE HE MIGHT EXPLOIT FATSORT WITH\n" \ "A FORGED CORRUPT FILESYSTEM! USE THIS PROGRAM AT YOUR OWN RISK!\n" \ "\n" \ "Examples:\n" \ "\tfatsort /dev/sda\t\tSort /dev/sda.\n" \ "\tfatsort -n /dev/sdb1\t\tSort /dev/sdb1 with natural order.\n" \ "\n" \ "Report bugs to .\n" #define INFO_OPTION_VERSION INFO_PROGRAM " " INFO_VERSION "\n" \ "\n" \ INFO_COPYRIGHT \ INFO_LICENSE \ "\n" \ INFO_AUTHOR #define INFO_OPTION_HELP INFO_DESCRIPTION \ "\n" \ INFO_USAGE int32_t printFSInfo(char *filename) { /* print file system information */ assert(filename != NULL); u_int32_t value, clen; int32_t usedClusters, badClusters; int32_t i; struct sClusterChain *chain; struct sFileSystem fs; printf("\t- File system information -\n"); if (openFileSystem(filename, FS_MODE_RO, &fs)) { myerror("Failed to open file system!"); return -1; } usedClusters=0; badClusters=0; for (i=2; i This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /* This file contains/describes the cluster chain ADO with its structures and functions. Cluster chain ADOs hold a linked list of cluster numbers. Together all clusters in a cluster chain hold the date of a file or a directory in a FAT filesystem. */ #ifndef __clusterchain_h__ #define __clusterchain_h__ #include #include "platform.h" struct sClusterChain { /* this structure contains cluster chains */ u_int32_t cluster; struct sClusterChain *next; }; // create new cluster chain struct sClusterChain *newClusterChain(void); // allocate memory and insert cluster into cluster chain int32_t insertCluster(struct sClusterChain *chain, u_int32_t cluster); // free cluster chain void freeClusterChain(struct sClusterChain *chain); #endif // __clusterchain_h__ fatsort-1.3.365/src/options.h0000664000175000017500000000342512321036670015322 0ustar feanorfeanor/* FATSort, utility for sorting FAT directory structures Copyright (C) 2004 Boris Leidner This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /* This file contains/describes functions that parse command line options. */ #ifndef __options_h__ #define __options_h__ #include #include "platform.h" #include "FAT_fs.h" #include "stringlist.h" extern u_int32_t OPT_VERSION, OPT_HELP, OPT_INFO, OPT_QUIET, OPT_IGNORE_CASE, OPT_ORDER, OPT_LIST, OPT_REVERSE, OPT_FORCE, OPT_NATURAL_SORT, OPT_RECURSIVE, OPT_RANDOM, OPT_MORE_INFO, OPT_MODIFICATION, OPT_ASCII; extern struct sStringList *OPT_INCL_DIRS, *OPT_EXCL_DIRS, *OPT_INCL_DIRS_REC, *OPT_EXCL_DIRS_REC, *OPT_IGNORE_PREFIXES_LIST; // parses command line options int32_t parse_options(int argc, char *argv[]); // evaluate whether str matches the include an exclude dir path lists or not int32_t matchesDirPathLists(struct sStringList *includes, struct sStringList *includes_recursion, struct sStringList *excludes, struct sStringList *excludes_recursion, const char (*str)[MAX_PATH_LEN+1]); // free options void freeOptions(); #endif // __options_h__ fatsort-1.3.365/src/errors.h0000664000175000017500000000247412321036670015146 0ustar feanorfeanor/* FATSort, utility for sorting FAT directory structures Copyright (C) 2004 Boris Leidner This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /* This file contains/describes functions for error handling and messaging. */ #ifndef __errors_h__ #define __errors_h__ #include #include // macros #if DEBUG >= 1 #define DEBUGMSG(msg...) errormsg("DEBUG", msg); #else #define DEBUGMSG(msg...) #endif #define myerror(msg...) errormsg(__func__, msg); #define stderror() errormsg(__func__, "%s!", strerror(errno)); // error messages with function name and argument list void errormsg(const char *func, const char *str, ...); #endif // __errors_h__ fatsort-1.3.365/src/signal.h0000664000175000017500000000224212321036670015100 0ustar feanorfeanor/* FATSort, utility for sorting FAT directory structures Copyright (C) 2004 Boris Leidner This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /* This file contains/describes function for signal handling. */ #ifndef __signal_h__ #define __signal_h__ // initialize signal handling for critical sections void init_signal_handling(void); // blocks signals for critical section void start_critical_section(void); // unblocks signals after critical section void end_critical_section(void); #endif // __signal_h__ fatsort-1.3.365/src/platform.h0000664000175000017500000000226412321036670015453 0ustar feanorfeanor/* FATSort, utility for sorting FAT directory structures Copyright (C) 2004 Boris Leidner This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /* This file contains platform dependend macros. */ #ifndef __platform_h__ #define __platform_h__ #if defined(linux) || defined(__linux) || defined(__linux__) #undef __LINUX__ #define __LINUX__ 1 #elif defined(__FreeBSD__) || defined(__DragonFly__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__APPLE__) #undef __BSD__ #define __BSD__ 1 #endif #endif // __platform_h__ fatsort-1.3.365/src/clusterchain.c0000664000175000017500000000426112321036670016305 0ustar feanorfeanor/* FATSort, utility for sorting FAT directory structures Copyright (C) 2004 Boris Leidner This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /* This file contains/describes the cluster chain ADO with its structures and functions. Cluster chain ADOs hold a linked list of cluster numbers. Together all clusters in a cluster chain hold the date of a file or a directory in a FAT filesystem. */ #include "clusterchain.h" #include #include #include #include "errors.h" #include "mallocv.h" // const struct sClusterChain __INITCLUSTERCHAIN__ = {0, NULL}; struct sClusterChain *newClusterChain(void) { /* create new cluster chain */ struct sClusterChain *tmp; if ((tmp=malloc(sizeof(struct sClusterChain)))==NULL) { stderror(); return NULL; } tmp->cluster=0; tmp->next=NULL; return tmp; } int32_t insertCluster(struct sClusterChain *chain, u_int32_t cluster) { /* allocate memory and insert cluster into cluster chain */ assert(chain != NULL); while (chain->next != NULL) { if (chain->cluster == cluster) { myerror("Loop in cluster chain detected (%08lx)!", cluster); return -1; } chain=chain->next; } if ((chain->next = malloc(sizeof(struct sClusterChain))) == NULL) { stderror(); return -1; } chain->next->cluster=cluster; chain->next->next=NULL; return 0; } void freeClusterChain(struct sClusterChain *chain) { /* free cluster chain */ assert(chain != NULL); struct sClusterChain *tmp; while(chain != NULL) { tmp=chain; chain=chain->next; free(tmp); } } fatsort-1.3.365/src/sort.c0000664000175000017500000005256112321036670014616 0ustar feanorfeanor/* FATSort, utility for sorting FAT directory structures Copyright (C) 2004 Boris Leidner This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /* This file contains/describes functions for sorting of FAT filesystems. */ #include "sort.h" #include "platform.h" #include #include #include #include #include #include #include #include "entrylist.h" #include "errors.h" #include "options.h" #include "endianness.h" #include "clusterchain.h" #include "signal.h" #include "misc.h" #include "fileio.h" #include "platform.h" #include "stringlist.h" #include "mallocv.h" int32_t parseLongFilenamePart(struct sLongDirEntry *lde, char *str, iconv_t cd) { /* retrieves a part of a long filename from a directory entry (thanks to M$ for this ugly hack...) */ assert(lde != NULL); assert(str != NULL); size_t incount; size_t outcount; char *outptr = &(str[0]); char utf16str[28]; char *inptr=&(utf16str[0]); size_t ret; str[0]='\0'; memcpy(utf16str, (&lde->LDIR_Ord+1), 10); memcpy(utf16str+10, (&lde->LDIR_Ord+14), 12); memcpy(utf16str+22, (&lde->LDIR_Ord+28), 4); memset(utf16str+26, 0, 2); incount=26; outcount=MAX_PATH_LEN; int i; for (i=0;i<12; i++) { if ((utf16str[i*2] == '\0') && (utf16str[i*2+1] == '\0')) { incount=i*2; break; } } //printf("Incount: %u\n", incount); while (incount != 0) { if ((ret=iconv(cd, &inptr, &incount, &outptr, &outcount)) == (size_t)-1) { stderror(); myerror("iconv failed! %d", ret); return -1; } } outptr[0]='\0'; return 0; } void parseShortFilename(struct sShortDirEntry *sde, char *str) { /* parses short name of a file */ assert(sde != NULL); assert(str != NULL); char *s; strncpy(str, sde->DIR_Name, 8); str[8]='\0'; s=strchr(str, ' '); if (s!=NULL) s[0]='\0'; if ((char)(*(sde->DIR_Name+8)) != ' ') { strcat(str, "."); strncat(str, sde->DIR_Name+8, 3); str[12]='\0'; } } int32_t checkLongDirEntries(struct sDirEntryList *list) { /* does some integrity checks on LongDirEntries */ assert(list != NULL); u_char calculatedChecksum; u_int32_t i; u_int32_t nr; struct sLongDirEntryList *tmp; if (list->entries > 1) { calculatedChecksum = calculateChecksum(list->sde->DIR_Name); if ((list->ldel->lde->LDIR_Ord != DE_FREE) && // ignore deleted entries !(list->ldel->lde->LDIR_Ord & LAST_LONG_ENTRY)) { myerror("LongDirEntry should be marked as last long dir entry but isn't!"); return -1; } tmp = list->ldel; for(i=0;i < list->entries - 1; i++) { if (tmp->lde->LDIR_Ord != DE_FREE) { // ignore deleted entries nr=tmp->lde->LDIR_Ord & ~LAST_LONG_ENTRY; // index of long dir entry //fprintf(stderr, "Debug: count=%x, LDIR_Ord=%x\n", list->entries - 1 -i, tmp->lde->LDIR_Ord); if (nr != (list->entries - 1 - i)) { myerror("LongDirEntry number is 0x%x (0x%x) but should be 0x%x!", nr, tmp->lde->LDIR_Ord, list->entries - 1 - i ); return -1; } else if (tmp->lde->LDIR_Checksum != calculatedChecksum) { myerror("Checksum for LongDirEntry is 0x%x but should be 0x%x!", tmp->lde->LDIR_Checksum, calculatedChecksum); return -1; } } tmp = tmp->next; } } return 0; } int32_t parseClusterChain(struct sFileSystem *fs, struct sClusterChain *chain, struct sDirEntryList *list, u_int32_t *direntries) { /* parses a cluster chain and puts found directory entries to list */ assert(fs != NULL); assert(chain != NULL); assert(list != NULL); assert(direntries != NULL); u_int32_t j; int32_t ret; u_int32_t entries=0; union sDirEntry de; struct sDirEntryList *lnde; struct sLongDirEntryList *llist; char tmp[MAX_PATH_LEN+1], dummy[MAX_PATH_LEN+1], sname[MAX_PATH_LEN+1], lname[MAX_PATH_LEN+1]; *direntries=0; chain=chain->next; // head element llist = NULL; lname[0]='\0'; while (chain != NULL) { fs_seek(fs->fd, getClusterOffset(fs, chain->cluster), SEEK_SET); for (j=0;jmaxDirEntriesPerCluster;j++) { entries++; ret=parseEntry(fs, &de); switch(ret) { case -1: myerror("Failed to parse directory entry!"); return -1; case 0: // current dir entry and following dir entries are free if (llist != NULL) { // short dir entry is still missing! myerror("ShortDirEntry is missing after LongDirEntries (cluster: %08lx, entry %u)!", chain->cluster, j); return -1; } else { return 0; } case 1: // short dir entry parseShortFilename(&de.ShortDirEntry, sname); if (OPT_LIST && strcmp(sname, ".") && strcmp(sname, "..") && (((u_char) sname[0]) != DE_FREE) && !(de.ShortDirEntry.DIR_Atrr & ATTR_VOLUME_ID)) { if (!OPT_MORE_INFO) { printf("%s\n", (lname[0] != '\0') ? lname : sname); } else { printf("%s (%s)\n", (lname[0] != '\0') ? lname : "n/a", sname); } } lnde=newDirEntry(sname, lname, &de.ShortDirEntry, llist, entries); if (lnde == NULL) { myerror("Failed to create DirEntry!"); return -1; } if (checkLongDirEntries(lnde)) { myerror("checkDirEntry failed in cluster %08lx at entry %u!", chain->cluster, j); return -1; } insertDirEntryList(lnde, list); (*direntries)++; entries=0; llist = NULL; lname[0]='\0'; break; case 2: // long dir entry if (parseLongFilenamePart(&de.LongDirEntry, tmp, fs->cd)) { myerror("Failed to parse long filename part!"); return -1; } // insert long dir entry in list llist=insertLongDirEntryList(&de.LongDirEntry, llist); if (llist == NULL) { myerror("Failed to insert LongDirEntry!"); return -1; } strncpy(dummy, tmp, MAX_PATH_LEN); dummy[MAX_PATH_LEN]='\0'; strncat(dummy, lname, MAX_PATH_LEN - strlen(dummy)); dummy[MAX_PATH_LEN]='\0'; strncpy(lname, dummy, MAX_PATH_LEN); dummy[MAX_PATH_LEN]='\0'; break; default: myerror("Unhandled return code!"); return -1; } } chain=chain->next; } if (llist != NULL) { // short dir entry is still missing! myerror("ShortDirEntry is missing after LongDirEntries (root directory entry %d)!", j); return -1; } return 0; } int32_t parseFAT1xRootDirEntries(struct sFileSystem *fs, struct sDirEntryList *list, u_int32_t *direntries) { /* parses FAT1x root directory entries to list */ assert(fs != NULL); assert(list != NULL); assert(direntries != NULL); off_t BSOffset; int32_t j, ret; u_int32_t entries=0; union sDirEntry de; struct sDirEntryList *lnde; struct sLongDirEntryList *llist; char tmp[MAX_PATH_LEN+1], dummy[MAX_PATH_LEN+1], sname[MAX_PATH_LEN+1], lname[MAX_PATH_LEN+1]; *direntries=0; llist = NULL; lname[0]='\0'; BSOffset = ((off_t)SwapInt16(fs->bs.BS_RsvdSecCnt) + fs->bs.BS_NumFATs * fs->FATSize) * fs->sectorSize; fs_seek(fs->fd, BSOffset, SEEK_SET); for (j=0;jbs.BS_RootEntCnt);j++) { entries++; ret=parseEntry(fs, &de); switch(ret) { case -1: myerror("Failed to parse directory entry!"); return -1; case 0: // current dir entry and following dir entries are free if (llist != NULL) { // short dir entry is still missing! myerror("ShortDirEntry is missing after LongDirEntries (root directory entry %u)!", j); return -1; } else { return 0; } case 1: // short dir entry parseShortFilename(&de.ShortDirEntry, sname); if (OPT_LIST && strcmp(sname, ".") && strcmp(sname, "..") && (((u_char) sname[0]) != DE_FREE) && !(de.ShortDirEntry.DIR_Atrr & ATTR_VOLUME_ID)) { if (!OPT_MORE_INFO) { printf("%s\n", (lname[0] != '\0') ? lname : sname); } else { printf("%s (%s)\n", (lname[0] != '\0') ? lname : "n/a", sname); } } lnde=newDirEntry(sname, lname, &de.ShortDirEntry, llist, entries); if (lnde == NULL) { myerror("Failed to create DirEntry!"); return -1; } if (checkLongDirEntries(lnde)) { myerror("checkDirEntry failed at root directory entry %u!", j); return -1; } insertDirEntryList(lnde, list); (*direntries)++; entries=0; llist = NULL; lname[0]='\0'; break; case 2: // long dir entry if (parseLongFilenamePart(&de.LongDirEntry, tmp, fs->cd)) { myerror("Failed to parse long filename part!"); return -1; } // insert long dir entry in list llist=insertLongDirEntryList(&de.LongDirEntry, llist); if (llist == NULL) { myerror("Failed to insert LongDirEntry!"); return -1; } strncpy(dummy, tmp, MAX_PATH_LEN); dummy[MAX_PATH_LEN]='\0'; strncat(dummy, lname, MAX_PATH_LEN - strlen(dummy)); dummy[MAX_PATH_LEN]='\0'; strncpy(lname, dummy, MAX_PATH_LEN); dummy[MAX_PATH_LEN]='\0'; break; default: myerror("Unhandled return code!"); return -1; } } if (llist != NULL) { // short dir entry is still missing! myerror("ShortDirEntry is missing after LongDirEntries (root dir entry %d)!", j); return -1; } return 0; } int32_t writeList(struct sFileSystem *fs, struct sDirEntryList *list) { /* writes directory entries to file */ assert(fs != NULL); assert(list != NULL); struct sLongDirEntryList *tmp; // no signal handling while writing (atomic action) start_critical_section(); while(list->next!=NULL) { tmp=list->next->ldel; while(tmp != NULL) { if (fs_write(tmp->lde, DIR_ENTRY_SIZE, 1, fs->fd)<1) { // end of critical section end_critical_section(); stderror(); return -1; } tmp=tmp->next; } if (fs_write(list->next->sde, DIR_ENTRY_SIZE, 1, fs->fd)<1) { // end of critical section end_critical_section(); stderror(); return -1; } list=list->next; } // sync fs syncFileSystem(fs); // end of critical section end_critical_section(); return 0; } int32_t getClusterChain(struct sFileSystem *fs, u_int32_t startCluster, struct sClusterChain *chain) { /* retrieves an array of all clusters in a cluster chain starting with startCluster */ assert(fs != NULL); assert(chain != NULL); int32_t cluster; u_int32_t data,i=0; cluster=startCluster; switch(fs->FATType) { case FATTYPE_FAT12: do { if (i == fs->maxClusterChainLength) { myerror("Cluster chain is too long!"); return -1; } if (cluster >= fs->clusters+2) { myerror("Cluster %08x does not exist!", data); return -1; } if (insertCluster(chain, cluster) == -1) { myerror("Failed to insert cluster!"); return -1; } i++; if (getFATEntry(fs, cluster, &data)) { myerror("Failed to get FAT entry!"); return -1; } if (data == 0) { myerror("Cluster %08x is marked as unused!", cluster); return -1; } cluster=data; } while (cluster < 0x0ff8); // end of cluster break; case FATTYPE_FAT16: do { if (i == fs->maxClusterChainLength) { myerror("Cluster chain is too long!"); return -1; } if (cluster >= fs->clusters+2) { myerror("Cluster %08x does not exist!", data); return -1; } if (insertCluster(chain, cluster) == -1) { myerror("Failed to insert cluster!"); return -1; } i++; if (getFATEntry(fs, cluster, &data)) { myerror("Failed to get FAT entry!"); return -1; } if (data == 0) { myerror("Cluster %08x is marked as unused!", cluster); return -1; } cluster=data; } while (cluster < 0xfff8); // end of cluster break; case FATTYPE_FAT32: do { if (i == fs->maxClusterChainLength) { myerror("Cluster chain is too long!"); return -1; } if ((cluster & 0x0fffffff) >= fs->clusters+2) { myerror("Cluster %08x does not exist!", data); return -1; } if (insertCluster(chain, cluster) == -1) { myerror("Failed to insert cluster!"); return -1; } i++; if (getFATEntry(fs, cluster, &data)) { myerror("Failed to get FAT entry"); return -1; } if ((data & 0x0fffffff) == 0) { myerror("Cluster %08x is marked as unused!", cluster); return -1; } cluster=data; } while (((cluster & 0x0fffffff) != 0x0ff8fff8) && ((cluster & 0x0fffffff) < 0x0ffffff8)); // end of cluster break; case -1: default: myerror("Failed to get FAT type!"); return -1; } return i; } int32_t writeClusterChain(struct sFileSystem *fs, struct sDirEntryList *list, struct sClusterChain *chain) { /* writes all entries from list to the cluster chain */ assert(fs != NULL); assert(list != NULL); assert(chain != NULL); u_int32_t i=0, entries=0; struct sLongDirEntryList *tmp; struct sDirEntryList *p=list->next; char empty[DIR_ENTRY_SIZE]={0}; chain=chain->next; // we don't need to look at the head element if (fs_seek(fs->fd, getClusterOffset(fs, chain->cluster), SEEK_SET)==-1) { myerror("Seek error!"); return -1; } // no signal handling while writing (atomic action) start_critical_section(); while(p != NULL) { if (entries+p->entries <= fs->maxDirEntriesPerCluster) { tmp=p->ldel; for (i=1;ientries;i++) { if (fs_write(tmp->lde, DIR_ENTRY_SIZE, 1, fs->fd)<1) { // end of critical section end_critical_section(); stderror(); return -1; } tmp=tmp->next; } if (fs_write(p->sde, DIR_ENTRY_SIZE, 1, fs->fd)<1) { // end of critical section end_critical_section(); stderror(); return -1; } entries+=p->entries; } else { tmp=p->ldel; for (i=1;i<=fs->maxDirEntriesPerCluster-entries;i++) { if (fs_write(tmp->lde, DIR_ENTRY_SIZE, 1, fs->fd)<1) { // end of critical section end_critical_section(); stderror(); return -1; } tmp=tmp->next; } chain=chain->next; entries=p->entries - (fs->maxDirEntriesPerCluster - entries); // next cluster if (fs_seek(fs->fd, getClusterOffset(fs, chain->cluster), SEEK_SET)==-1) { // end of critical section end_critical_section(); myerror("Seek error!"); return -1; } while(tmp!=NULL) { if (fs_write(tmp->lde, DIR_ENTRY_SIZE, 1, fs->fd)<1) { // end of critical section end_critical_section(); stderror(); return -1; } tmp=tmp->next; } if (fs_write(p->sde, DIR_ENTRY_SIZE, 1, fs->fd)<1) { // end of critical section end_critical_section(); stderror(); return -1; } } p=p->next; } if (entries < fs->maxDirEntriesPerCluster) { if (fs_write(empty, DIR_ENTRY_SIZE, 1, fs->fd)<1) { // end of critical section end_critical_section(); stderror(); return -1; } } // sync fs syncFileSystem(fs); // end of critical section end_critical_section(); return 0; } int32_t sortSubdirectories(struct sFileSystem *fs, struct sDirEntryList *list, const char (*path)[MAX_PATH_LEN+1]) { /* sorts sub directories in a FAT file system */ assert(fs != NULL); assert(list != NULL); assert(path != NULL); struct sDirEntryList *p; char newpath[MAX_PATH_LEN+1]={0}; u_int32_t c, value; // sort sub directories p=list->next; while (p != NULL) { if ((p->sde->DIR_Atrr & ATTR_DIRECTORY) && ((u_char) p->sde->DIR_Name[0] != DE_FREE) && !(p->sde->DIR_Atrr & ATTR_VOLUME_ID) && (strcmp(p->sname, ".")) && strcmp(p->sname, "..")) { c=(SwapInt16(p->sde->DIR_FstClusHI) * 65536 + SwapInt16(p->sde->DIR_FstClusLO)); if (getFATEntry(fs, c, &value) == -1) { myerror("Failed to get FAT entry!"); return -1; } strncpy(newpath, (char*) path, MAX_PATH_LEN - strlen(newpath)); newpath[MAX_PATH_LEN]='\0'; if ((p->lname != NULL) && (p->lname[0] != '\0')) { strncat(newpath, p->lname, MAX_PATH_LEN - strlen(newpath)); newpath[MAX_PATH_LEN]='\0'; strncat(newpath, "/", MAX_PATH_LEN - strlen(newpath)); newpath[MAX_PATH_LEN]='\0'; } else { strncat(newpath, p->sname, MAX_PATH_LEN - strlen(newpath)); newpath[MAX_PATH_LEN]='\0'; strncat(newpath, "/", MAX_PATH_LEN - strlen(newpath)); newpath[MAX_PATH_LEN]='\0'; } if (sortClusterChain(fs, c, (const char(*)[MAX_PATH_LEN+1]) newpath) == -1) { myerror("Failed to sort cluster chain!"); return -1; } } p=p->next; } return 0; } int32_t sortClusterChain(struct sFileSystem *fs, u_int32_t cluster, const char (*path)[MAX_PATH_LEN+1]) { /* sorts directory entries in a cluster */ assert(fs != NULL); assert(path != NULL); u_int32_t direntries; int32_t clen; struct sClusterChain *ClusterChain; struct sDirEntryList *list; u_int32_t match; match=matchesDirPathLists(OPT_INCL_DIRS, OPT_INCL_DIRS_REC, OPT_EXCL_DIRS, OPT_EXCL_DIRS_REC, path); if ((ClusterChain=newClusterChain()) == NULL) { myerror("Failed to generate new ClusterChain!"); return -1; } if ((list = newDirEntryList()) == NULL) { myerror("Failed to generate new dirEntryList!"); freeClusterChain(ClusterChain); return -1; } if ((clen=getClusterChain(fs, cluster, ClusterChain)) == -1 ) { myerror("Failed to get cluster chain!"); freeDirEntryList(list); freeClusterChain(ClusterChain); return -1; } if (!OPT_LIST) { if (match) { infomsg("Sorting directory %s\n", path); if (OPT_MORE_INFO) infomsg("Start cluster: %08lx, length: %d (%d bytes)\n", cluster, clen, clen*fs->clusterSize); } } else { printf("%s\n", (char*) path); if (OPT_MORE_INFO) infomsg("Start cluster: %08lx, length: %d (%d bytes)\n", cluster, clen, clen*fs->clusterSize); } if (parseClusterChain(fs, ClusterChain, list, &direntries) == -1) { myerror("Failed to parse cluster chain!"); freeDirEntryList(list); freeClusterChain(ClusterChain); return -1; } if (!OPT_LIST) { // sort directory if selected if (match) { if (OPT_RANDOM) randomizeDirEntryList(list, direntries); if (writeClusterChain(fs, list, ClusterChain) == -1) { myerror("Failed to write cluster chain!"); freeDirEntryList(list); freeClusterChain(ClusterChain); return -1; } } } else { printf("\n"); } freeClusterChain(ClusterChain); // sort subdirectories if (sortSubdirectories(fs, list, path) == -1 ){ myerror("Failed to sort subdirectories!"); return -1; } freeDirEntryList(list); return 0; } int32_t sortFAT1xRootDirectory(struct sFileSystem *fs) { /* sorts the root directory of a FAT12 or FAT16 file system */ assert(fs != NULL); off_t BSOffset; u_int32_t direntries=0; struct sDirEntryList *list; u_int32_t match; match=matchesDirPathLists(OPT_INCL_DIRS, OPT_INCL_DIRS_REC, OPT_EXCL_DIRS, OPT_EXCL_DIRS_REC, (const char(*)[MAX_PATH_LEN+1]) "/"); if (!OPT_LIST) { if (match) { infomsg("Sorting directory /\n"); } } else { printf("/\n"); } if ((list = newDirEntryList()) == NULL) { myerror("Failed to generate new dirEntryList!"); return -1; } if (parseFAT1xRootDirEntries(fs, list, &direntries) == -1) { myerror("Failed to parse root directory entries!"); return -1; } if (!OPT_LIST) { // sort matching directories if (match) { if (OPT_RANDOM) randomizeDirEntryList(list, direntries); BSOffset = ((off_t)SwapInt16(fs->bs.BS_RsvdSecCnt) + fs->bs.BS_NumFATs * fs->FATSize) * fs->sectorSize; fs_seek(fs->fd, BSOffset, SEEK_SET); // write the sorted entries back to the fs if (writeList(fs, list) == -1) { freeDirEntryList(list); myerror("Failed to write root directory entries!"); return -1; } } } else { printf("\n"); } // sort subdirectories if (sortSubdirectories(fs, list, (const char (*)[MAX_PATH_LEN+1]) "/") == -1 ){ myerror("Failed to sort subdirectories!"); freeDirEntryList(list); return -1; } freeDirEntryList(list); return 0; } int32_t sortFileSystem(char *filename) { /* sort FAT file system */ assert(filename != NULL); u_int32_t mode; struct sFileSystem fs; if (!OPT_FORCE && OPT_LIST) { mode = FS_MODE_RO_EXCL; } else if (!OPT_FORCE && !OPT_LIST) { mode = FS_MODE_RW_EXCL; } else if (OPT_FORCE && OPT_LIST) { mode = FS_MODE_RO; } else { mode = FS_MODE_RW; } if (openFileSystem(filename, mode, &fs)) { myerror("Failed to open file system!"); return -1; } if (checkFATs(&fs)) { myerror("FATs don't match! Please repair file system!"); closeFileSystem(&fs); return -1; } switch(fs.FATType) { case FATTYPE_FAT12: // FAT12 // root directory has fixed size and position infomsg("File system: FAT12.\n\n"); if (sortFAT1xRootDirectory(&fs) == -1) { myerror("Failed to sort FAT12 root directory!"); closeFileSystem(&fs); return -1; } break; case FATTYPE_FAT16: // FAT16 // root directory has fixed size and position infomsg("File system: FAT16.\n\n"); if (sortFAT1xRootDirectory(&fs) == -1) { myerror("Failed to sort FAT16 root directory!"); closeFileSystem(&fs); return -1; } break; case FATTYPE_FAT32: // FAT32 // root directory lies in cluster chain, // so sort it like all other directories infomsg("File system: FAT32.\n\n"); if (sortClusterChain(&fs, SwapInt32(fs.bs.FATxx.FAT32.BS_RootClus), (const char(*)[MAX_PATH_LEN+1]) "/") == -1) { myerror("Failed to sort first cluster chain!"); closeFileSystem(&fs); return -1; } break; default: myerror("Failed to get FAT type!"); closeFileSystem(&fs); return -1; } closeFileSystem(&fs); return 0; } fatsort-1.3.365/src/options.c0000664000175000017500000001724612321036670015323 0ustar feanorfeanor/* FATSort, utility for sorting FAT directory structures Copyright (C) 2004 Boris Leidner This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /* This file contains/describes functions that parse command line options. */ #include "options.h" #include #include #include #include "errors.h" #include "stringlist.h" #include "mallocv.h" u_int32_t OPT_VERSION, OPT_HELP, OPT_INFO, OPT_QUIET, OPT_IGNORE_CASE, OPT_ORDER, OPT_LIST, OPT_REVERSE, OPT_FORCE, OPT_NATURAL_SORT, OPT_RECURSIVE, OPT_RANDOM, OPT_MORE_INFO, OPT_MODIFICATION, OPT_ASCII; struct sStringList *OPT_INCL_DIRS = NULL; struct sStringList *OPT_EXCL_DIRS = NULL; struct sStringList *OPT_INCL_DIRS_REC = NULL; struct sStringList *OPT_EXCL_DIRS_REC = NULL; struct sStringList *OPT_IGNORE_PREFIXES_LIST = NULL; int32_t addDirPathToStringList(struct sStringList *stringList, const char (*str)[MAX_PATH_LEN+1]) { /* insert new string into string list */ assert(stringList != NULL); assert(stringList->str == NULL); assert(str != NULL); assert(strlen((char *)str) <= MAX_PATH_LEN); char *newStr; int32_t ret, prefix=0, suffix=0, len; len=strlen((char*)str); // determine whether we have to add slashes if (((const char*) str)[0] != '/') prefix=1; if (((const char*) str)[len-1] != '/') suffix=1; // allocate memory for string newStr=malloc(prefix+len+suffix+1); if (newStr == NULL) { stderror(); return -1; } // copy string to new structure including missing slashes newStr[0] = '\0'; strncat(newStr, "/", prefix); strncat(newStr, (const char*) str, len); strncat(newStr, "/", suffix); if (prefix+len+suffix > MAX_PATH_LEN) { newStr[MAX_PATH_LEN] = '\0'; } else { newStr[prefix+len+suffix] = '\0'; } ret = addStringToStringList(stringList, newStr); free(newStr); return ret; } int32_t matchesDirPathLists(struct sStringList *includes, struct sStringList *includes_recursion, struct sStringList *excludes, struct sStringList *excludes_recursion, const char (*str)[MAX_PATH_LEN+1]) { /* evaluate whether str matches the include an exclude dir path lists or not */ int32_t incl, incl_rec, excl, excl_rec; incl=matchesStringList(includes, (const char*) str); incl_rec=matchesStringList(includes_recursion, (const char*) str); excl=matchesStringList(excludes, (const char*) str); excl_rec=matchesStringList(excludes_recursion, (const char*) str); // debug("str=%s,incl=%d,inclrec=%d,excl=%d,exclrec=%d", str, incl, incl_rec, excl, excl_rec); // if no options -d and -D are used if ((includes->next==NULL) && (includes_recursion->next==NULL)) { // match all directories except those are supplied via -x // and those and subdirs that are supplied via -X if ((excl != RETURN_EXACT_MATCH) && (excl_rec == RETURN_NO_MATCH)) { return 1; // match } // if options -d and -D are used } else { // match all dirs that are supplied via -d, and all dirs and subdirs that are supplied via -D, // except those that excplicitly excluded via -x, or those and their subdirs that are supplied via -X if (((incl == RETURN_EXACT_MATCH) || (incl_rec != RETURN_NO_MATCH)) && (excl != RETURN_EXACT_MATCH) && (excl_rec == RETURN_NO_MATCH)) { return 1; // match } } return 0; // no match } int32_t parse_options(int argc, char *argv[]) { /* parses command line options */ int8_t c; static struct option longOpts[] = { // name, has_arg, flag, val {"help", 0, 0, 'h'}, {"version", 0, 0, 'v'}, {0, 0, 0, 0} }; // no info by default OPT_INFO = 0; OPT_MORE_INFO = 0; /* Default (1) is normal order, use -1 for reverse order. */ OPT_REVERSE = 1; // natural sort OPT_NATURAL_SORT = 0; // random sort order OPT_RANDOM = 0; // default order (directories first) OPT_ORDER = 0; // default is case sensitive OPT_IGNORE_CASE = 0; // be noisy by default OPT_QUIET = 0; // no version information by default OPT_VERSION = 0; // sort by last modification time OPT_MODIFICATION = 0; // sort by using locale collation order OPT_ASCII = 0; // empty string lists for inclusion and exclusion of dirs if ((OPT_INCL_DIRS=newStringList()) == NULL) { myerror("Could not create stringList!"); return -1; } if ((OPT_INCL_DIRS_REC=newStringList()) == NULL) { myerror("Could not create stringList!"); freeOptions(); return -1; } if ((OPT_EXCL_DIRS=newStringList()) == NULL) { myerror("Could not create stringList!"); freeOptions(); return -1; } if ((OPT_EXCL_DIRS_REC=newStringList()) == NULL) { myerror("Could not create stringList!"); freeOptions(); return -1; } // empty string list for to be ignored prefixes if ((OPT_IGNORE_PREFIXES_LIST=newStringList()) == NULL) { myerror("Could not create stringList!"); freeOptions(); return -1; } opterr=0; while ((c=getopt_long(argc, argv, "imvhqcfo:lrRnd:D:x:X:I:ta", longOpts, NULL)) != -1) { switch(c) { case 'a' : OPT_ASCII = 1; break; case 'c' : OPT_IGNORE_CASE = 1; break; case 'f' : OPT_FORCE = 1; break; case 'h' : OPT_HELP = 1; break; case 'i' : OPT_INFO = 1; break; case 'm' : OPT_MORE_INFO = 1; break; case 'l' : OPT_LIST = 1; break; case 'o' : switch(optarg[0]) { case 'd': OPT_ORDER=0; break; case 'f': OPT_ORDER=1; break; case 'a': OPT_ORDER=2; break; default: myerror("Unknown flag '%c' for option 'o'.", optarg[0]); myerror("Use -h for more help."); freeOptions(); return -1; } break; case 'd' : if (addDirPathToStringList(OPT_INCL_DIRS, (const char(*)[MAX_PATH_LEN+1]) optarg)) { myerror("Could not add directory path to dirPathList"); freeOptions(); return -1; } break; case 'D' : if (addDirPathToStringList(OPT_INCL_DIRS_REC, (const char(*)[MAX_PATH_LEN+1]) optarg)) { myerror("Could not add directory path to string list"); freeOptions(); return -1; } break; case 'x' : if (addDirPathToStringList(OPT_EXCL_DIRS, (const char(*)[MAX_PATH_LEN+1]) optarg)) { myerror("Could not add directory path to string list"); freeOptions(); return -1; } break; case 'X' : if (addDirPathToStringList(OPT_EXCL_DIRS_REC, (const char(*)[MAX_PATH_LEN+1]) optarg)) { myerror("Could not add directory path to string list"); freeOptions(); return -1; } break; case 'I' : if (addStringToStringList(OPT_IGNORE_PREFIXES_LIST, optarg)) { myerror("Could not add directory path to string list"); freeOptions(); return -1; } break; case 'n' : OPT_NATURAL_SORT = 1; break; case 'q' : OPT_QUIET = 1; break; case 'r' : OPT_REVERSE = -1; break; case 'R' : OPT_RANDOM = 1; break; case 't' : OPT_MODIFICATION = 1; break; case 'v' : OPT_VERSION = 1; break; default : myerror("Unknown option '%c'.", optopt); myerror("Use -h for more help."); freeOptions(); return -1; } } return 0; } void freeOptions() { freeStringList(OPT_INCL_DIRS); freeStringList(OPT_INCL_DIRS_REC); freeStringList(OPT_EXCL_DIRS); freeStringList(OPT_EXCL_DIRS_REC); freeStringList(OPT_IGNORE_PREFIXES_LIST); } fatsort-1.3.365/src/entrylist.h0000664000175000017500000000456612321036670015673 0ustar feanorfeanor/* FATSort, utility for sorting FAT directory structures Copyright (C) 2004 Boris Leidner This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /* This file contains/describes some ADOs which are used to represent the structures of FAT directory entries and entry lists. */ #ifndef __entrylist_h__ #define __entrylist_h__ #include #include "FAT_fs.h" struct sLongDirEntryList { /* list structures for directory entries list structure for a long name entry */ struct sLongDirEntry *lde; struct sLongDirEntryList *next; }; struct sDirEntryList { /* list structure for every file with short name entries and long name entries */ char *sname, *lname; // short and long name strings struct sShortDirEntry *sde; // short dir entry struct sLongDirEntryList *ldel; // long name entries in a list u_int32_t entries; // number of entries struct sDirEntryList *next; // next dir entry }; // create new dir entry list struct sDirEntryList * newDirEntryList(void); // randomize entry list void randomizeDirEntryList(struct sDirEntryList *list, u_int32_t entries); // create a new directory entry holder struct sDirEntryList * newDirEntry(char *sname, char *lname, struct sShortDirEntry *sde, struct sLongDirEntryList *ldel, u_int32_t entries); // insert a long directory entry to list struct sLongDirEntryList * insertLongDirEntryList(struct sLongDirEntry *lde, struct sLongDirEntryList *list); // compare two directory entries int32_t cmpEntries(struct sDirEntryList *de1, struct sDirEntryList *de2); // insert a directory entry into list void insertDirEntryList(struct sDirEntryList *new, struct sDirEntryList *list); // free dir entry list void freeDirEntryList(struct sDirEntryList *list); #endif // __entrylist_h__ fatsort-1.3.365/tests/0000775000175000017500000000000012321036670014025 5ustar feanorfeanorfatsort-1.3.365/tests/tc_neg_bad_checksum_in_lne/0000775000175000017500000000000012321036667021306 5ustar feanorfeanorfatsort-1.3.365/tests/tc_neg_bad_checksum_in_lne/files.txt0000664000175000017500000000012412321036667023146 0ustar feanorfeanorlong_filename___________________________1 long_filename___________________________2 fatsort-1.3.365/tests/tc_neg_bad_checksum_in_lne/Makefile0000775000175000017500000000375512321036667022763 0ustar feanorfeanorinclude ../testconfig.mk FS_FATType=32 # 100 MiBytes FS_SIZE=100 FS_FATs=2 FS_VOL_NAME=test FS_ROOT_ENTRIES=512 FS_RSVD_SEC=32 FS_SEC_PER_CLUS=1 FS_SEC_SIZE=512 DIRECTORIES=directories.txt FILES=files.txt TESTLOG=test.log STDOUT=stdout.log STDOUT_EXP=stdout_expected.txt STDERR=stderr.log STDERR_EXP=stderr_expected.txt # no fsck in negative tests all: execute if [ ${DEL_FS_ON_PASS} -eq 1 ]; then rm -f ${FS_IMG}; fi clean: rm -fr *.log *.tmp ${FS_IMG} ${TMPFILE} ${TMPDIR} if [ -d ${MOUNT_POINT} ]; then \ until sudo umount ${MOUNT_POINT}; do sleep 1; done; \ rmdir ${MOUNT_POINT}; \ fi # create file system mkfs: # ++++++++++ Creating file ${FATType} system ++++++++++ rm -f ${FS_IMG} truncate -s ${FS_SIZE}MB ${FS_IMG} mkfs.vfat -F ${FS_FATType} -f ${FS_FATs} -n ${FS_VOL_NAME} -r ${FS_ROOT_ENTRIES} -R ${FS_RSVD_SEC} -s ${FS_SEC_PER_CLUS} -S ${FS_SEC_SIZE} ${FS_IMG} # populate fs populatefs: mkfs # ++++++++++ Populating file system with directories and files ++++++++++ mkdir -p ${MOUNT_POINT} sudo mount -o loop,codepage=850,iocharset=iso8859-1,utf8,uid=${MOUNT_UID},gid=${MOUNT_GID} ${FS_IMG} ${MOUNT_POINT} cat ${DIRECTORIES} | while read dir; do mkdir -p "${MOUNT_POINT}/$$dir"; done cat ${FILES} | while read file; do touch "${MOUNT_POINT}/$$file"; done rm -f "${MOUNT_POINT}/a" #remove some files rm -f "${MOUNT_POINT}/n" rm -f "${MOUNT_POINT}/z" until sudo umount ${MOUNT_POINT}; do sleep 1; done rmdir ${MOUNT_POINT} # alter file system as necessary for the test alterfs: populatefs # ++++++++++ Altering file system ++++++++++ ${BBE} -b x17bc8d:1 -e "r 0 \x42" ${FS_IMG} > ${TMPFILE} # alter checksum in lne cp -f ${TMPFILE} ${FS_IMG} rm -fr ${TMPFILE} execute: alterfs # ++++++++++ Executing tests ++++++++++ ${FATSORT} ${FS_IMG} > ${STDOUT} 2> ${STDERR}; [ $$? -ne 0 ] diff ${STDOUT} ${STDOUT_EXP} diff ${STDERR} ${STDERR_EXP} # check result fsck: execute # ++++++++++ Checking file system ++++++++++ fsck.vfat -n ${FS_IMG} .PHONY: fsck execute populatefs mkfs clean fatsort-1.3.365/tests/tc_neg_bad_checksum_in_lne/stderr_expected.txt0000664000175000017500000000043212321036667025232 0ustar feanorfeanorcheckLongDirEntries: Checksum for LongDirEntry is 0x42 but should be 0x88! parseClusterChain: checkDirEntry failed in cluster 00000002 at entry 5! sortClusterChain: Failed to parse cluster chain! sortFileSystem: Failed to sort first cluster chain! main: Failed to sort file system! fatsort-1.3.365/tests/tc_neg_bad_checksum_in_lne/stdout_expected.txt0000664000175000017500000000005112321036667025246 0ustar feanorfeanorFile system: FAT32. Sorting directory / fatsort-1.3.365/tests/tc_neg_bad_checksum_in_lne/directories.txt0000664000175000017500000000000012321036667024351 0ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_sort_dir6_fat16/0000775000175000017500000000000012321036667020316 5ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_sort_dir6_fat16/files.txt0000664000175000017500000000064412321036667022165 0ustar feanorfeanorz g u n w e o a c v dir1/z dir1/g dir1/u dir1/n dir1/w dir1/e dir1/o dir1/a dir1/c dir1/v dir2/z dir2/g dir2/u dir2/n dir2/w dir2/e dir2/o dir2/a dir2/c dir2/v dir3/z dir3/g dir3/u dir3/n dir3/w dir3/e dir3/o dir3/a dir3/c dir3/v dir4/z dir4/g dir4/u dir4/n dir4/w dir4/e dir4/o dir4/a dir4/c dir4/v dir4/dir5/z dir4/dir5/g dir4/dir5/u dir4/dir5/n dir4/dir5/w dir4/dir5/e dir4/dir5/o dir4/dir5/a dir4/dir5/c dir4/dir5/v fatsort-1.3.365/tests/tc_pos_sort_dir6_fat16/Makefile0000775000175000017500000000346312321036667021767 0ustar feanorfeanorinclude ../testconfig.mk FS_FATType=16 # MiBytes FS_SIZE=10 FS_FATs=1 FS_VOL_NAME=test FS_ROOT_ENTRIES=512 FS_RSVD_SEC=32 FS_SEC_PER_CLUS=1 FS_SEC_SIZE=512 DIRECTORIES=directories.txt FILES=files.txt TESTLOG=test.log STDOUT=stdout.log STDOUT_EXP=stdout_expected.txt STDERR=stderr.log STDERR_EXP=stderr_expected.txt all: fsck if [ ${DEL_FS_ON_PASS} -eq 1 ]; then rm -f ${FS_IMG}; fi clean: rm -fr *.log *.tmp ${FS_IMG} ${TMPFILE} ${TMPDIR} if [ -d ${MOUNT_POINT} ]; then \ until sudo umount ${MOUNT_POINT}; do sleep 1; done; \ rmdir ${MOUNT_POINT}; \ fi # create file system mkfs: # ++++++++++ Creating file ${FATType} system ++++++++++ rm -f ${FS_IMG} truncate -s ${FS_SIZE}MB ${FS_IMG} mkfs.vfat -F ${FS_FATType} -f ${FS_FATs} -n ${FS_VOL_NAME} -r ${FS_ROOT_ENTRIES} -R ${FS_RSVD_SEC} -s ${FS_SEC_PER_CLUS} -S ${FS_SEC_SIZE} ${FS_IMG} # populate fs populatefs: mkfs # ++++++++++ Populating file system with directories and files ++++++++++ mkdir -p ${MOUNT_POINT} sudo mount -o loop,codepage=850,iocharset=iso8859-1,utf8,uid=${MOUNT_UID},gid=${MOUNT_GID} ${FS_IMG} ${MOUNT_POINT} cat ${DIRECTORIES} | while read dir; do mkdir -p "${MOUNT_POINT}/$$dir"; done cat ${FILES} | while read file; do touch "${MOUNT_POINT}/$$file"; done # delete some files until sudo umount ${MOUNT_POINT}; do sleep 1; done rmdir ${MOUNT_POINT} # alter file system as necessary for the test alterfs: populatefs # ++++++++++ Altering file system ++++++++++ # empty here rm -fr ${TMPFILE} execute: alterfs # ++++++++++ Executing tests ++++++++++ ${FATSORT} -D / -X dir4 ${FS_IMG} ${FATSORT} -l ${FS_IMG} > ${STDOUT} 2> ${STDERR} diff ${STDOUT} ${STDOUT_EXP} diff ${STDERR} ${STDERR_EXP} # check result fsck: execute # ++++++++++ Checking file system ++++++++++ fsck.vfat -n ${FS_IMG} .PHONY: fsck execute populatefs mkfs clean fatsort-1.3.365/tests/tc_pos_sort_dir6_fat16/stderr_expected.txt0000664000175000017500000000000012321036667024231 0ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_sort_dir6_fat16/stdout_expected.txt0000664000175000017500000000032612321036667024263 0ustar feanorfeanorFile system: FAT16. / dir1 dir2 dir3 dir4 a c e g n o u v w z /dir1/ a c e g n o u v w z /dir2/ a c e g n o u v w z /dir3/ a c e g n o u v w z /dir4/ dir5 z g u n w e o a c v /dir4/dir5/ z g u n w e o a c v fatsort-1.3.365/tests/tc_pos_sort_dir6_fat16/directories.txt0000664000175000017500000000003112321036667023365 0ustar feanorfeanordir1 dir2 dir3 dir4/dir5 fatsort-1.3.365/tests/tc_pos_sort_reverse_fat32/0000775000175000017500000000000012321036667021123 5ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_sort_reverse_fat32/files.txt0000664000175000017500000000043112321036667022764 0ustar feanorfeanora b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z Ä Ö Ü file3.bin file2.bin file1.bin Long file name with lots of words and characters just to test long file name entries in FAT file systems 1 2 3 4 5 6 7 8 9 10 01b 1a 001c fatsort-1.3.365/tests/tc_pos_sort_reverse_fat32/Makefile0000775000175000017500000000345212321036667022572 0ustar feanorfeanorinclude ../testconfig.mk FS_FATType=32 # MiBytes FS_SIZE=100 FS_FATs=1 FS_VOL_NAME=test FS_ROOT_ENTRIES=512 FS_RSVD_SEC=32 FS_SEC_PER_CLUS=1 FS_SEC_SIZE=512 DIRECTORIES=directories.txt FILES=files.txt TESTLOG=test.log STDOUT=stdout.log STDOUT_EXP=stdout_expected.txt STDERR=stderr.log STDERR_EXP=stderr_expected.txt all: fsck if [ ${DEL_FS_ON_PASS} -eq 1 ]; then rm -f ${FS_IMG}; fi clean: rm -fr *.log *.tmp ${FS_IMG} ${TMPFILE} ${TMPDIR} if [ -d ${MOUNT_POINT} ]; then \ until sudo umount ${MOUNT_POINT}; do sleep 1; done; \ rmdir ${MOUNT_POINT}; \ fi # create file system mkfs: # ++++++++++ Creating file ${FATType} system ++++++++++ rm -f ${FS_IMG} truncate -s ${FS_SIZE}MB ${FS_IMG} mkfs.vfat -F ${FS_FATType} -f ${FS_FATs} -n ${FS_VOL_NAME} -r ${FS_ROOT_ENTRIES} -R ${FS_RSVD_SEC} -s ${FS_SEC_PER_CLUS} -S ${FS_SEC_SIZE} ${FS_IMG} # populate fs populatefs: mkfs # ++++++++++ Populating file system with directories and files ++++++++++ mkdir -p ${MOUNT_POINT} sudo mount -o loop,codepage=850,iocharset=iso8859-1,utf8,uid=${MOUNT_UID},gid=${MOUNT_GID} ${FS_IMG} ${MOUNT_POINT} cat ${DIRECTORIES} | while read dir; do mkdir -p "${MOUNT_POINT}/$$dir"; done cat ${FILES} | while read file; do touch "${MOUNT_POINT}/$$file"; done # delete some files until sudo umount ${MOUNT_POINT}; do sleep 1; done rmdir ${MOUNT_POINT} # alter file system as necessary for the test alterfs: populatefs # ++++++++++ Altering file system ++++++++++ # empty here rm -fr ${TMPFILE} execute: alterfs # ++++++++++ Executing tests ++++++++++ ${FATSORT} -r ${FS_IMG} ${FATSORT} -l ${FS_IMG} > ${STDOUT} 2> ${STDERR} diff ${STDOUT} ${STDOUT_EXP} diff ${STDERR} ${STDERR_EXP} # check result fsck: execute # ++++++++++ Checking file system ++++++++++ fsck.vfat -n ${FS_IMG} .PHONY: fsck execute populatefs mkfs clean fatsort-1.3.365/tests/tc_pos_sort_reverse_fat32/stderr_expected.txt0000664000175000017500000000000012321036667025036 0ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_sort_reverse_fat32/stdout_expected.txt0000664000175000017500000000052212321036667025066 0ustar feanorfeanorFile system: FAT32. / directory2 Directory1 dir3 z y x w v Ü u t s r q p Ö o n m Long file name with lots of words and characters just to test long file name entries in FAT file systems l k j i h g file3.bin file2.bin file1.bin f e d c b Ä a 9 8 7 6 5 4 3 2 1a 10 1 01b 001c /directory2/ /Directory1/ /dir3/ subDir /dir3/subDir/ fatsort-1.3.365/tests/tc_pos_sort_reverse_fat32/directories.txt0000664000175000017500000000004212321036667024174 0ustar feanorfeanorDirectory1 directory2 dir3/subDir fatsort-1.3.365/tests/tc_pos_sort_order_files_fat32/0000775000175000017500000000000012321036667021745 5ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_sort_order_files_fat32/files.txt0000664000175000017500000000043112321036667023606 0ustar feanorfeanora b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z Ä Ö Ü file3.bin file2.bin file1.bin Long file name with lots of words and characters just to test long file name entries in FAT file systems 1 2 3 4 5 6 7 8 9 10 01b 1a 001c fatsort-1.3.365/tests/tc_pos_sort_order_files_fat32/Makefile0000775000175000017500000000345312321036667023415 0ustar feanorfeanorinclude ../testconfig.mk FS_FATType=32 # MiBytes FS_SIZE=100 FS_FATs=1 FS_VOL_NAME=test FS_ROOT_ENTRIES=512 FS_RSVD_SEC=32 FS_SEC_PER_CLUS=1 FS_SEC_SIZE=512 DIRECTORIES=directories.txt FILES=files.txt TESTLOG=test.log STDOUT=stdout.log STDOUT_EXP=stdout_expected.txt STDERR=stderr.log STDERR_EXP=stderr_expected.txt all: fsck if [ ${DEL_FS_ON_PASS} -eq 1 ]; then rm -f ${FS_IMG}; fi clean: rm -fr *.log *.tmp ${FS_IMG} ${TMPFILE} ${TMPDIR} if [ -d ${MOUNT_POINT} ]; then \ until sudo umount ${MOUNT_POINT}; do sleep 1; done; \ rmdir ${MOUNT_POINT}; \ fi # create file system mkfs: # ++++++++++ Creating file ${FATType} system ++++++++++ rm -f ${FS_IMG} truncate -s ${FS_SIZE}MB ${FS_IMG} mkfs.vfat -F ${FS_FATType} -f ${FS_FATs} -n ${FS_VOL_NAME} -r ${FS_ROOT_ENTRIES} -R ${FS_RSVD_SEC} -s ${FS_SEC_PER_CLUS} -S ${FS_SEC_SIZE} ${FS_IMG} # populate fs populatefs: mkfs # ++++++++++ Populating file system with directories and files ++++++++++ mkdir -p ${MOUNT_POINT} sudo mount -o loop,codepage=850,iocharset=iso8859-1,utf8,uid=${MOUNT_UID},gid=${MOUNT_GID} ${FS_IMG} ${MOUNT_POINT} cat ${DIRECTORIES} | while read dir; do mkdir -p "${MOUNT_POINT}/$$dir"; done cat ${FILES} | while read file; do touch "${MOUNT_POINT}/$$file"; done # delete some files until sudo umount ${MOUNT_POINT}; do sleep 1; done rmdir ${MOUNT_POINT} # alter file system as necessary for the test alterfs: populatefs # ++++++++++ Altering file system ++++++++++ # empty here rm -fr ${TMPFILE} execute: alterfs # ++++++++++ Executing tests ++++++++++ ${FATSORT} -of ${FS_IMG} ${FATSORT} -l ${FS_IMG} > ${STDOUT} 2> ${STDERR} diff ${STDOUT} ${STDOUT_EXP} diff ${STDERR} ${STDERR_EXP} # check result fsck: execute # ++++++++++ Checking file system ++++++++++ fsck.vfat -n ${FS_IMG} .PHONY: fsck execute populatefs mkfs clean fatsort-1.3.365/tests/tc_pos_sort_order_files_fat32/stderr_expected.txt0000664000175000017500000000000012321036667025660 0ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_sort_order_files_fat32/stdout_expected.txt0000664000175000017500000000052212321036667025710 0ustar feanorfeanorFile system: FAT32. / 001c 01b 1 10 1a 2 3 4 5 6 7 8 9 a Ä b c d e f file1.bin file2.bin file3.bin g h i j k l Long file name with lots of words and characters just to test long file name entries in FAT file systems m n o Ö p q r s t u Ü v w x y z dir3 Directory1 directory2 /dir3/ subDir /dir3/subDir/ /Directory1/ /directory2/ fatsort-1.3.365/tests/tc_pos_sort_order_files_fat32/directories.txt0000664000175000017500000000004212321036667025016 0ustar feanorfeanorDirectory1 directory2 dir3/subDir fatsort-1.3.365/tests/tc_pos_sort_modification_time/0000775000175000017500000000000012321036667022134 5ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_sort_modification_time/files.txt0000664000175000017500000000003112321036667023771 0ustar feanorfeanorsecond first last second fatsort-1.3.365/tests/tc_pos_sort_modification_time/Makefile0000775000175000017500000000363512321036667023606 0ustar feanorfeanorinclude ../testconfig.mk FS_FATType=32 # MiBytes FS_SIZE=100 FS_FATs=1 FS_VOL_NAME=test FS_ROOT_ENTRIES=512 FS_RSVD_SEC=32 FS_SEC_PER_CLUS=1 FS_SEC_SIZE=512 DIRECTORIES=directories.txt FILES=files.txt TESTLOG=test.log STDOUT=stdout.log STDOUT_EXP=stdout_expected.txt STDERR=stderr.log STDERR_EXP=stderr_expected.txt all: fsck if [ ${DEL_FS_ON_PASS} -eq 1 ]; then rm -f ${FS_IMG}; fi clean: rm -fr *.log *.tmp ${FS_IMG} ${TMPFILE} ${TMPDIR} if [ -d ${MOUNT_POINT} ]; then \ until sudo umount ${MOUNT_POINT}; do sleep 1; done; \ rmdir ${MOUNT_POINT}; \ fi # create file system mkfs: # ++++++++++ Creating file ${FATType} system ++++++++++ rm -f ${FS_IMG} truncate -s ${FS_SIZE}MB ${FS_IMG} mkfs.vfat -F ${FS_FATType} -f ${FS_FATs} -n ${FS_VOL_NAME} -r ${FS_ROOT_ENTRIES} -R ${FS_RSVD_SEC} -s ${FS_SEC_PER_CLUS} -S ${FS_SEC_SIZE} ${FS_IMG} # populate fs populatefs: mkfs # ++++++++++ Populating file system with directories and files ++++++++++ mkdir -p ${MOUNT_POINT} sudo mount -o loop,codepage=850,iocharset=iso8859-1,utf8,uid=${MOUNT_UID},gid=${MOUNT_GID} ${FS_IMG} ${MOUNT_POINT} cat ${DIRECTORIES} | while read dir; do mkdir -p "${MOUNT_POINT}/$$dir"; sleep 1; done cat ${FILES} | while read file; do touch "${MOUNT_POINT}/$$file"; sleep 1; done sleep 1 touch ${MOUNT_POINT}/last # alter modification time sleep 1 touch ${MOUNT_POINT}/first -t 200001010101.01 until sudo umount ${MOUNT_POINT}; do sleep 1; done rmdir ${MOUNT_POINT} # alter file system as necessary for the test alterfs: populatefs # ++++++++++ Altering file system ++++++++++ # empty here rm -fr ${TMPFILE} execute: alterfs # ++++++++++ Executing tests ++++++++++ ${FATSORT} -t ${FS_IMG} ${FATSORT} -l ${FS_IMG} > ${STDOUT} 2> ${STDERR} diff ${STDOUT} ${STDOUT_EXP} diff ${STDERR} ${STDERR_EXP} # check result fsck: execute # ++++++++++ Checking file system ++++++++++ fsck.vfat -n ${FS_IMG} .PHONY: fsck execute populatefs mkfs clean fatsort-1.3.365/tests/tc_pos_sort_modification_time/stderr_expected.txt0000664000175000017500000000000012321036667026047 0ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_sort_modification_time/stdout_expected.txt0000664000175000017500000000007712321036667026104 0ustar feanorfeanorFile system: FAT32. / firstdir first second last /firstdir/ fatsort-1.3.365/tests/tc_pos_sort_modification_time/directories.txt0000664000175000017500000000001112321036667025201 0ustar feanorfeanorfirstdir fatsort-1.3.365/tests/tc_neg_bad_reserved_sector_count/0000775000175000017500000000000012321036667022566 5ustar feanorfeanorfatsort-1.3.365/tests/tc_neg_bad_reserved_sector_count/files.txt0000664000175000017500000000001112321036667024421 0ustar feanorfeanordir/test fatsort-1.3.365/tests/tc_neg_bad_reserved_sector_count/Makefile0000775000175000017500000000362412321036667024236 0ustar feanorfeanorinclude ../testconfig.mk FS_FATType=32 # 100 MiBytes FS_SIZE=100 FS_FATs=2 FS_VOL_NAME=test FS_ROOT_ENTRIES=512 FS_RSVD_SEC=32 FS_SEC_PER_CLUS=1 FS_SEC_SIZE=512 DIRECTORIES=directories.txt FILES=files.txt TESTLOG=test.log STDOUT=stdout.log STDOUT_EXP=stdout_expected.txt STDERR=stderr.log STDERR_EXP=stderr_expected.txt # no fsck in negative tests all: execute if [ ${DEL_FS_ON_PASS} -eq 1 ]; then rm -f ${FS_IMG}; fi clean: rm -fr *.log *.tmp ${FS_IMG} ${TMPFILE} ${TMPDIR} if [ -d ${MOUNT_POINT} ]; then \ until sudo umount ${MOUNT_POINT}; do sleep 1; done; \ rmdir ${MOUNT_POINT}; \ fi # create file system mkfs: # ++++++++++ Creating file ${FATType} system ++++++++++ rm -f ${FS_IMG} truncate -s ${FS_SIZE}MB ${FS_IMG} mkfs.vfat -F ${FS_FATType} -f ${FS_FATs} -n ${FS_VOL_NAME} -r ${FS_ROOT_ENTRIES} -R ${FS_RSVD_SEC} -s ${FS_SEC_PER_CLUS} -S ${FS_SEC_SIZE} ${FS_IMG} # populate fs populatefs: mkfs # ++++++++++ Populating file system with directories and files ++++++++++ mkdir -p ${MOUNT_POINT} sudo mount -o loop,codepage=850,iocharset=iso8859-1,utf8,uid=${MOUNT_UID},gid=${MOUNT_GID} ${FS_IMG} ${MOUNT_POINT} cat ${DIRECTORIES} | while read dir; do mkdir -p "${MOUNT_POINT}/$$dir"; done cat ${FILES} | while read file; do touch "${MOUNT_POINT}/$$file"; done until sudo umount ${MOUNT_POINT}; do sleep 1; done rmdir ${MOUNT_POINT} # alter file system as necessary for the test alterfs: populatefs # ++++++++++ Altering file system ++++++++++ # set reserved sector count to zero ${BBE} -b xe:2 -e "r 0 \x00\x00" ${FS_IMG} > ${TMPFILE} cp ${TMPFILE} ${FS_IMG} rm -fr ${TMPFILE} execute: alterfs # ++++++++++ Executing tests ++++++++++ ${FATSORT} ${FS_IMG} > ${STDOUT} 2> ${STDERR}; [ $$? -ne 0 ] diff ${STDOUT} ${STDOUT_EXP} diff ${STDERR} ${STDERR_EXP} # check result fsck: execute # ++++++++++ Checking file system ++++++++++ fsck.vfat -n ${FS_IMG} .PHONY: fsck execute populatefs mkfs clean fatsort-1.3.365/tests/tc_neg_bad_reserved_sector_count/stderr_expected.txt0000664000175000017500000000036012321036667026512 0ustar feanorfeanorcheck_bootsector: Reserved sector count is zero! read_bootsector: This is not a FAT boot sector or sector is damaged! openFileSystem: Failed to read boot sector! sortFileSystem: Failed to open file system! main: Failed to sort file system! fatsort-1.3.365/tests/tc_neg_bad_reserved_sector_count/stdout_expected.txt0000664000175000017500000000000012321036667026520 0ustar feanorfeanorfatsort-1.3.365/tests/tc_neg_bad_reserved_sector_count/directories.txt0000664000175000017500000000000412321036667025635 0ustar feanorfeanordir fatsort-1.3.365/tests/tc_neg_missing_sne_at_end_of_cluster_fat32/0000775000175000017500000000000012321036667024426 5ustar feanorfeanorfatsort-1.3.365/tests/tc_neg_missing_sne_at_end_of_cluster_fat32/files.txt0000664000175000017500000000012412321036667026266 0ustar feanorfeanordir1/Apfel1 dir1/Apfel2 dir1/Apfel3 dir1/Apfel4 dir1/Apfel5 dir1/Apfel6 dir1/Apfel7 fatsort-1.3.365/tests/tc_neg_missing_sne_at_end_of_cluster_fat32/Makefile0000775000175000017500000000425012321036667026072 0ustar feanorfeanorinclude ../testconfig.mk FS_FATType=32 # 100 MiBytes FS_SIZE=100 FS_FATs=2 FS_VOL_NAME=test FS_ROOT_ENTRIES=512 FS_RSVD_SEC=32 FS_SEC_PER_CLUS=1 FS_SEC_SIZE=512 DIRECTORIES=directories.txt FILES=files.txt TESTLOG=test.log STDOUT=stdout.log STDOUT_EXP=stdout_expected.txt STDERR=stderr.log STDERR_EXP=stderr_expected.txt # no fsck in negative tests all: execute if [ ${DEL_FS_ON_PASS} -eq 1 ]; then rm -f ${FS_IMG}; fi clean: rm -fr *.log *.tmp ${FS_IMG} ${TMPFILE} ${TMPDIR} if [ -d ${MOUNT_POINT} ]; then \ until sudo umount ${MOUNT_POINT}; do sleep 1; done; \ rmdir ${MOUNT_POINT}; \ fi # create file system mkfs: # ++++++++++ Creating file ${FATType} system ++++++++++ rm -f ${FS_IMG} truncate -s ${FS_SIZE}MB ${FS_IMG} mkfs.vfat -F ${FS_FATType} -f ${FS_FATs} -n ${FS_VOL_NAME} -r ${FS_ROOT_ENTRIES} -R ${FS_RSVD_SEC} -s ${FS_SEC_PER_CLUS} -S ${FS_SEC_SIZE} ${FS_IMG} # populate fs populatefs: mkfs # ++++++++++ Populating file system with directories and files ++++++++++ mkdir -p ${MOUNT_POINT} sudo mount -o loop,codepage=850,iocharset=iso8859-1,utf8,uid=${MOUNT_UID},gid=${MOUNT_GID} ${FS_IMG} ${MOUNT_POINT} cat ${DIRECTORIES} | while read dir; do mkdir -p "${MOUNT_POINT}/$$dir"; done cat ${FILES} | while read file; do touch "${MOUNT_POINT}/$$file"; done rm -f "${MOUNT_POINT}/a" #remove some files rm -f "${MOUNT_POINT}/n" rm -f "${MOUNT_POINT}/z" until sudo umount ${MOUNT_POINT}; do sleep 1; done rmdir ${MOUNT_POINT} # alter file system as necessary for the test alterfs: populatefs # ++++++++++ Altering file system ++++++++++ # delete empty space and insert single sne before last lne ${BBE} -b x17c020:32 -e "d 0 32" ${FS_IMG} > ${TMPFILE} ${BBE} -b x17bfa0:32 -e "A \x41\x50\x46\x45\x4C\x39\x39\x39\x20\x20\x20\x20\x00\x00\x31\xA0\xB0\x42\xB0\x42\x00\x00\x31\xA0\xB0\x42\x00\x00\x00\x00\x00\x00" ${TMPFILE} > ${FS_IMG} rm -fr ${TMPFILE} execute: alterfs # ++++++++++ Executing tests ++++++++++ ${FATSORT} ${FS_IMG} > ${STDOUT} 2> ${STDERR}; [ $$? -ne 0 ] diff ${STDOUT} ${STDOUT_EXP} diff ${STDERR} ${STDERR_EXP} # check result fsck: execute # ++++++++++ Checking file system ++++++++++ fsck.vfat -n ${FS_IMG} .PHONY: fsck execute populatefs mkfs clean fatsort-1.3.365/tests/tc_neg_missing_sne_at_end_of_cluster_fat32/stderr_expected.txt0000664000175000017500000000050612321036667030354 0ustar feanorfeanorparseClusterChain: ShortDirEntry is missing after LongDirEntries (root directory entry 16)! sortClusterChain: Failed to parse cluster chain! sortSubdirectories: Failed to sort cluster chain! sortClusterChain: Failed to sort subdirectories! sortFileSystem: Failed to sort first cluster chain! main: Failed to sort file system! fatsort-1.3.365/tests/tc_neg_missing_sne_at_end_of_cluster_fat32/stdout_expected.txt0000664000175000017500000000010212321036667030363 0ustar feanorfeanorFile system: FAT32. Sorting directory / Sorting directory /dir1/ fatsort-1.3.365/tests/tc_neg_missing_sne_at_end_of_cluster_fat32/directories.txt0000664000175000017500000000000512321036667027476 0ustar feanorfeanordir1 fatsort-1.3.365/tests/tc_pos_three_fats_fat32/0000775000175000017500000000000012321036667020525 5ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_three_fats_fat32/files.txt0000664000175000017500000000043112321036667022366 0ustar feanorfeanora b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z Ä Ö Ü file3.bin file2.bin file1.bin Long file name with lots of words and characters just to test long file name entries in FAT file systems 1 2 3 4 5 6 7 8 9 10 01b 1a 001c fatsort-1.3.365/tests/tc_pos_three_fats_fat32/Makefile0000775000175000017500000000342312321036667022172 0ustar feanorfeanorinclude ../testconfig.mk FS_FATType=32 # MiBytes FS_SIZE=100 FS_FATs=3 FS_VOL_NAME=test FS_ROOT_ENTRIES=512 FS_RSVD_SEC=32 FS_SEC_PER_CLUS=1 FS_SEC_SIZE=512 DIRECTORIES=directories.txt FILES=files.txt TESTLOG=test.log STDOUT=stdout.log STDOUT_EXP=stdout_expected.txt STDERR=stderr.log STDERR_EXP=stderr_expected.txt all: fsck if [ ${DEL_FS_ON_PASS} -eq 1 ]; then rm -f ${FS_IMG}; fi clean: rm -fr *.log *.tmp ${FS_IMG} ${TMPFILE} ${TMPDIR} if [ -d ${MOUNT_POINT} ]; then \ until sudo umount ${MOUNT_POINT}; do sleep 1; done; \ rmdir ${MOUNT_POINT}; \ fi # create file system mkfs: # ++++++++++ Creating file ${FATType} system ++++++++++ rm -f ${FS_IMG} truncate -s ${FS_SIZE}MB ${FS_IMG} mkfs.vfat -F ${FS_FATType} -f ${FS_FATs} -n ${FS_VOL_NAME} -r ${FS_ROOT_ENTRIES} -R ${FS_RSVD_SEC} -s ${FS_SEC_PER_CLUS} -S ${FS_SEC_SIZE} ${FS_IMG} # populate fs populatefs: mkfs # ++++++++++ Populating file system with directories and files ++++++++++ mkdir -p ${MOUNT_POINT} sudo mount -o loop,codepage=850,iocharset=iso8859-1,utf8,uid=${MOUNT_UID},gid=${MOUNT_GID} ${FS_IMG} ${MOUNT_POINT} cat ${DIRECTORIES} | while read dir; do mkdir -p "${MOUNT_POINT}/$$dir"; done cat ${FILES} | while read file; do touch "${MOUNT_POINT}/$$file"; done until sudo umount ${MOUNT_POINT}; do sleep 1; done rmdir ${MOUNT_POINT} # alter file system as necessary for the test alterfs: populatefs # ++++++++++ Altering file system ++++++++++ # empty here rm -fr ${TMPFILE} execute: alterfs # ++++++++++ Executing tests ++++++++++ ${FATSORT} ${FS_IMG} ${FATSORT} -l ${FS_IMG} > ${STDOUT} 2> ${STDERR} diff ${STDOUT} ${STDOUT_EXP} diff ${STDERR} ${STDERR_EXP} # check result fsck: execute # ++++++++++ Checking file system ++++++++++ #fsck.vfat -n ${FS_IMG} .PHONY: fsck execute populatefs mkfs clean fatsort-1.3.365/tests/tc_pos_three_fats_fat32/stderr_expected.txt0000664000175000017500000000000012321036667024440 0ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_three_fats_fat32/stdout_expected.txt0000664000175000017500000000052212321036667024470 0ustar feanorfeanorFile system: FAT32. / dir3 Directory1 directory2 001c 01b 1 10 1a 2 3 4 5 6 7 8 9 a Ä b c d e f file1.bin file2.bin file3.bin g h i j k l Long file name with lots of words and characters just to test long file name entries in FAT file systems m n o Ö p q r s t u Ü v w x y z /dir3/ subDir /dir3/subDir/ /Directory1/ /directory2/ fatsort-1.3.365/tests/tc_pos_three_fats_fat32/directories.txt0000664000175000017500000000004212321036667023576 0ustar feanorfeanorDirectory1 directory2 dir3/subDir fatsort-1.3.365/tests/README0000664000175000017500000000007212321036667014712 0ustar feanorfeanorTest requrirements: dosfstools 3.0.22 bbe version 0.2.2 fatsort-1.3.365/tests/tc_neg_bad_number_of_fats/0000775000175000017500000000000012321036670021143 5ustar feanorfeanorfatsort-1.3.365/tests/tc_neg_bad_number_of_fats/files.txt0000664000175000017500000000001112321036670022776 0ustar feanorfeanordir/test fatsort-1.3.365/tests/tc_neg_bad_number_of_fats/Makefile0000775000175000017500000000361212321036670022610 0ustar feanorfeanorinclude ../testconfig.mk FS_FATType=32 # 100 MiBytes FS_SIZE=100 FS_FATs=2 FS_VOL_NAME=test FS_ROOT_ENTRIES=512 FS_RSVD_SEC=32 FS_SEC_PER_CLUS=1 FS_SEC_SIZE=512 DIRECTORIES=directories.txt FILES=files.txt TESTLOG=test.log STDOUT=stdout.log STDOUT_EXP=stdout_expected.txt STDERR=stderr.log STDERR_EXP=stderr_expected.txt # no fsck in negative tests all: execute if [ ${DEL_FS_ON_PASS} -eq 1 ]; then rm -f ${FS_IMG}; fi clean: rm -fr *.log *.tmp ${FS_IMG} ${TMPFILE} ${TMPDIR} if [ -d ${MOUNT_POINT} ]; then \ until sudo umount ${MOUNT_POINT}; do sleep 1; done; \ rmdir ${MOUNT_POINT}; \ fi # create file system mkfs: # ++++++++++ Creating file ${FATType} system ++++++++++ rm -f ${FS_IMG} truncate -s ${FS_SIZE}MB ${FS_IMG} mkfs.vfat -F ${FS_FATType} -f ${FS_FATs} -n ${FS_VOL_NAME} -r ${FS_ROOT_ENTRIES} -R ${FS_RSVD_SEC} -s ${FS_SEC_PER_CLUS} -S ${FS_SEC_SIZE} ${FS_IMG} # populate fs populatefs: mkfs # ++++++++++ Populating file system with directories and files ++++++++++ mkdir -p ${MOUNT_POINT} sudo mount -o loop,codepage=850,iocharset=iso8859-1,utf8,uid=${MOUNT_UID},gid=${MOUNT_GID} ${FS_IMG} ${MOUNT_POINT} cat ${DIRECTORIES} | while read dir; do mkdir -p "${MOUNT_POINT}/$$dir"; done cat ${FILES} | while read file; do touch "${MOUNT_POINT}/$$file"; done until sudo umount ${MOUNT_POINT}; do sleep 1; done rmdir ${MOUNT_POINT} # alter file system as necessary for the test alterfs: populatefs # ++++++++++ Altering file system ++++++++++ # set number of FATs to zero ${BBE} -b x10:1 -e "r 0 \x00" ${FS_IMG} > ${TMPFILE} cp ${TMPFILE} ${FS_IMG} rm -fr ${TMPFILE} execute: alterfs # ++++++++++ Executing tests ++++++++++ ${FATSORT} ${FS_IMG} > ${STDOUT} 2> ${STDERR}; [ $$? -ne 0 ] diff ${STDOUT} ${STDOUT_EXP} diff ${STDERR} ${STDERR_EXP} # check result fsck: execute # ++++++++++ Checking file system ++++++++++ fsck.vfat -n ${FS_IMG} .PHONY: fsck execute populatefs mkfs clean fatsort-1.3.365/tests/tc_neg_bad_number_of_fats/stderr_expected.txt0000664000175000017500000000035112321036670025067 0ustar feanorfeanorcheck_bootsector: Number of FATs is zero! read_bootsector: This is not a FAT boot sector or sector is damaged! openFileSystem: Failed to read boot sector! sortFileSystem: Failed to open file system! main: Failed to sort file system! fatsort-1.3.365/tests/tc_neg_bad_number_of_fats/stdout_expected.txt0000664000175000017500000000000012321036670025075 0ustar feanorfeanorfatsort-1.3.365/tests/tc_neg_bad_number_of_fats/directories.txt0000664000175000017500000000000412321036670024212 0ustar feanorfeanordir fatsort-1.3.365/tests/tc_pos_sort_order_any_fat32/0000775000175000017500000000000012321036667021432 5ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_sort_order_any_fat32/files.txt0000664000175000017500000000043112321036667023273 0ustar feanorfeanora b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z Ä Ö Ü file3.bin file2.bin file1.bin Long file name with lots of words and characters just to test long file name entries in FAT file systems 1 2 3 4 5 6 7 8 9 10 01b 1a 001c fatsort-1.3.365/tests/tc_pos_sort_order_any_fat32/Makefile0000775000175000017500000000345312321036667023102 0ustar feanorfeanorinclude ../testconfig.mk FS_FATType=32 # MiBytes FS_SIZE=100 FS_FATs=1 FS_VOL_NAME=test FS_ROOT_ENTRIES=512 FS_RSVD_SEC=32 FS_SEC_PER_CLUS=1 FS_SEC_SIZE=512 DIRECTORIES=directories.txt FILES=files.txt TESTLOG=test.log STDOUT=stdout.log STDOUT_EXP=stdout_expected.txt STDERR=stderr.log STDERR_EXP=stderr_expected.txt all: fsck if [ ${DEL_FS_ON_PASS} -eq 1 ]; then rm -f ${FS_IMG}; fi clean: rm -fr *.log *.tmp ${FS_IMG} ${TMPFILE} ${TMPDIR} if [ -d ${MOUNT_POINT} ]; then \ until sudo umount ${MOUNT_POINT}; do sleep 1; done; \ rmdir ${MOUNT_POINT}; \ fi # create file system mkfs: # ++++++++++ Creating file ${FATType} system ++++++++++ rm -f ${FS_IMG} truncate -s ${FS_SIZE}MB ${FS_IMG} mkfs.vfat -F ${FS_FATType} -f ${FS_FATs} -n ${FS_VOL_NAME} -r ${FS_ROOT_ENTRIES} -R ${FS_RSVD_SEC} -s ${FS_SEC_PER_CLUS} -S ${FS_SEC_SIZE} ${FS_IMG} # populate fs populatefs: mkfs # ++++++++++ Populating file system with directories and files ++++++++++ mkdir -p ${MOUNT_POINT} sudo mount -o loop,codepage=850,iocharset=iso8859-1,utf8,uid=${MOUNT_UID},gid=${MOUNT_GID} ${FS_IMG} ${MOUNT_POINT} cat ${DIRECTORIES} | while read dir; do mkdir -p "${MOUNT_POINT}/$$dir"; done cat ${FILES} | while read file; do touch "${MOUNT_POINT}/$$file"; done # delete some files until sudo umount ${MOUNT_POINT}; do sleep 1; done rmdir ${MOUNT_POINT} # alter file system as necessary for the test alterfs: populatefs # ++++++++++ Altering file system ++++++++++ # empty here rm -fr ${TMPFILE} execute: alterfs # ++++++++++ Executing tests ++++++++++ ${FATSORT} -oa ${FS_IMG} ${FATSORT} -l ${FS_IMG} > ${STDOUT} 2> ${STDERR} diff ${STDOUT} ${STDOUT_EXP} diff ${STDERR} ${STDERR_EXP} # check result fsck: execute # ++++++++++ Checking file system ++++++++++ fsck.vfat -n ${FS_IMG} .PHONY: fsck execute populatefs mkfs clean fatsort-1.3.365/tests/tc_pos_sort_order_any_fat32/stderr_expected.txt0000664000175000017500000000000012321036667025345 0ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_sort_order_any_fat32/stdout_expected.txt0000664000175000017500000000052212321036667025375 0ustar feanorfeanorFile system: FAT32. / 001c 01b 1 10 1a 2 3 4 5 6 7 8 9 a Ä b c d dir3 Directory1 directory2 e f file1.bin file2.bin file3.bin g h i j k l Long file name with lots of words and characters just to test long file name entries in FAT file systems m n o Ö p q r s t u Ü v w x y z /dir3/ subDir /dir3/subDir/ /Directory1/ /directory2/ fatsort-1.3.365/tests/tc_pos_sort_order_any_fat32/directories.txt0000664000175000017500000000004212321036667024503 0ustar feanorfeanorDirectory1 directory2 dir3/subDir fatsort-1.3.365/tests/tc_neg_missing_last_lne_in_root_dir_fat16/0000775000175000017500000000000012321036667024274 5ustar feanorfeanorfatsort-1.3.365/tests/tc_neg_missing_last_lne_in_root_dir_fat16/files.txt0000664000175000017500000000012412321036667026134 0ustar feanorfeanorlong_filename___________________________1 long_filename___________________________2 fatsort-1.3.365/tests/tc_neg_missing_last_lne_in_root_dir_fat16/Makefile0000775000175000017500000000374612321036667025751 0ustar feanorfeanorinclude ../testconfig.mk FS_FATType=16 # MiBytes FS_SIZE=10 FS_FATs=2 FS_VOL_NAME=test FS_ROOT_ENTRIES=512 FS_RSVD_SEC=32 FS_SEC_PER_CLUS=1 FS_SEC_SIZE=512 DIRECTORIES=directories.txt FILES=files.txt TESTLOG=test.log STDOUT=stdout.log STDOUT_EXP=stdout_expected.txt STDERR=stderr.log STDERR_EXP=stderr_expected.txt # no fsck in negative tests all: execute if [ ${DEL_FS_ON_PASS} -eq 1 ]; then rm -f ${FS_IMG}; fi clean: rm -fr *.log *.tmp ${FS_IMG} ${TMPFILE} ${TMPDIR} if [ -d ${MOUNT_POINT} ]; then \ until sudo umount ${MOUNT_POINT}; do sleep 1; done; \ rmdir ${MOUNT_POINT}; \ fi # create file system mkfs: # ++++++++++ Creating file ${FATType} system ++++++++++ rm -f ${FS_IMG} truncate -s ${FS_SIZE}MB ${FS_IMG} mkfs.vfat -F ${FS_FATType} -f ${FS_FATs} -n ${FS_VOL_NAME} -r ${FS_ROOT_ENTRIES} -R ${FS_RSVD_SEC} -s ${FS_SEC_PER_CLUS} -S ${FS_SEC_SIZE} ${FS_IMG} # populate fs populatefs: mkfs # ++++++++++ Populating file system with directories and files ++++++++++ mkdir -p ${MOUNT_POINT} sudo mount -o loop,codepage=850,iocharset=iso8859-1,utf8,uid=${MOUNT_UID},gid=${MOUNT_GID} ${FS_IMG} ${MOUNT_POINT} cat ${DIRECTORIES} | while read dir; do mkdir -p "${MOUNT_POINT}/$$dir"; done cat ${FILES} | while read file; do touch "${MOUNT_POINT}/$$file"; done rm -f "${MOUNT_POINT}/a" #remove some files rm -f "${MOUNT_POINT}/n" rm -f "${MOUNT_POINT}/z" until sudo umount ${MOUNT_POINT}; do sleep 1; done rmdir ${MOUNT_POINT} # alter file system as necessary for the test alterfs: populatefs # ++++++++++ Altering file system ++++++++++ # change last lde ord ${BBE} -b x17020:1 -e "r 0 \x04" ${FS_IMG} > ${TMPFILE} cp -f ${TMPFILE} ${FS_IMG} rm -fr ${TMPFILE} execute: alterfs # ++++++++++ Executing tests ++++++++++ ${FATSORT} ${FS_IMG} > ${STDOUT} 2> ${STDERR}; [ $$? -ne 0 ] diff ${STDOUT} ${STDOUT_EXP} diff ${STDERR} ${STDERR_EXP} # check result fsck: execute # ++++++++++ Checking file system ++++++++++ fsck.vfat -n ${FS_IMG} .PHONY: fsck execute populatefs mkfs clean fatsort-1.3.365/tests/tc_neg_missing_last_lne_in_root_dir_fat16/stderr_expected.txt0000664000175000017500000000046612321036667030227 0ustar feanorfeanorcheckLongDirEntries: LongDirEntry should be marked as last long dir entry but isn't! parseFAT1xRootDirEntries: checkDirEntry failed at root directory entry 5! sortFAT1xRootDirectory: Failed to parse root directory entries! sortFileSystem: Failed to sort FAT16 root directory! main: Failed to sort file system! fatsort-1.3.365/tests/tc_neg_missing_last_lne_in_root_dir_fat16/stdout_expected.txt0000664000175000017500000000005112321036667030234 0ustar feanorfeanorFile system: FAT16. Sorting directory / fatsort-1.3.365/tests/tc_neg_missing_last_lne_in_root_dir_fat16/directories.txt0000664000175000017500000000000012321036667027337 0ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_sort_ascii_fat12/0000775000175000017500000000000012321036667020536 5ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_sort_ascii_fat12/files.txt0000664000175000017500000000001712321036667022377 0ustar feanorfeanorABC1 Abc2 abc3 fatsort-1.3.365/tests/tc_pos_sort_ascii_fat12/Makefile0000775000175000017500000000342512321036667022205 0ustar feanorfeanorinclude ../testconfig.mk FS_FATType=12 # MiBytes FS_SIZE=10 FS_FATs=2 FS_VOL_NAME=test FS_ROOT_ENTRIES=512 FS_RSVD_SEC=32 FS_SEC_PER_CLUS=16 FS_SEC_SIZE=512 DIRECTORIES=directories.txt FILES=files.txt TESTLOG=test.log STDOUT=stdout.log STDOUT_EXP=stdout_expected.txt STDERR=stderr.log STDERR_EXP=stderr_expected.txt all: fsck if [ ${DEL_FS_ON_PASS} -eq 1 ]; then rm -f ${FS_IMG}; fi clean: rm -fr *.log *.tmp ${FS_IMG} ${TMPFILE} ${TMPDIR} if [ -d ${MOUNT_POINT} ]; then \ until sudo umount ${MOUNT_POINT}; do sleep 1; done; \ rmdir ${MOUNT_POINT}; \ fi # create file system mkfs: # ++++++++++ Creating file ${FATType} system ++++++++++ rm -f ${FS_IMG} truncate -s ${FS_SIZE}MB ${FS_IMG} mkfs.vfat -F ${FS_FATType} -f ${FS_FATs} -n ${FS_VOL_NAME} -r ${FS_ROOT_ENTRIES} -R ${FS_RSVD_SEC} -s ${FS_SEC_PER_CLUS} -S ${FS_SEC_SIZE} ${FS_IMG} # populate fs populatefs: mkfs # ++++++++++ Populating file system with directories and files ++++++++++ mkdir -p ${MOUNT_POINT} sudo mount -o loop,codepage=850,iocharset=iso8859-1,utf8,uid=${MOUNT_UID},gid=${MOUNT_GID} ${FS_IMG} ${MOUNT_POINT} cat ${DIRECTORIES} | while read dir; do mkdir -p "${MOUNT_POINT}/$$dir"; done cat ${FILES} | while read file; do touch "${MOUNT_POINT}/$$file"; done until sudo umount ${MOUNT_POINT}; do sleep 1; done rmdir ${MOUNT_POINT} # alter file system as necessary for the test alterfs: populatefs # ++++++++++ Altering file system ++++++++++ # empty here rm -fr ${TMPFILE} execute: alterfs # ++++++++++ Executing tests ++++++++++ ${FATSORT} -a ${FS_IMG} ${FATSORT} -l ${FS_IMG} > ${STDOUT} 2> ${STDERR} diff ${STDOUT} ${STDOUT_EXP} diff ${STDERR} ${STDERR_EXP} # check result fsck: execute # ++++++++++ Checking file system ++++++++++ fsck.vfat -n ${FS_IMG} .PHONY: fsck execute populatefs mkfs clean fatsort-1.3.365/tests/tc_pos_sort_ascii_fat12/stderr_expected.txt0000664000175000017500000000000012321036667024451 0ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_sort_ascii_fat12/stdout_expected.txt0000664000175000017500000000014612321036667024503 0ustar feanorfeanorFile system: FAT12. / dir_ABC2 dir_Abc1 dir_abc3 ABC1 Abc2 abc3 /dir_ABC2/ /dir_Abc1/ /dir_abc3/ fatsort-1.3.365/tests/tc_pos_sort_ascii_fat12/directories.txt0000664000175000017500000000003312321036667023607 0ustar feanorfeanordir_Abc1 dir_ABC2 dir_abc3 fatsort-1.3.365/tests/tc_neg_bad_fat_size_fat12/0000775000175000017500000000000012321036667020761 5ustar feanorfeanorfatsort-1.3.365/tests/tc_neg_bad_fat_size_fat12/files.txt0000664000175000017500000000001112321036667022614 0ustar feanorfeanordir/test fatsort-1.3.365/tests/tc_neg_bad_fat_size_fat12/tc_neg_bad_fat_size_fat12/0000775000175000017500000000000012321036667025707 5ustar feanorfeanorfatsort-1.3.365/tests/tc_neg_bad_fat_size_fat12/tc_neg_bad_fat_size_fat12/files.txt0000664000175000017500000000001112321036667027542 0ustar feanorfeanordir/test fatsort-1.3.365/tests/tc_neg_bad_fat_size_fat12/Makefile0000775000175000017500000000400312321036667022421 0ustar feanorfeanorinclude ../testconfig.mk FS_FATType=12 # 100 MiBytes FS_SIZE=10 FS_FATs=2 FS_VOL_NAME=test FS_ROOT_ENTRIES=512 FS_RSVD_SEC=32 FS_SEC_PER_CLUS=16 FS_SEC_SIZE=512 DIRECTORIES=directories.txt FILES=files.txt TESTLOG=test.log STDOUT=stdout.log STDOUT_EXP=stdout_expected.txt STDERR=stderr.log STDERR_EXP=stderr_expected.txt # no fsck in negative tests all: execute if [ ${DEL_FS_ON_PASS} -eq 1 ]; then rm -f ${FS_IMG}; fi clean: rm -fr *.log *.tmp ${FS_IMG} ${TMPFILE} ${TMPDIR} if [ -d ${MOUNT_POINT} ]; then \ until sudo umount ${MOUNT_POINT}; do sleep 1; done; \ rmdir ${MOUNT_POINT}; \ fi # create file system mkfs: # ++++++++++ Creating file ${FATType} system ++++++++++ rm -f ${FS_IMG} truncate -s ${FS_SIZE}MB ${FS_IMG} mkfs.vfat -F ${FS_FATType} -f ${FS_FATs} -n ${FS_VOL_NAME} -r ${FS_ROOT_ENTRIES} -R ${FS_RSVD_SEC} -s ${FS_SEC_PER_CLUS} -S ${FS_SEC_SIZE} ${FS_IMG} # populate fs populatefs: mkfs # ++++++++++ Populating file system with directories and files ++++++++++ mkdir -p ${MOUNT_POINT} sudo mount -o loop,codepage=850,iocharset=iso8859-1,utf8,uid=${MOUNT_UID},gid=${MOUNT_GID} ${FS_IMG} ${MOUNT_POINT} cat ${DIRECTORIES} | while read dir; do mkdir -p "${MOUNT_POINT}/$$dir"; done cat ${FILES} | while read file; do touch "${MOUNT_POINT}/$$file"; done until sudo umount ${MOUNT_POINT}; do sleep 1; done rmdir ${MOUNT_POINT} # alter file system as necessary for the test alterfs: populatefs # ++++++++++ Altering file system ++++++++++ # set 16-bit count of fat sectors to zero (bad for FAT1x) ${BBE} -b x16:2 -e "r 0 \x00\x00" ${FS_IMG} > ${TMPFILE} # necessary to fake a large amout of clusters ${BBE} -b x24:4 -e "r 0 \x00\xff\xff\xff" ${TMPFILE} > ${FS_IMG} rm -fr ${TMPFILE} execute: alterfs # ++++++++++ Executing tests ++++++++++ ${FATSORT} ${FS_IMG} > ${STDOUT} 2> ${STDERR}; [ $$? -ne 0 ] diff ${STDOUT} ${STDOUT_EXP} diff ${STDERR} ${STDERR_EXP} # check result fsck: execute # ++++++++++ Checking file system ++++++++++ fsck.vfat -n ${FS_IMG} .PHONY: fsck execute populatefs mkfs clean fatsort-1.3.365/tests/tc_neg_bad_fat_size_fat12/stderr_expected.txt0000664000175000017500000000022612321036667024706 0ustar feanorfeanoropenFileSystem: 16-bit count of FAT sectors must not be zero for FAT1x! sortFileSystem: Failed to open file system! main: Failed to sort file system! fatsort-1.3.365/tests/tc_neg_bad_fat_size_fat12/stdout_expected.txt0000664000175000017500000000000012321036667024713 0ustar feanorfeanorfatsort-1.3.365/tests/tc_neg_bad_fat_size_fat12/directories.txt0000664000175000017500000000000412321036667024030 0ustar feanorfeanordir fatsort-1.3.365/tests/tc_pos_sort_natural_fat32/0000775000175000017500000000000012321036667021116 5ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_sort_natural_fat32/files.txt0000664000175000017500000000054012321036667022760 0ustar feanorfeanor0abcdfgh 0defgh 0zgrth 1ihihu 2oijoj 3trgtrgrtgrtgr 4gtrjgr 5grtgrtg 6htzhzt 7jztjztj 8fesfnffre 9arefawiufneirg 01forejgoiregiog 02oirjfoirejg 03zthrrtr 04rrtdsefi 05eeeeirg 06mvdvvfvd 07oeweff 08xmcncew 09reiregerg 001rieortert 002iiewfref 003rgrgegeg 004nnbrferf 005wiiewfe 006ootot 007zttt 00822eeewr 009qqeqeun 5abc06defg 05abc6abc 005abc00006aaa fatsort-1.3.365/tests/tc_pos_sort_natural_fat32/Makefile0000775000175000017500000000345212321036667022565 0ustar feanorfeanorinclude ../testconfig.mk FS_FATType=32 # MiBytes FS_SIZE=100 FS_FATs=1 FS_VOL_NAME=test FS_ROOT_ENTRIES=512 FS_RSVD_SEC=32 FS_SEC_PER_CLUS=1 FS_SEC_SIZE=512 DIRECTORIES=directories.txt FILES=files.txt TESTLOG=test.log STDOUT=stdout.log STDOUT_EXP=stdout_expected.txt STDERR=stderr.log STDERR_EXP=stderr_expected.txt all: fsck if [ ${DEL_FS_ON_PASS} -eq 1 ]; then rm -f ${FS_IMG}; fi clean: rm -fr *.log *.tmp ${FS_IMG} ${TMPFILE} ${TMPDIR} if [ -d ${MOUNT_POINT} ]; then \ until sudo umount ${MOUNT_POINT}; do sleep 1; done; \ rmdir ${MOUNT_POINT}; \ fi # create file system mkfs: # ++++++++++ Creating file ${FATType} system ++++++++++ rm -f ${FS_IMG} truncate -s ${FS_SIZE}MB ${FS_IMG} mkfs.vfat -F ${FS_FATType} -f ${FS_FATs} -n ${FS_VOL_NAME} -r ${FS_ROOT_ENTRIES} -R ${FS_RSVD_SEC} -s ${FS_SEC_PER_CLUS} -S ${FS_SEC_SIZE} ${FS_IMG} # populate fs populatefs: mkfs # ++++++++++ Populating file system with directories and files ++++++++++ mkdir -p ${MOUNT_POINT} sudo mount -o loop,codepage=850,iocharset=iso8859-1,utf8,uid=${MOUNT_UID},gid=${MOUNT_GID} ${FS_IMG} ${MOUNT_POINT} cat ${DIRECTORIES} | while read dir; do mkdir -p "${MOUNT_POINT}/$$dir"; done cat ${FILES} | while read file; do touch "${MOUNT_POINT}/$$file"; done # delete some files until sudo umount ${MOUNT_POINT}; do sleep 1; done rmdir ${MOUNT_POINT} # alter file system as necessary for the test alterfs: populatefs # ++++++++++ Altering file system ++++++++++ # empty here rm -fr ${TMPFILE} execute: alterfs # ++++++++++ Executing tests ++++++++++ ${FATSORT} -n ${FS_IMG} ${FATSORT} -l ${FS_IMG} > ${STDOUT} 2> ${STDERR} diff ${STDOUT} ${STDOUT_EXP} diff ${STDERR} ${STDERR_EXP} # check result fsck: execute # ++++++++++ Checking file system ++++++++++ fsck.vfat -n ${FS_IMG} .PHONY: fsck execute populatefs mkfs clean fatsort-1.3.365/tests/tc_pos_sort_natural_fat32/stderr_expected.txt0000664000175000017500000000000012321036667025031 0ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_sort_natural_fat32/stdout_expected.txt0000664000175000017500000000057012321036667025064 0ustar feanorfeanorFile system: FAT32. / 0abcdfgh 0defgh 0zgrth 01forejgoiregiog 1ihihu 001rieortert 002iiewfref 2oijoj 02oirjfoirejg 003rgrgegeg 3trgtrgrtgrtgr 03zthrrtr 4gtrjgr 004nnbrferf 04rrtdsefi 005abc00006aaa 05abc6abc 5abc06defg 05eeeeirg 5grtgrtg 005wiiewfe 6htzhzt 06mvdvvfvd 006ootot 7jztjztj 07oeweff 007zttt 8fesfnffre 08xmcncew 9arefawiufneirg 009qqeqeun 09reiregerg 00822eeewr fatsort-1.3.365/tests/tc_pos_sort_natural_fat32/directories.txt0000664000175000017500000000000012321036667024161 0ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_sort_dir3_fat16/0000775000175000017500000000000012321036667020313 5ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_sort_dir3_fat16/files.txt0000664000175000017500000000064412321036667022162 0ustar feanorfeanorz g u n w e o a c v dir1/z dir1/g dir1/u dir1/n dir1/w dir1/e dir1/o dir1/a dir1/c dir1/v dir2/z dir2/g dir2/u dir2/n dir2/w dir2/e dir2/o dir2/a dir2/c dir2/v dir3/z dir3/g dir3/u dir3/n dir3/w dir3/e dir3/o dir3/a dir3/c dir3/v dir4/z dir4/g dir4/u dir4/n dir4/w dir4/e dir4/o dir4/a dir4/c dir4/v dir4/dir5/z dir4/dir5/g dir4/dir5/u dir4/dir5/n dir4/dir5/w dir4/dir5/e dir4/dir5/o dir4/dir5/a dir4/dir5/c dir4/dir5/v fatsort-1.3.365/tests/tc_pos_sort_dir3_fat16/Makefile0000775000175000017500000000347012321036667021762 0ustar feanorfeanorinclude ../testconfig.mk FS_FATType=16 # MiBytes FS_SIZE=10 FS_FATs=1 FS_VOL_NAME=test FS_ROOT_ENTRIES=512 FS_RSVD_SEC=32 FS_SEC_PER_CLUS=1 FS_SEC_SIZE=512 DIRECTORIES=directories.txt FILES=files.txt TESTLOG=test.log STDOUT=stdout.log STDOUT_EXP=stdout_expected.txt STDERR=stderr.log STDERR_EXP=stderr_expected.txt all: fsck if [ ${DEL_FS_ON_PASS} -eq 1 ]; then rm -f ${FS_IMG}; fi clean: rm -fr *.log *.tmp ${FS_IMG} ${TMPFILE} ${TMPDIR} if [ -d ${MOUNT_POINT} ]; then \ until sudo umount ${MOUNT_POINT}; do sleep 1; done; \ rmdir ${MOUNT_POINT}; \ fi # create file system mkfs: # ++++++++++ Creating file ${FATType} system ++++++++++ rm -f ${FS_IMG} truncate -s ${FS_SIZE}MB ${FS_IMG} mkfs.vfat -F ${FS_FATType} -f ${FS_FATs} -n ${FS_VOL_NAME} -r ${FS_ROOT_ENTRIES} -R ${FS_RSVD_SEC} -s ${FS_SEC_PER_CLUS} -S ${FS_SEC_SIZE} ${FS_IMG} # populate fs populatefs: mkfs # ++++++++++ Populating file system with directories and files ++++++++++ mkdir -p ${MOUNT_POINT} sudo mount -o loop,codepage=850,iocharset=iso8859-1,utf8,uid=${MOUNT_UID},gid=${MOUNT_GID} ${FS_IMG} ${MOUNT_POINT} cat ${DIRECTORIES} | while read dir; do mkdir -p "${MOUNT_POINT}/$$dir"; done cat ${FILES} | while read file; do touch "${MOUNT_POINT}/$$file"; done # delete some files until sudo umount ${MOUNT_POINT}; do sleep 1; done rmdir ${MOUNT_POINT} # alter file system as necessary for the test alterfs: populatefs # ++++++++++ Altering file system ++++++++++ # empty here rm -fr ${TMPFILE} execute: alterfs # ++++++++++ Executing tests ++++++++++ ${FATSORT} -x /dir2 -x /dir4 ${FS_IMG} ${FATSORT} -l ${FS_IMG} > ${STDOUT} 2> ${STDERR} diff ${STDOUT} ${STDOUT_EXP} diff ${STDERR} ${STDERR_EXP} # check result fsck: execute # ++++++++++ Checking file system ++++++++++ fsck.vfat -n ${FS_IMG} .PHONY: fsck execute populatefs mkfs clean fatsort-1.3.365/tests/tc_pos_sort_dir3_fat16/stderr_expected.txt0000664000175000017500000000000012321036667024226 0ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_sort_dir3_fat16/stdout_expected.txt0000664000175000017500000000032612321036667024260 0ustar feanorfeanorFile system: FAT16. / dir1 dir2 dir3 dir4 a c e g n o u v w z /dir1/ a c e g n o u v w z /dir2/ z g u n w e o a c v /dir3/ a c e g n o u v w z /dir4/ dir5 z g u n w e o a c v /dir4/dir5/ a c e g n o u v w z fatsort-1.3.365/tests/tc_pos_sort_dir3_fat16/directories.txt0000664000175000017500000000003112321036667023362 0ustar feanorfeanordir1 dir2 dir3 dir4/dir5 fatsort-1.3.365/tests/Makefile0000775000175000017500000000240612321036667015500 0ustar feanorfeanorSHELL=/bin/bash .PHONY: clean LOGFILE=test_results.log all: @which bbe &>/dev/null || (echo "You need bbe to run the tests!"; false) @which mkfs.vfat &>/dev/null || (echo "You need mkfs.vfat to run the tests!"; false) @which fsck.vfat &>/dev/null || (echo "You need fsck.vfat to run the tests!"; false) @if [ -f ${LOGFILE} ]; then rm -f ${LOGFILE}; fi @failed=0; \ for i in `ls -d tc_*`; do \ if [ ! -f $$i/passed ]; then \ printf "%.70s" "Test case $$i... "; \ printf "[ \e[1;33mWAIT \e[0m]"; \ echo "=============================================" >> ${LOGFILE}; \ echo "Test case $$i" >> ${LOGFILE}; \ echo "=============================================" >> ${LOGFILE}; \ make -C $$i &>> ${LOGFILE}; \ ret=$$?; \ printf "\r%.70s" "Test case $$i... "; \ if [ $$ret -eq 0 ]; then \ printf "[ \e[1;32mPASS \e[0m]\n"; \ else \ printf "[ \e[1;31mFAIL \e[0m]\n"; \ (( failed+=1 )); \ fi; \ fi; \ done; \ if [ $$failed -eq 0 ]; then \ echo "All tests passed."; \ else \ echo $$failed "test(s) failed!"; \ fi clean: rm -f ${LOGFILE} for i in `ls -d tc_*`; do $(MAKE) -C $$i clean || [ 1 ]; done fatsort-1.3.365/tests/tc_neg_faulty_ord_in_lne_in_root_dir_fat16/0000775000175000017500000000000012321036667024436 5ustar feanorfeanorfatsort-1.3.365/tests/tc_neg_faulty_ord_in_lne_in_root_dir_fat16/files.txt0000664000175000017500000000012412321036667026276 0ustar feanorfeanorlong_filename___________________________1 long_filename___________________________2 fatsort-1.3.365/tests/tc_neg_faulty_ord_in_lne_in_root_dir_fat16/Makefile0000775000175000017500000000374412321036667026111 0ustar feanorfeanorinclude ../testconfig.mk FS_FATType=16 # MiBytes FS_SIZE=10 FS_FATs=2 FS_VOL_NAME=test FS_ROOT_ENTRIES=512 FS_RSVD_SEC=32 FS_SEC_PER_CLUS=1 FS_SEC_SIZE=512 DIRECTORIES=directories.txt FILES=files.txt TESTLOG=test.log STDOUT=stdout.log STDOUT_EXP=stdout_expected.txt STDERR=stderr.log STDERR_EXP=stderr_expected.txt # no fsck in negative tests all: execute if [ ${DEL_FS_ON_PASS} -eq 1 ]; then rm -f ${FS_IMG}; fi clean: rm -fr *.log *.tmp ${FS_IMG} ${TMPFILE} ${TMPDIR} if [ -d ${MOUNT_POINT} ]; then \ until sudo umount ${MOUNT_POINT}; do sleep 1; done; \ rmdir ${MOUNT_POINT}; \ fi # create file system mkfs: # ++++++++++ Creating file ${FATType} system ++++++++++ rm -f ${FS_IMG} truncate -s ${FS_SIZE}MB ${FS_IMG} mkfs.vfat -F ${FS_FATType} -f ${FS_FATs} -n ${FS_VOL_NAME} -r ${FS_ROOT_ENTRIES} -R ${FS_RSVD_SEC} -s ${FS_SEC_PER_CLUS} -S ${FS_SEC_SIZE} ${FS_IMG} # populate fs populatefs: mkfs # ++++++++++ Populating file system with directories and files ++++++++++ mkdir -p ${MOUNT_POINT} sudo mount -o loop,codepage=850,iocharset=iso8859-1,utf8,uid=${MOUNT_UID},gid=${MOUNT_GID} ${FS_IMG} ${MOUNT_POINT} cat ${DIRECTORIES} | while read dir; do mkdir -p "${MOUNT_POINT}/$$dir"; done cat ${FILES} | while read file; do touch "${MOUNT_POINT}/$$file"; done rm -f "${MOUNT_POINT}/a" #remove some files rm -f "${MOUNT_POINT}/n" rm -f "${MOUNT_POINT}/z" until sudo umount ${MOUNT_POINT}; do sleep 1; done rmdir ${MOUNT_POINT} # alter file system as necessary for the test alterfs: populatefs # ++++++++++ Altering file system ++++++++++ # change ord in lne ${BBE} -b x17040:1 -e "r 0 \x05" ${FS_IMG} > ${TMPFILE} cp -f ${TMPFILE} ${FS_IMG} rm -fr ${TMPFILE} execute: alterfs # ++++++++++ Executing tests ++++++++++ ${FATSORT} ${FS_IMG} > ${STDOUT} 2> ${STDERR}; [ $$? -ne 0 ] diff ${STDOUT} ${STDOUT_EXP} diff ${STDERR} ${STDERR_EXP} # check result fsck: execute # ++++++++++ Checking file system ++++++++++ fsck.vfat -n ${FS_IMG} .PHONY: fsck execute populatefs mkfs clean fatsort-1.3.365/tests/tc_neg_faulty_ord_in_lne_in_root_dir_fat16/stderr_expected.txt0000664000175000017500000000045212321036667030364 0ustar feanorfeanorcheckLongDirEntries: LongDirEntry number is 0x5 (0x5) but should be 0x3! parseFAT1xRootDirEntries: checkDirEntry failed at root directory entry 5! sortFAT1xRootDirectory: Failed to parse root directory entries! sortFileSystem: Failed to sort FAT16 root directory! main: Failed to sort file system! fatsort-1.3.365/tests/tc_neg_faulty_ord_in_lne_in_root_dir_fat16/stdout_expected.txt0000664000175000017500000000005112321036667030376 0ustar feanorfeanorFile system: FAT16. Sorting directory / fatsort-1.3.365/tests/tc_neg_faulty_ord_in_lne_in_root_dir_fat16/directories.txt0000664000175000017500000000000012321036667027501 0ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_sort_dir2_fat16/0000775000175000017500000000000012321036667020312 5ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_sort_dir2_fat16/files.txt0000664000175000017500000000064412321036667022161 0ustar feanorfeanorz g u n w e o a c v dir1/z dir1/g dir1/u dir1/n dir1/w dir1/e dir1/o dir1/a dir1/c dir1/v dir2/z dir2/g dir2/u dir2/n dir2/w dir2/e dir2/o dir2/a dir2/c dir2/v dir3/z dir3/g dir3/u dir3/n dir3/w dir3/e dir3/o dir3/a dir3/c dir3/v dir4/z dir4/g dir4/u dir4/n dir4/w dir4/e dir4/o dir4/a dir4/c dir4/v dir4/dir5/z dir4/dir5/g dir4/dir5/u dir4/dir5/n dir4/dir5/w dir4/dir5/e dir4/dir5/o dir4/dir5/a dir4/dir5/c dir4/dir5/v fatsort-1.3.365/tests/tc_pos_sort_dir2_fat16/Makefile0000775000175000017500000000345712321036667021766 0ustar feanorfeanorinclude ../testconfig.mk FS_FATType=16 # MiBytes FS_SIZE=10 FS_FATs=1 FS_VOL_NAME=test FS_ROOT_ENTRIES=512 FS_RSVD_SEC=32 FS_SEC_PER_CLUS=1 FS_SEC_SIZE=512 DIRECTORIES=directories.txt FILES=files.txt TESTLOG=test.log STDOUT=stdout.log STDOUT_EXP=stdout_expected.txt STDERR=stderr.log STDERR_EXP=stderr_expected.txt all: fsck if [ ${DEL_FS_ON_PASS} -eq 1 ]; then rm -f ${FS_IMG}; fi clean: rm -fr *.log *.tmp ${FS_IMG} ${TMPFILE} ${TMPDIR} if [ -d ${MOUNT_POINT} ]; then \ until sudo umount ${MOUNT_POINT}; do sleep 1; done; \ rmdir ${MOUNT_POINT}; \ fi # create file system mkfs: # ++++++++++ Creating file ${FATType} system ++++++++++ rm -f ${FS_IMG} truncate -s ${FS_SIZE}MB ${FS_IMG} mkfs.vfat -F ${FS_FATType} -f ${FS_FATs} -n ${FS_VOL_NAME} -r ${FS_ROOT_ENTRIES} -R ${FS_RSVD_SEC} -s ${FS_SEC_PER_CLUS} -S ${FS_SEC_SIZE} ${FS_IMG} # populate fs populatefs: mkfs # ++++++++++ Populating file system with directories and files ++++++++++ mkdir -p ${MOUNT_POINT} sudo mount -o loop,codepage=850,iocharset=iso8859-1,utf8,uid=${MOUNT_UID},gid=${MOUNT_GID} ${FS_IMG} ${MOUNT_POINT} cat ${DIRECTORIES} | while read dir; do mkdir -p "${MOUNT_POINT}/$$dir"; done cat ${FILES} | while read file; do touch "${MOUNT_POINT}/$$file"; done # delete some files until sudo umount ${MOUNT_POINT}; do sleep 1; done rmdir ${MOUNT_POINT} # alter file system as necessary for the test alterfs: populatefs # ++++++++++ Altering file system ++++++++++ # empty here rm -fr ${TMPFILE} execute: alterfs # ++++++++++ Executing tests ++++++++++ ${FATSORT} -D /dir4 ${FS_IMG} ${FATSORT} -l ${FS_IMG} > ${STDOUT} 2> ${STDERR} diff ${STDOUT} ${STDOUT_EXP} diff ${STDERR} ${STDERR_EXP} # check result fsck: execute # ++++++++++ Checking file system ++++++++++ fsck.vfat -n ${FS_IMG} .PHONY: fsck execute populatefs mkfs clean fatsort-1.3.365/tests/tc_pos_sort_dir2_fat16/stderr_expected.txt0000664000175000017500000000000012321036667024225 0ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_sort_dir2_fat16/stdout_expected.txt0000664000175000017500000000032612321036667024257 0ustar feanorfeanorFile system: FAT16. / dir1 dir2 dir3 dir4 z g u n w e o a c v /dir1/ z g u n w e o a c v /dir2/ z g u n w e o a c v /dir3/ z g u n w e o a c v /dir4/ dir5 a c e g n o u v w z /dir4/dir5/ a c e g n o u v w z fatsort-1.3.365/tests/tc_pos_sort_dir2_fat16/directories.txt0000664000175000017500000000003112321036667023361 0ustar feanorfeanordir1 dir2 dir3 dir4/dir5 fatsort-1.3.365/tests/tc_pos_sort_dir2_fat12/0000775000175000017500000000000012321036667020306 5ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_sort_dir2_fat12/files.txt0000664000175000017500000000064412321036667022155 0ustar feanorfeanorz g u n w e o a c v dir1/z dir1/g dir1/u dir1/n dir1/w dir1/e dir1/o dir1/a dir1/c dir1/v dir2/z dir2/g dir2/u dir2/n dir2/w dir2/e dir2/o dir2/a dir2/c dir2/v dir3/z dir3/g dir3/u dir3/n dir3/w dir3/e dir3/o dir3/a dir3/c dir3/v dir4/z dir4/g dir4/u dir4/n dir4/w dir4/e dir4/o dir4/a dir4/c dir4/v dir4/dir5/z dir4/dir5/g dir4/dir5/u dir4/dir5/n dir4/dir5/w dir4/dir5/e dir4/dir5/o dir4/dir5/a dir4/dir5/c dir4/dir5/v fatsort-1.3.365/tests/tc_pos_sort_dir2_fat12/Makefile0000775000175000017500000000346012321036667021754 0ustar feanorfeanorinclude ../testconfig.mk FS_FATType=12 # MiBytes FS_SIZE=10 FS_FATs=1 FS_VOL_NAME=test FS_ROOT_ENTRIES=512 FS_RSVD_SEC=32 FS_SEC_PER_CLUS=16 FS_SEC_SIZE=512 DIRECTORIES=directories.txt FILES=files.txt TESTLOG=test.log STDOUT=stdout.log STDOUT_EXP=stdout_expected.txt STDERR=stderr.log STDERR_EXP=stderr_expected.txt all: fsck if [ ${DEL_FS_ON_PASS} -eq 1 ]; then rm -f ${FS_IMG}; fi clean: rm -fr *.log *.tmp ${FS_IMG} ${TMPFILE} ${TMPDIR} if [ -d ${MOUNT_POINT} ]; then \ until sudo umount ${MOUNT_POINT}; do sleep 1; done; \ rmdir ${MOUNT_POINT}; \ fi # create file system mkfs: # ++++++++++ Creating file ${FATType} system ++++++++++ rm -f ${FS_IMG} truncate -s ${FS_SIZE}MB ${FS_IMG} mkfs.vfat -F ${FS_FATType} -f ${FS_FATs} -n ${FS_VOL_NAME} -r ${FS_ROOT_ENTRIES} -R ${FS_RSVD_SEC} -s ${FS_SEC_PER_CLUS} -S ${FS_SEC_SIZE} ${FS_IMG} # populate fs populatefs: mkfs # ++++++++++ Populating file system with directories and files ++++++++++ mkdir -p ${MOUNT_POINT} sudo mount -o loop,codepage=850,iocharset=iso8859-1,utf8,uid=${MOUNT_UID},gid=${MOUNT_GID} ${FS_IMG} ${MOUNT_POINT} cat ${DIRECTORIES} | while read dir; do mkdir -p "${MOUNT_POINT}/$$dir"; done cat ${FILES} | while read file; do touch "${MOUNT_POINT}/$$file"; done # delete some files until sudo umount ${MOUNT_POINT}; do sleep 1; done rmdir ${MOUNT_POINT} # alter file system as necessary for the test alterfs: populatefs # ++++++++++ Altering file system ++++++++++ # empty here rm -fr ${TMPFILE} execute: alterfs # ++++++++++ Executing tests ++++++++++ ${FATSORT} -D /dir4 ${FS_IMG} ${FATSORT} -l ${FS_IMG} > ${STDOUT} 2> ${STDERR} diff ${STDOUT} ${STDOUT_EXP} diff ${STDERR} ${STDERR_EXP} # check result fsck: execute # ++++++++++ Checking file system ++++++++++ fsck.vfat -n ${FS_IMG} .PHONY: fsck execute populatefs mkfs clean fatsort-1.3.365/tests/tc_pos_sort_dir2_fat12/stderr_expected.txt0000664000175000017500000000000012321036667024221 0ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_sort_dir2_fat12/stdout_expected.txt0000664000175000017500000000032612321036667024253 0ustar feanorfeanorFile system: FAT12. / dir1 dir2 dir3 dir4 z g u n w e o a c v /dir1/ z g u n w e o a c v /dir2/ z g u n w e o a c v /dir3/ z g u n w e o a c v /dir4/ dir5 a c e g n o u v w z /dir4/dir5/ a c e g n o u v w z fatsort-1.3.365/tests/tc_pos_sort_dir2_fat12/directories.txt0000664000175000017500000000003112321036667023355 0ustar feanorfeanordir1 dir2 dir3 dir4/dir5 fatsort-1.3.365/tests/tc_pos_sort_natural_fat12/0000775000175000017500000000000012321036666021113 5ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_sort_natural_fat12/files.txt0000664000175000017500000000054012321036666022755 0ustar feanorfeanor0abcdfgh 0defgh 0zgrth 1ihihu 2oijoj 3trgtrgrtgrtgr 4gtrjgr 5grtgrtg 6htzhzt 7jztjztj 8fesfnffre 9arefawiufneirg 01forejgoiregiog 02oirjfoirejg 03zthrrtr 04rrtdsefi 05eeeeirg 06mvdvvfvd 07oeweff 08xmcncew 09reiregerg 001rieortert 002iiewfref 003rgrgegeg 004nnbrferf 005wiiewfe 006ootot 007zttt 00822eeewr 009qqeqeun 5abc06defg 05abc6abc 005abc00006aaa fatsort-1.3.365/tests/tc_pos_sort_natural_fat12/Makefile0000775000175000017500000000345212321036666022562 0ustar feanorfeanorinclude ../testconfig.mk FS_FATType=12 # MiBytes FS_SIZE=10 FS_FATs=1 FS_VOL_NAME=test FS_ROOT_ENTRIES=512 FS_RSVD_SEC=32 FS_SEC_PER_CLUS=16 FS_SEC_SIZE=512 DIRECTORIES=directories.txt FILES=files.txt TESTLOG=test.log STDOUT=stdout.log STDOUT_EXP=stdout_expected.txt STDERR=stderr.log STDERR_EXP=stderr_expected.txt all: fsck if [ ${DEL_FS_ON_PASS} -eq 1 ]; then rm -f ${FS_IMG}; fi clean: rm -fr *.log *.tmp ${FS_IMG} ${TMPFILE} ${TMPDIR} if [ -d ${MOUNT_POINT} ]; then \ until sudo umount ${MOUNT_POINT}; do sleep 1; done; \ rmdir ${MOUNT_POINT}; \ fi # create file system mkfs: # ++++++++++ Creating file ${FATType} system ++++++++++ rm -f ${FS_IMG} truncate -s ${FS_SIZE}MB ${FS_IMG} mkfs.vfat -F ${FS_FATType} -f ${FS_FATs} -n ${FS_VOL_NAME} -r ${FS_ROOT_ENTRIES} -R ${FS_RSVD_SEC} -s ${FS_SEC_PER_CLUS} -S ${FS_SEC_SIZE} ${FS_IMG} # populate fs populatefs: mkfs # ++++++++++ Populating file system with directories and files ++++++++++ mkdir -p ${MOUNT_POINT} sudo mount -o loop,codepage=850,iocharset=iso8859-1,utf8,uid=${MOUNT_UID},gid=${MOUNT_GID} ${FS_IMG} ${MOUNT_POINT} cat ${DIRECTORIES} | while read dir; do mkdir -p "${MOUNT_POINT}/$$dir"; done cat ${FILES} | while read file; do touch "${MOUNT_POINT}/$$file"; done # delete some files until sudo umount ${MOUNT_POINT}; do sleep 1; done rmdir ${MOUNT_POINT} # alter file system as necessary for the test alterfs: populatefs # ++++++++++ Altering file system ++++++++++ # empty here rm -fr ${TMPFILE} execute: alterfs # ++++++++++ Executing tests ++++++++++ ${FATSORT} -n ${FS_IMG} ${FATSORT} -l ${FS_IMG} > ${STDOUT} 2> ${STDERR} diff ${STDOUT} ${STDOUT_EXP} diff ${STDERR} ${STDERR_EXP} # check result fsck: execute # ++++++++++ Checking file system ++++++++++ fsck.vfat -n ${FS_IMG} .PHONY: fsck execute populatefs mkfs clean fatsort-1.3.365/tests/tc_pos_sort_natural_fat12/stderr_expected.txt0000664000175000017500000000000012321036666025026 0ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_sort_natural_fat12/stdout_expected.txt0000664000175000017500000000057012321036666025061 0ustar feanorfeanorFile system: FAT12. / 0abcdfgh 0defgh 0zgrth 01forejgoiregiog 1ihihu 001rieortert 002iiewfref 2oijoj 02oirjfoirejg 003rgrgegeg 3trgtrgrtgrtgr 03zthrrtr 4gtrjgr 004nnbrferf 04rrtdsefi 005abc00006aaa 05abc6abc 5abc06defg 05eeeeirg 5grtgrtg 005wiiewfe 6htzhzt 06mvdvvfvd 006ootot 7jztjztj 07oeweff 007zttt 8fesfnffre 08xmcncew 9arefawiufneirg 009qqeqeun 09reiregerg 00822eeewr fatsort-1.3.365/tests/tc_pos_sort_natural_fat12/directories.txt0000664000175000017500000000000012321036666024156 0ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_sort_dir4_fat16/0000775000175000017500000000000012321036667020314 5ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_sort_dir4_fat16/files.txt0000664000175000017500000000064412321036667022163 0ustar feanorfeanorz g u n w e o a c v dir1/z dir1/g dir1/u dir1/n dir1/w dir1/e dir1/o dir1/a dir1/c dir1/v dir2/z dir2/g dir2/u dir2/n dir2/w dir2/e dir2/o dir2/a dir2/c dir2/v dir3/z dir3/g dir3/u dir3/n dir3/w dir3/e dir3/o dir3/a dir3/c dir3/v dir4/z dir4/g dir4/u dir4/n dir4/w dir4/e dir4/o dir4/a dir4/c dir4/v dir4/dir5/z dir4/dir5/g dir4/dir5/u dir4/dir5/n dir4/dir5/w dir4/dir5/e dir4/dir5/o dir4/dir5/a dir4/dir5/c dir4/dir5/v fatsort-1.3.365/tests/tc_pos_sort_dir4_fat16/Makefile0000775000175000017500000000345712321036667021770 0ustar feanorfeanorinclude ../testconfig.mk FS_FATType=16 # MiBytes FS_SIZE=10 FS_FATs=1 FS_VOL_NAME=test FS_ROOT_ENTRIES=512 FS_RSVD_SEC=32 FS_SEC_PER_CLUS=1 FS_SEC_SIZE=512 DIRECTORIES=directories.txt FILES=files.txt TESTLOG=test.log STDOUT=stdout.log STDOUT_EXP=stdout_expected.txt STDERR=stderr.log STDERR_EXP=stderr_expected.txt all: fsck if [ ${DEL_FS_ON_PASS} -eq 1 ]; then rm -f ${FS_IMG}; fi clean: rm -fr *.log *.tmp ${FS_IMG} ${TMPFILE} ${TMPDIR} if [ -d ${MOUNT_POINT} ]; then \ until sudo umount ${MOUNT_POINT}; do sleep 1; done; \ rmdir ${MOUNT_POINT}; \ fi # create file system mkfs: # ++++++++++ Creating file ${FATType} system ++++++++++ rm -f ${FS_IMG} truncate -s ${FS_SIZE}MB ${FS_IMG} mkfs.vfat -F ${FS_FATType} -f ${FS_FATs} -n ${FS_VOL_NAME} -r ${FS_ROOT_ENTRIES} -R ${FS_RSVD_SEC} -s ${FS_SEC_PER_CLUS} -S ${FS_SEC_SIZE} ${FS_IMG} # populate fs populatefs: mkfs # ++++++++++ Populating file system with directories and files ++++++++++ mkdir -p ${MOUNT_POINT} sudo mount -o loop,codepage=850,iocharset=iso8859-1,utf8,uid=${MOUNT_UID},gid=${MOUNT_GID} ${FS_IMG} ${MOUNT_POINT} cat ${DIRECTORIES} | while read dir; do mkdir -p "${MOUNT_POINT}/$$dir"; done cat ${FILES} | while read file; do touch "${MOUNT_POINT}/$$file"; done # delete some files until sudo umount ${MOUNT_POINT}; do sleep 1; done rmdir ${MOUNT_POINT} # alter file system as necessary for the test alterfs: populatefs # ++++++++++ Altering file system ++++++++++ # empty here rm -fr ${TMPFILE} execute: alterfs # ++++++++++ Executing tests ++++++++++ ${FATSORT} -X /dir4 ${FS_IMG} ${FATSORT} -l ${FS_IMG} > ${STDOUT} 2> ${STDERR} diff ${STDOUT} ${STDOUT_EXP} diff ${STDERR} ${STDERR_EXP} # check result fsck: execute # ++++++++++ Checking file system ++++++++++ fsck.vfat -n ${FS_IMG} .PHONY: fsck execute populatefs mkfs clean fatsort-1.3.365/tests/tc_pos_sort_dir4_fat16/stderr_expected.txt0000664000175000017500000000000012321036667024227 0ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_sort_dir4_fat16/stdout_expected.txt0000664000175000017500000000032612321036667024261 0ustar feanorfeanorFile system: FAT16. / dir1 dir2 dir3 dir4 a c e g n o u v w z /dir1/ a c e g n o u v w z /dir2/ a c e g n o u v w z /dir3/ a c e g n o u v w z /dir4/ dir5 z g u n w e o a c v /dir4/dir5/ z g u n w e o a c v fatsort-1.3.365/tests/tc_pos_sort_dir4_fat16/directories.txt0000664000175000017500000000003112321036667023363 0ustar feanorfeanordir1 dir2 dir3 dir4/dir5 fatsort-1.3.365/tests/tc_pos_sort_case_fat16/0000775000175000017500000000000012321036667020365 5ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_sort_case_fat16/files.txt0000664000175000017500000000043112321036667022226 0ustar feanorfeanora b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z Ä Ö Ü file3.bin file2.bin file1.bin Long file name with lots of words and characters just to test long file name entries in FAT file systems 1 2 3 4 5 6 7 8 9 10 01b 1a 001c fatsort-1.3.365/tests/tc_pos_sort_case_fat16/Makefile0000775000175000017500000000342412321036667022033 0ustar feanorfeanorinclude ../testconfig.mk FS_FATType=16 # MiBytes FS_SIZE=10 FS_FATs=1 FS_VOL_NAME=test FS_ROOT_ENTRIES=512 FS_RSVD_SEC=32 FS_SEC_PER_CLUS=1 FS_SEC_SIZE=512 DIRECTORIES=directories.txt FILES=files.txt TESTLOG=test.log STDOUT=stdout.log STDOUT_EXP=stdout_expected.txt STDERR=stderr.log STDERR_EXP=stderr_expected.txt all: fsck if [ ${DEL_FS_ON_PASS} -eq 1 ]; then rm -f ${FS_IMG}; fi clean: rm -fr *.log *.tmp ${FS_IMG} ${TMPFILE} ${TMPDIR} if [ -d ${MOUNT_POINT} ]; then \ until sudo umount ${MOUNT_POINT}; do sleep 1; done; \ rmdir ${MOUNT_POINT}; \ fi # create file system mkfs: # ++++++++++ Creating file ${FATType} system ++++++++++ rm -f ${FS_IMG} truncate -s ${FS_SIZE}MB ${FS_IMG} mkfs.vfat -F ${FS_FATType} -f ${FS_FATs} -n ${FS_VOL_NAME} -r ${FS_ROOT_ENTRIES} -R ${FS_RSVD_SEC} -s ${FS_SEC_PER_CLUS} -S ${FS_SEC_SIZE} ${FS_IMG} # populate fs populatefs: mkfs # ++++++++++ Populating file system with directories and files ++++++++++ mkdir -p ${MOUNT_POINT} sudo mount -o loop,codepage=850,iocharset=iso8859-1,utf8,uid=${MOUNT_UID},gid=${MOUNT_GID} ${FS_IMG} ${MOUNT_POINT} cat ${DIRECTORIES} | while read dir; do mkdir -p "${MOUNT_POINT}/$$dir"; done cat ${FILES} | while read file; do touch "${MOUNT_POINT}/$$file"; done until sudo umount ${MOUNT_POINT}; do sleep 1; done rmdir ${MOUNT_POINT} # alter file system as necessary for the test alterfs: populatefs # ++++++++++ Altering file system ++++++++++ # empty here rm -fr ${TMPFILE} execute: alterfs # ++++++++++ Executing tests ++++++++++ ${FATSORT} -c ${FS_IMG} ${FATSORT} -l ${FS_IMG} > ${STDOUT} 2> ${STDERR} diff ${STDOUT} ${STDOUT_EXP} diff ${STDERR} ${STDERR_EXP} # check result fsck: execute # ++++++++++ Checking file system ++++++++++ fsck.vfat -n ${FS_IMG} .PHONY: fsck execute populatefs mkfs clean fatsort-1.3.365/tests/tc_pos_sort_case_fat16/stderr_expected.txt0000664000175000017500000000000012321036667024300 0ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_sort_case_fat16/stdout_expected.txt0000664000175000017500000000052212321036667024330 0ustar feanorfeanorFile system: FAT16. / dir3 Directory1 directory2 001c 01b 1 10 1a 2 3 4 5 6 7 8 9 a Ä b c d e f file1.bin file2.bin file3.bin g h i j k l Long file name with lots of words and characters just to test long file name entries in FAT file systems m n o Ö p q r s t u Ü v w x y z /dir3/ subDir /dir3/subDir/ /Directory1/ /directory2/ fatsort-1.3.365/tests/tc_pos_sort_case_fat16/directories.txt0000664000175000017500000000004212321036667023436 0ustar feanorfeanorDirectory1 directory2 dir3/subDir fatsort-1.3.365/tests/tc_pos_sort_order_directories_fat32/0000775000175000017500000000000012321036667023157 5ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_sort_order_directories_fat32/files.txt0000664000175000017500000000043112321036667025020 0ustar feanorfeanora b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z Ä Ö Ü file3.bin file2.bin file1.bin Long file name with lots of words and characters just to test long file name entries in FAT file systems 1 2 3 4 5 6 7 8 9 10 01b 1a 001c fatsort-1.3.365/tests/tc_pos_sort_order_directories_fat32/Makefile0000775000175000017500000000345312321036667024627 0ustar feanorfeanorinclude ../testconfig.mk FS_FATType=32 # MiBytes FS_SIZE=100 FS_FATs=1 FS_VOL_NAME=test FS_ROOT_ENTRIES=512 FS_RSVD_SEC=32 FS_SEC_PER_CLUS=1 FS_SEC_SIZE=512 DIRECTORIES=directories.txt FILES=files.txt TESTLOG=test.log STDOUT=stdout.log STDOUT_EXP=stdout_expected.txt STDERR=stderr.log STDERR_EXP=stderr_expected.txt all: fsck if [ ${DEL_FS_ON_PASS} -eq 1 ]; then rm -f ${FS_IMG}; fi clean: rm -fr *.log *.tmp ${FS_IMG} ${TMPFILE} ${TMPDIR} if [ -d ${MOUNT_POINT} ]; then \ until sudo umount ${MOUNT_POINT}; do sleep 1; done; \ rmdir ${MOUNT_POINT}; \ fi # create file system mkfs: # ++++++++++ Creating file ${FATType} system ++++++++++ rm -f ${FS_IMG} truncate -s ${FS_SIZE}MB ${FS_IMG} mkfs.vfat -F ${FS_FATType} -f ${FS_FATs} -n ${FS_VOL_NAME} -r ${FS_ROOT_ENTRIES} -R ${FS_RSVD_SEC} -s ${FS_SEC_PER_CLUS} -S ${FS_SEC_SIZE} ${FS_IMG} # populate fs populatefs: mkfs # ++++++++++ Populating file system with directories and files ++++++++++ mkdir -p ${MOUNT_POINT} sudo mount -o loop,codepage=850,iocharset=iso8859-1,utf8,uid=${MOUNT_UID},gid=${MOUNT_GID} ${FS_IMG} ${MOUNT_POINT} cat ${DIRECTORIES} | while read dir; do mkdir -p "${MOUNT_POINT}/$$dir"; done cat ${FILES} | while read file; do touch "${MOUNT_POINT}/$$file"; done # delete some files until sudo umount ${MOUNT_POINT}; do sleep 1; done rmdir ${MOUNT_POINT} # alter file system as necessary for the test alterfs: populatefs # ++++++++++ Altering file system ++++++++++ # empty here rm -fr ${TMPFILE} execute: alterfs # ++++++++++ Executing tests ++++++++++ ${FATSORT} -od ${FS_IMG} ${FATSORT} -l ${FS_IMG} > ${STDOUT} 2> ${STDERR} diff ${STDOUT} ${STDOUT_EXP} diff ${STDERR} ${STDERR_EXP} # check result fsck: execute # ++++++++++ Checking file system ++++++++++ fsck.vfat -n ${FS_IMG} .PHONY: fsck execute populatefs mkfs clean fatsort-1.3.365/tests/tc_pos_sort_order_directories_fat32/stderr_expected.txt0000664000175000017500000000000012321036667027072 0ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_sort_order_directories_fat32/stdout_expected.txt0000664000175000017500000000052212321036667027122 0ustar feanorfeanorFile system: FAT32. / dir3 Directory1 directory2 001c 01b 1 10 1a 2 3 4 5 6 7 8 9 a Ä b c d e f file1.bin file2.bin file3.bin g h i j k l Long file name with lots of words and characters just to test long file name entries in FAT file systems m n o Ö p q r s t u Ü v w x y z /dir3/ subDir /dir3/subDir/ /Directory1/ /directory2/ fatsort-1.3.365/tests/tc_pos_sort_order_directories_fat32/directories.txt0000664000175000017500000000004212321036667026230 0ustar feanorfeanorDirectory1 directory2 dir3/subDir fatsort-1.3.365/tests/tc_neg_missing_sne_in_root_dir_fat32/0000775000175000017500000000000012321036667023256 5ustar feanorfeanorfatsort-1.3.365/tests/tc_neg_missing_sne_in_root_dir_fat32/files.txt0000664000175000017500000000012412321036667025116 0ustar feanorfeanorlong_filename___________________________1 long_filename___________________________2 fatsort-1.3.365/tests/tc_neg_missing_sne_in_root_dir_fat32/Makefile0000775000175000017500000000414012321036667024720 0ustar feanorfeanorinclude ../testconfig.mk FS_FATType=32 # 100 MiBytes FS_SIZE=100 FS_FATs=2 FS_VOL_NAME=test FS_ROOT_ENTRIES=512 FS_RSVD_SEC=32 FS_SEC_PER_CLUS=1 FS_SEC_SIZE=512 DIRECTORIES=directories.txt FILES=files.txt TESTLOG=test.log STDOUT=stdout.log STDOUT_EXP=stdout_expected.txt STDERR=stderr.log STDERR_EXP=stderr_expected.txt # no fsck in negative tests all: execute if [ ${DEL_FS_ON_PASS} -eq 1 ]; then rm -f ${FS_IMG}; fi clean: rm -fr *.log *.tmp ${FS_IMG} ${TMPFILE} ${TMPDIR} if [ -d ${MOUNT_POINT} ]; then \ until sudo umount ${MOUNT_POINT}; do sleep 1; done; \ rmdir ${MOUNT_POINT}; \ fi # create file system mkfs: # ++++++++++ Creating file ${FATType} system ++++++++++ rm -f ${FS_IMG} truncate -s ${FS_SIZE}MB ${FS_IMG} mkfs.vfat -F ${FS_FATType} -f ${FS_FATs} -n ${FS_VOL_NAME} -r ${FS_ROOT_ENTRIES} -R ${FS_RSVD_SEC} -s ${FS_SEC_PER_CLUS} -S ${FS_SEC_SIZE} ${FS_IMG} # populate fs populatefs: mkfs # ++++++++++ Populating file system with directories and files ++++++++++ mkdir -p ${MOUNT_POINT} sudo mount -o loop,codepage=850,iocharset=iso8859-1,utf8,uid=${MOUNT_UID},gid=${MOUNT_GID} ${FS_IMG} ${MOUNT_POINT} cat ${DIRECTORIES} | while read dir; do mkdir -p "${MOUNT_POINT}/$$dir"; done cat ${FILES} | while read file; do touch "${MOUNT_POINT}/$$file"; done rm -f "${MOUNT_POINT}/a" #remove some files rm -f "${MOUNT_POINT}/n" rm -f "${MOUNT_POINT}/z" until sudo umount ${MOUNT_POINT}; do sleep 1; done rmdir ${MOUNT_POINT} # alter file system as necessary for the test alterfs: populatefs # ++++++++++ Altering file system ++++++++++ # remove sne ${BBE} -b x17bca0:32 -e "r 0 \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" ${FS_IMG} > ${TMPFILE} cp -f ${TMPFILE} ${FS_IMG} rm -fr ${TMPFILE} execute: alterfs # ++++++++++ Executing tests ++++++++++ ${FATSORT} ${FS_IMG} > ${STDOUT} 2> ${STDERR}; [ $$? -ne 0 ] diff ${STDOUT} ${STDOUT_EXP} diff ${STDERR} ${STDERR_EXP} # check result fsck: execute # ++++++++++ Checking file system ++++++++++ fsck.vfat -n ${FS_IMG} .PHONY: fsck execute populatefs mkfs clean fatsort-1.3.365/tests/tc_neg_missing_sne_in_root_dir_fat32/stderr_expected.txt0000664000175000017500000000034612321036667027206 0ustar feanorfeanorparseClusterChain: ShortDirEntry is missing after LongDirEntries (cluster: 00000002, entry 5)! sortClusterChain: Failed to parse cluster chain! sortFileSystem: Failed to sort first cluster chain! main: Failed to sort file system! fatsort-1.3.365/tests/tc_neg_missing_sne_in_root_dir_fat32/stdout_expected.txt0000664000175000017500000000005112321036667027216 0ustar feanorfeanorFile system: FAT32. Sorting directory / fatsort-1.3.365/tests/tc_neg_missing_sne_in_root_dir_fat32/directories.txt0000664000175000017500000000000012321036667026321 0ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_sort_dir1_fat16/0000775000175000017500000000000012321036667020311 5ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_sort_dir1_fat16/files.txt0000664000175000017500000000064412321036667022160 0ustar feanorfeanorz g u n w e o a c v dir1/z dir1/g dir1/u dir1/n dir1/w dir1/e dir1/o dir1/a dir1/c dir1/v dir2/z dir2/g dir2/u dir2/n dir2/w dir2/e dir2/o dir2/a dir2/c dir2/v dir3/z dir3/g dir3/u dir3/n dir3/w dir3/e dir3/o dir3/a dir3/c dir3/v dir4/z dir4/g dir4/u dir4/n dir4/w dir4/e dir4/o dir4/a dir4/c dir4/v dir4/dir5/z dir4/dir5/g dir4/dir5/u dir4/dir5/n dir4/dir5/w dir4/dir5/e dir4/dir5/o dir4/dir5/a dir4/dir5/c dir4/dir5/v fatsort-1.3.365/tests/tc_pos_sort_dir1_fat16/Makefile0000775000175000017500000000347012321036667021760 0ustar feanorfeanorinclude ../testconfig.mk FS_FATType=16 # MiBytes FS_SIZE=10 FS_FATs=1 FS_VOL_NAME=test FS_ROOT_ENTRIES=512 FS_RSVD_SEC=32 FS_SEC_PER_CLUS=1 FS_SEC_SIZE=512 DIRECTORIES=directories.txt FILES=files.txt TESTLOG=test.log STDOUT=stdout.log STDOUT_EXP=stdout_expected.txt STDERR=stderr.log STDERR_EXP=stderr_expected.txt all: fsck if [ ${DEL_FS_ON_PASS} -eq 1 ]; then rm -f ${FS_IMG}; fi clean: rm -fr *.log *.tmp ${FS_IMG} ${TMPFILE} ${TMPDIR} if [ -d ${MOUNT_POINT} ]; then \ until sudo umount ${MOUNT_POINT}; do sleep 1; done; \ rmdir ${MOUNT_POINT}; \ fi # create file system mkfs: # ++++++++++ Creating file ${FATType} system ++++++++++ rm -f ${FS_IMG} truncate -s ${FS_SIZE}MB ${FS_IMG} mkfs.vfat -F ${FS_FATType} -f ${FS_FATs} -n ${FS_VOL_NAME} -r ${FS_ROOT_ENTRIES} -R ${FS_RSVD_SEC} -s ${FS_SEC_PER_CLUS} -S ${FS_SEC_SIZE} ${FS_IMG} # populate fs populatefs: mkfs # ++++++++++ Populating file system with directories and files ++++++++++ mkdir -p ${MOUNT_POINT} sudo mount -o loop,codepage=850,iocharset=iso8859-1,utf8,uid=${MOUNT_UID},gid=${MOUNT_GID} ${FS_IMG} ${MOUNT_POINT} cat ${DIRECTORIES} | while read dir; do mkdir -p "${MOUNT_POINT}/$$dir"; done cat ${FILES} | while read file; do touch "${MOUNT_POINT}/$$file"; done # delete some files until sudo umount ${MOUNT_POINT}; do sleep 1; done rmdir ${MOUNT_POINT} # alter file system as necessary for the test alterfs: populatefs # ++++++++++ Altering file system ++++++++++ # empty here rm -fr ${TMPFILE} execute: alterfs # ++++++++++ Executing tests ++++++++++ ${FATSORT} -d /dir1 -d /dir3 ${FS_IMG} ${FATSORT} -l ${FS_IMG} > ${STDOUT} 2> ${STDERR} diff ${STDOUT} ${STDOUT_EXP} diff ${STDERR} ${STDERR_EXP} # check result fsck: execute # ++++++++++ Checking file system ++++++++++ fsck.vfat -n ${FS_IMG} .PHONY: fsck execute populatefs mkfs clean fatsort-1.3.365/tests/tc_pos_sort_dir1_fat16/stderr_expected.txt0000664000175000017500000000000012321036667024224 0ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_sort_dir1_fat16/stdout_expected.txt0000664000175000017500000000032612321036667024256 0ustar feanorfeanorFile system: FAT16. / dir1 dir2 dir3 dir4 z g u n w e o a c v /dir1/ a c e g n o u v w z /dir2/ z g u n w e o a c v /dir3/ a c e g n o u v w z /dir4/ dir5 z g u n w e o a c v /dir4/dir5/ z g u n w e o a c v fatsort-1.3.365/tests/tc_pos_sort_dir1_fat16/directories.txt0000664000175000017500000000003112321036667023360 0ustar feanorfeanordir1 dir2 dir3 dir4/dir5 fatsort-1.3.365/tests/tc_pos_sort_dir5_fat32/0000775000175000017500000000000012321036667020313 5ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_sort_dir5_fat32/files.txt0000664000175000017500000000064412321036667022162 0ustar feanorfeanorz g u n w e o a c v dir1/z dir1/g dir1/u dir1/n dir1/w dir1/e dir1/o dir1/a dir1/c dir1/v dir2/z dir2/g dir2/u dir2/n dir2/w dir2/e dir2/o dir2/a dir2/c dir2/v dir3/z dir3/g dir3/u dir3/n dir3/w dir3/e dir3/o dir3/a dir3/c dir3/v dir4/z dir4/g dir4/u dir4/n dir4/w dir4/e dir4/o dir4/a dir4/c dir4/v dir4/dir5/z dir4/dir5/g dir4/dir5/u dir4/dir5/n dir4/dir5/w dir4/dir5/e dir4/dir5/o dir4/dir5/a dir4/dir5/c dir4/dir5/v fatsort-1.3.365/tests/tc_pos_sort_dir5_fat32/Makefile0000775000175000017500000000347412321036667021766 0ustar feanorfeanorinclude ../testconfig.mk FS_FATType=32 # MiBytes FS_SIZE=100 FS_FATs=1 FS_VOL_NAME=test FS_ROOT_ENTRIES=512 FS_RSVD_SEC=32 FS_SEC_PER_CLUS=1 FS_SEC_SIZE=512 DIRECTORIES=directories.txt FILES=files.txt TESTLOG=test.log STDOUT=stdout.log STDOUT_EXP=stdout_expected.txt STDERR=stderr.log STDERR_EXP=stderr_expected.txt all: fsck if [ ${DEL_FS_ON_PASS} -eq 1 ]; then rm -f ${FS_IMG}; fi clean: rm -fr *.log *.tmp ${FS_IMG} ${TMPFILE} ${TMPDIR} if [ -d ${MOUNT_POINT} ]; then \ until sudo umount ${MOUNT_POINT}; do sleep 1; done; \ rmdir ${MOUNT_POINT}; \ fi # create file system mkfs: # ++++++++++ Creating file ${FATType} system ++++++++++ rm -f ${FS_IMG} truncate -s ${FS_SIZE}MB ${FS_IMG} mkfs.vfat -F ${FS_FATType} -f ${FS_FATs} -n ${FS_VOL_NAME} -r ${FS_ROOT_ENTRIES} -R ${FS_RSVD_SEC} -s ${FS_SEC_PER_CLUS} -S ${FS_SEC_SIZE} ${FS_IMG} # populate fs populatefs: mkfs # ++++++++++ Populating file system with directories and files ++++++++++ mkdir -p ${MOUNT_POINT} sudo mount -o loop,codepage=850,iocharset=iso8859-1,utf8,uid=${MOUNT_UID},gid=${MOUNT_GID} ${FS_IMG} ${MOUNT_POINT} cat ${DIRECTORIES} | while read dir; do mkdir -p "${MOUNT_POINT}/$$dir"; done cat ${FILES} | while read file; do touch "${MOUNT_POINT}/$$file"; done # delete some files until sudo umount ${MOUNT_POINT}; do sleep 1; done rmdir ${MOUNT_POINT} # alter file system as necessary for the test alterfs: populatefs # ++++++++++ Altering file system ++++++++++ # empty here rm -fr ${TMPFILE} execute: alterfs # ++++++++++ Executing tests ++++++++++ ${FATSORT} -D dir4 -x dir4/dir5 ${FS_IMG} ${FATSORT} -l ${FS_IMG} > ${STDOUT} 2> ${STDERR} diff ${STDOUT} ${STDOUT_EXP} diff ${STDERR} ${STDERR_EXP} # check result fsck: execute # ++++++++++ Checking file system ++++++++++ fsck.vfat -n ${FS_IMG} .PHONY: fsck execute populatefs mkfs clean fatsort-1.3.365/tests/tc_pos_sort_dir5_fat32/stderr_expected.txt0000664000175000017500000000000012321036667024226 0ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_sort_dir5_fat32/stdout_expected.txt0000664000175000017500000000032612321036667024260 0ustar feanorfeanorFile system: FAT32. / dir1 dir2 dir3 dir4 z g u n w e o a c v /dir1/ z g u n w e o a c v /dir2/ z g u n w e o a c v /dir3/ z g u n w e o a c v /dir4/ dir5 a c e g n o u v w z /dir4/dir5/ z g u n w e o a c v fatsort-1.3.365/tests/tc_pos_sort_dir5_fat32/directories.txt0000664000175000017500000000003112321036667023362 0ustar feanorfeanordir1 dir2 dir3 dir4/dir5 fatsort-1.3.365/tests/tc_pos_print_fs_info_fat32/0000775000175000017500000000000012321036667021240 5ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_print_fs_info_fat32/files.txt0000664000175000017500000000205512321036667023105 0ustar feanorfeanora b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z Ä Ö Ü file3.bin file2.bin file1.bin Long file name with lots of words and characters just to test long file name entries in FAT file systems1 Long file name with lots of words and characters just to test long file name entries in FAT file systems2 Long file name with lots of words and characters just to test long file name entries in FAT file systems3 Long file name with lots of words and characters just to test long file name entries in FAT file systems4 1 2 3 4 5 6 7 8 9 10 01b 1a 001c Directory1/Long file name with lots of words and characters just to test long file name entries in FAT file systems1 Directory1/Long file name with lots of words and characters just to test long file name entries in FAT file systems2 Directory1/Long file name with lots of words and characters just to test long file name entries in FAT file systems3 Directory1/Long file name with lots of words and characters just to test long file name entries in FAT file systems4 fatsort-1.3.365/tests/tc_pos_print_fs_info_fat32/Makefile0000775000175000017500000000362012321036667022704 0ustar feanorfeanorinclude ../testconfig.mk FS_FATType=32 # MiBytes FS_SIZE=100 FS_FATs=2 FS_VOL_NAME=test FS_ROOT_ENTRIES=512 FS_RSVD_SEC=32 FS_SEC_PER_CLUS=2 FS_SEC_SIZE=512 FS_BAD_BLOCKS_FILE=badblocks.txt DIRECTORIES=directories.txt FILES=files.txt TESTLOG=test.log STDOUT=stdout.log STDOUT_EXP=stdout_expected.txt STDERR=stderr.log STDERR_EXP=stderr_expected.txt # don't check fs because fsck will fail # due to wrong information about free clusters all: execute if [ ${DEL_FS_ON_PASS} -eq 1 ]; then rm -f ${FS_IMG}; fi clean: rm -fr *.log *.tmp ${FS_IMG} ${TMPFILE} ${TMPDIR} if [ -d ${MOUNT_POINT} ]; then \ until sudo umount ${MOUNT_POINT}; do sleep 1; done; \ rmdir ${MOUNT_POINT}; \ fi # create file system mkfs: # ++++++++++ Creating file ${FATType} system ++++++++++ rm -f ${FS_IMG} truncate -s ${FS_SIZE}MB ${FS_IMG} mkfs.vfat -F ${FS_FATType} -f ${FS_FATs} -n ${FS_VOL_NAME} -r ${FS_ROOT_ENTRIES} -R ${FS_RSVD_SEC} -s ${FS_SEC_PER_CLUS} -S ${FS_SEC_SIZE} -l ${FS_BAD_BLOCKS_FILE} ${FS_IMG} # populate fs populatefs: mkfs # ++++++++++ Populating file system with directories and files ++++++++++ mkdir -p ${MOUNT_POINT} sudo mount -o loop,codepage=850,iocharset=iso8859-1,utf8,uid=${MOUNT_UID},gid=${MOUNT_GID} ${FS_IMG} ${MOUNT_POINT} cat ${DIRECTORIES} | while read dir; do mkdir -p "${MOUNT_POINT}/$$dir"; done cat ${FILES} | while read file; do touch "${MOUNT_POINT}/$$file"; done until sudo umount ${MOUNT_POINT}; do sleep 1; done rmdir ${MOUNT_POINT} # alter file system as necessary for the test alterfs: populatefs # ++++++++++ Altering file system ++++++++++ # empty here rm -fr ${TMPFILE} execute: alterfs # ++++++++++ Executing tests ++++++++++ ${FATSORT} -i ${FS_IMG} > ${STDOUT} 2> ${STDERR} diff ${STDOUT} ${STDOUT_EXP} diff ${STDERR} ${STDERR_EXP} # check result fsck: execute # ++++++++++ Checking file system ++++++++++ fsck.vfat -n ${FS_IMG} .PHONY: fsck execute populatefs mkfs clean fatsort-1.3.365/tests/tc_pos_print_fs_info_fat32/badblocks.txt0000664000175000017500000000002612321036667023723 0ustar feanorfeanor1234 1337 2324 4242 fatsort-1.3.365/tests/tc_pos_print_fs_info_fat32/stderr_expected.txt0000664000175000017500000000000012321036667025153 0ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_print_fs_info_fat32/stdout_expected.txt0000664000175000017500000000066712321036667025215 0ustar feanorfeanor - File system information - Device: /tmp/fatsort-tc_pos_print_fs_info_fat32-fs.img Type: FAT32 Sector size: 512 bytes FAT size: 757 sectors (387584 bytes) Number of FATs: 2 Cluster size: 1024 bytes Max. cluster chain length: 4194303 clusters Data clusters (total / used / bad): 96883 / 13 / 4 FS size: 94.61 MiBytes FAT32 root first cluster: 0x2 First cluster data offset: 0xc1400 First cluster FAT entry: 0x7 fatsort-1.3.365/tests/tc_pos_print_fs_info_fat32/directories.txt0000664000175000017500000000004212321036667024311 0ustar feanorfeanorDirectory1 directory2 dir3/subDir fatsort-1.3.365/tests/tc_neg_missing_sne_at_end_of_root_dir_fat16/0000775000175000017500000000000012321036667024570 5ustar feanorfeanorfatsort-1.3.365/tests/tc_neg_missing_sne_at_end_of_root_dir_fat16/files.txt0000664000175000017500000000036612321036667026440 0ustar feanorfeanorAPFEL0 Apfel1 Apfel2 Apfel3 Apfel4 Apfel5 Apfel6 Apfel7 Apfel8 Apfel9 Apfel10 Apfel11 Apfel12 Apfel13 Apfel14 Apfel15 Apfel16 Apfel17 Apfel18 Apfel19 Apfel20 Apfel21 Apfel22 Apfel23 Apfel24 Apfel25 Apfel26 Apfel27 Apfel28 Apfel29 Apfel30 Apfel31 fatsort-1.3.365/tests/tc_neg_missing_sne_at_end_of_root_dir_fat16/Makefile0000775000175000017500000000424012321036667026233 0ustar feanorfeanorinclude ../testconfig.mk FS_FATType=16 # MiBytes FS_SIZE=10 FS_FATs=2 FS_VOL_NAME=test FS_ROOT_ENTRIES=64 FS_RSVD_SEC=32 FS_SEC_PER_CLUS=1 FS_SEC_SIZE=512 DIRECTORIES=directories.txt FILES=files.txt TESTLOG=test.log STDOUT=stdout.log STDOUT_EXP=stdout_expected.txt STDERR=stderr.log STDERR_EXP=stderr_expected.txt # no fsck in negative tests all: execute if [ ${DEL_FS_ON_PASS} -eq 1 ]; then rm -f ${FS_IMG}; fi clean: rm -fr *.log *.tmp ${FS_IMG} ${TMPFILE} ${TMPDIR} if [ -d ${MOUNT_POINT} ]; then \ until sudo umount ${MOUNT_POINT}; do sleep 1; done; \ rmdir ${MOUNT_POINT}; \ fi # create file system mkfs: # ++++++++++ Creating file ${FATType} system ++++++++++ rm -f ${FS_IMG} truncate -s ${FS_SIZE}MB ${FS_IMG} mkfs.vfat -F ${FS_FATType} -f ${FS_FATs} -n ${FS_VOL_NAME} -r ${FS_ROOT_ENTRIES} -R ${FS_RSVD_SEC} -s ${FS_SEC_PER_CLUS} -S ${FS_SEC_SIZE} ${FS_IMG} # populate fs populatefs: mkfs # ++++++++++ Populating file system with directories and files ++++++++++ mkdir -p ${MOUNT_POINT} sudo mount -o loop,codepage=850,iocharset=iso8859-1,utf8,uid=${MOUNT_UID},gid=${MOUNT_GID} ${FS_IMG} ${MOUNT_POINT} cat ${DIRECTORIES} | while read dir; do mkdir -p "${MOUNT_POINT}/$$dir"; done cat ${FILES} | while read file; do touch "${MOUNT_POINT}/$$file"; done rm -f "${MOUNT_POINT}/a" #remove some files rm -f "${MOUNT_POINT}/n" rm -f "${MOUNT_POINT}/z" until sudo umount ${MOUNT_POINT}; do sleep 1; done rmdir ${MOUNT_POINT} # alter file system as necessary for the test alterfs: populatefs # ++++++++++ Altering file system ++++++++++ # delete empty space and insert single sne before last lne ${BBE} -b x17820:32 -e "d 0 32" ${FS_IMG} > ${TMPFILE} ${BBE} -b x177a0:32 -e "A \x41\x50\x46\x45\x4C\x39\x39\x20\x20\x20\x20\x20\x00\x00\x31\xA0\xB0\x42\xB0\x42\x00\x00\x31\xA0\xB0\x42\x00\x00\x00\x00\x00\x00" ${TMPFILE} > ${FS_IMG} rm -fr ${TMPFILE} execute: alterfs # ++++++++++ Executing tests ++++++++++ ${FATSORT} ${FS_IMG} > ${STDOUT} 2> ${STDERR}; [ $$? -ne 0 ] diff ${STDOUT} ${STDOUT_EXP} diff ${STDERR} ${STDERR_EXP} # check result fsck: execute # ++++++++++ Checking file system ++++++++++ fsck.vfat -n ${FS_IMG} .PHONY: fsck execute populatefs mkfs clean fatsort-1.3.365/tests/tc_neg_missing_sne_at_end_of_root_dir_fat16/stderr_expected.txt0000664000175000017500000000036412321036667030520 0ustar feanorfeanorparseFAT1xRootDirEntries: ShortDirEntry is missing after LongDirEntries (root dir entry 64)! sortFAT1xRootDirectory: Failed to parse root directory entries! sortFileSystem: Failed to sort FAT16 root directory! main: Failed to sort file system! fatsort-1.3.365/tests/tc_neg_missing_sne_at_end_of_root_dir_fat16/stdout_expected.txt0000664000175000017500000000005112321036667030530 0ustar feanorfeanorFile system: FAT16. Sorting directory / fatsort-1.3.365/tests/tc_neg_missing_sne_at_end_of_root_dir_fat16/directories.txt0000664000175000017500000000000012321036667027633 0ustar feanorfeanorfatsort-1.3.365/tests/tc_neg_bad_count_of_root_dir_entries_fat16/0000775000175000017500000000000012321036667024427 5ustar feanorfeanorfatsort-1.3.365/tests/tc_neg_bad_count_of_root_dir_entries_fat16/files.txt0000664000175000017500000000001112321036667026262 0ustar feanorfeanordir/test fatsort-1.3.365/tests/tc_neg_bad_count_of_root_dir_entries_fat16/Makefile0000775000175000017500000000364112321036667026076 0ustar feanorfeanorinclude ../testconfig.mk FS_FATType=16 # 100 MiBytes FS_SIZE=10 FS_FATs=2 FS_VOL_NAME=test FS_ROOT_ENTRIES=512 FS_RSVD_SEC=1 FS_SEC_PER_CLUS=1 FS_SEC_SIZE=512 DIRECTORIES=directories.txt FILES=files.txt TESTLOG=test.log STDOUT=stdout.log STDOUT_EXP=stdout_expected.txt STDERR=stderr.log STDERR_EXP=stderr_expected.txt # no fsck in negative tests all: execute if [ ${DEL_FS_ON_PASS} -eq 1 ]; then rm -f ${FS_IMG}; fi clean: rm -fr *.log *.tmp ${FS_IMG} ${TMPFILE} ${TMPDIR} if [ -d ${MOUNT_POINT} ]; then \ until sudo umount ${MOUNT_POINT}; do sleep 1; done; \ rmdir ${MOUNT_POINT}; \ fi # create file system mkfs: # ++++++++++ Creating file ${FATType} system ++++++++++ rm -f ${FS_IMG} truncate -s ${FS_SIZE}MB ${FS_IMG} mkfs.vfat -F ${FS_FATType} -f ${FS_FATs} -n ${FS_VOL_NAME} -r ${FS_ROOT_ENTRIES} -R ${FS_RSVD_SEC} -s ${FS_SEC_PER_CLUS} -S ${FS_SEC_SIZE} ${FS_IMG} # populate fs populatefs: mkfs # ++++++++++ Populating file system with directories and files ++++++++++ mkdir -p ${MOUNT_POINT} sudo mount -o loop,codepage=850,iocharset=iso8859-1,utf8,uid=${MOUNT_UID},gid=${MOUNT_GID} ${FS_IMG} ${MOUNT_POINT} cat ${DIRECTORIES} | while read dir; do mkdir -p "${MOUNT_POINT}/$$dir"; done cat ${FILES} | while read file; do touch "${MOUNT_POINT}/$$file"; done until sudo umount ${MOUNT_POINT}; do sleep 1; done rmdir ${MOUNT_POINT} # alter file system as necessary for the test alterfs: populatefs # ++++++++++ Altering file system ++++++++++ # set root dir entries to 0 (bad for FAT16/FAT12) ${BBE} -b x11:2 -e "r 0 \x00\x00" ${FS_IMG} > ${TMPFILE} cp ${TMPFILE} ${FS_IMG} rm -fr ${TMPFILE} execute: alterfs # ++++++++++ Executing tests ++++++++++ ${FATSORT} ${FS_IMG} > ${STDOUT} 2> ${STDERR}; [ $$? -ne 0 ] diff ${STDOUT} ${STDOUT_EXP} diff ${STDERR} ${STDERR_EXP} # check result fsck: execute # ++++++++++ Checking file system ++++++++++ fsck.vfat -n ${FS_IMG} .PHONY: fsck execute populatefs mkfs clean fatsort-1.3.365/tests/tc_neg_bad_count_of_root_dir_entries_fat16/stderr_expected.txt0000664000175000017500000000023212321036667030351 0ustar feanorfeanoropenFileSystem: Count of root directory entries must not be zero for FAT1x! sortFileSystem: Failed to open file system! main: Failed to sort file system! fatsort-1.3.365/tests/tc_neg_bad_count_of_root_dir_entries_fat16/stdout_expected.txt0000664000175000017500000000000012321036667030361 0ustar feanorfeanorfatsort-1.3.365/tests/tc_neg_bad_count_of_root_dir_entries_fat16/directories.txt0000664000175000017500000000000412321036667027476 0ustar feanorfeanordir fatsort-1.3.365/tests/tc_pos_sort_order_directories_fat12/0000775000175000017500000000000012321036667023155 5ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_sort_order_directories_fat12/files.txt0000664000175000017500000000043112321036667025016 0ustar feanorfeanora b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z Ä Ö Ü file3.bin file2.bin file1.bin Long file name with lots of words and characters just to test long file name entries in FAT file systems 1 2 3 4 5 6 7 8 9 10 01b 1a 001c fatsort-1.3.365/tests/tc_pos_sort_order_directories_fat12/Makefile0000775000175000017500000000345312321036667024625 0ustar feanorfeanorinclude ../testconfig.mk FS_FATType=12 # MiBytes FS_SIZE=10 FS_FATs=1 FS_VOL_NAME=test FS_ROOT_ENTRIES=512 FS_RSVD_SEC=32 FS_SEC_PER_CLUS=16 FS_SEC_SIZE=512 DIRECTORIES=directories.txt FILES=files.txt TESTLOG=test.log STDOUT=stdout.log STDOUT_EXP=stdout_expected.txt STDERR=stderr.log STDERR_EXP=stderr_expected.txt all: fsck if [ ${DEL_FS_ON_PASS} -eq 1 ]; then rm -f ${FS_IMG}; fi clean: rm -fr *.log *.tmp ${FS_IMG} ${TMPFILE} ${TMPDIR} if [ -d ${MOUNT_POINT} ]; then \ until sudo umount ${MOUNT_POINT}; do sleep 1; done; \ rmdir ${MOUNT_POINT}; \ fi # create file system mkfs: # ++++++++++ Creating file ${FATType} system ++++++++++ rm -f ${FS_IMG} truncate -s ${FS_SIZE}MB ${FS_IMG} mkfs.vfat -F ${FS_FATType} -f ${FS_FATs} -n ${FS_VOL_NAME} -r ${FS_ROOT_ENTRIES} -R ${FS_RSVD_SEC} -s ${FS_SEC_PER_CLUS} -S ${FS_SEC_SIZE} ${FS_IMG} # populate fs populatefs: mkfs # ++++++++++ Populating file system with directories and files ++++++++++ mkdir -p ${MOUNT_POINT} sudo mount -o loop,codepage=850,iocharset=iso8859-1,utf8,uid=${MOUNT_UID},gid=${MOUNT_GID} ${FS_IMG} ${MOUNT_POINT} cat ${DIRECTORIES} | while read dir; do mkdir -p "${MOUNT_POINT}/$$dir"; done cat ${FILES} | while read file; do touch "${MOUNT_POINT}/$$file"; done # delete some files until sudo umount ${MOUNT_POINT}; do sleep 1; done rmdir ${MOUNT_POINT} # alter file system as necessary for the test alterfs: populatefs # ++++++++++ Altering file system ++++++++++ # empty here rm -fr ${TMPFILE} execute: alterfs # ++++++++++ Executing tests ++++++++++ ${FATSORT} -od ${FS_IMG} ${FATSORT} -l ${FS_IMG} > ${STDOUT} 2> ${STDERR} diff ${STDOUT} ${STDOUT_EXP} diff ${STDERR} ${STDERR_EXP} # check result fsck: execute # ++++++++++ Checking file system ++++++++++ fsck.vfat -n ${FS_IMG} .PHONY: fsck execute populatefs mkfs clean fatsort-1.3.365/tests/tc_pos_sort_order_directories_fat12/stderr_expected.txt0000664000175000017500000000000012321036667027070 0ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_sort_order_directories_fat12/stdout_expected.txt0000664000175000017500000000052212321036667027120 0ustar feanorfeanorFile system: FAT12. / dir3 Directory1 directory2 001c 01b 1 10 1a 2 3 4 5 6 7 8 9 a Ä b c d e f file1.bin file2.bin file3.bin g h i j k l Long file name with lots of words and characters just to test long file name entries in FAT file systems m n o Ö p q r s t u Ü v w x y z /dir3/ subDir /dir3/subDir/ /Directory1/ /directory2/ fatsort-1.3.365/tests/tc_pos_sort_order_directories_fat12/directories.txt0000664000175000017500000000004212321036667026226 0ustar feanorfeanorDirectory1 directory2 dir3/subDir fatsort-1.3.365/tests/tc_neg_bad_dir_entry_checksum/0000775000175000017500000000000012321036667022041 5ustar feanorfeanorfatsort-1.3.365/tests/tc_neg_bad_dir_entry_checksum/files.txt0000664000175000017500000000043112321036667023702 0ustar feanorfeanora b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z Ä Ö Ü file3.bin file2.bin file1.bin Long file name with lots of words and characters just to test long file name entries in FAT file systems 1 2 3 4 5 6 7 8 9 10 01b 1a 001c fatsort-1.3.365/tests/tc_neg_bad_dir_entry_checksum/Makefile0000775000175000017500000000376512321036667023517 0ustar feanorfeanorinclude ../testconfig.mk FS_FATType=32 # 100 MiBytes FS_SIZE=100 FS_FATs=2 FS_VOL_NAME=test FS_ROOT_ENTRIES=512 FS_RSVD_SEC=32 FS_SEC_PER_CLUS=1 FS_SEC_SIZE=512 DIRECTORIES=directories.txt FILES=files.txt TESTLOG=test.log STDOUT=stdout.log STDOUT_EXP=stdout_expected.txt STDERR=stderr.log STDERR_EXP=stderr_expected.txt # no fsck in negative tests all: execute if [ ${DEL_FS_ON_PASS} -eq 1 ]; then rm -f ${FS_IMG}; fi clean: rm -fr *.log *.tmp ${FS_IMG} ${TMPFILE} ${TMPDIR} if [ -d ${MOUNT_POINT} ]; then \ until sudo umount ${MOUNT_POINT}; do sleep 1; done; \ rmdir ${MOUNT_POINT}; \ fi # create file system mkfs: # ++++++++++ Creating file ${FATType} system ++++++++++ rm -f ${FS_IMG} truncate -s ${FS_SIZE}MB ${FS_IMG} mkfs.vfat -F ${FS_FATType} -f ${FS_FATs} -n ${FS_VOL_NAME} -r ${FS_ROOT_ENTRIES} -R ${FS_RSVD_SEC} -s ${FS_SEC_PER_CLUS} -S ${FS_SEC_SIZE} ${FS_IMG} # populate fs populatefs: mkfs # ++++++++++ Populating file system with directories and files ++++++++++ mkdir -p ${MOUNT_POINT} sudo mount -o loop,codepage=850,iocharset=iso8859-1,utf8,uid=${MOUNT_UID},gid=${MOUNT_GID} ${FS_IMG} ${MOUNT_POINT} cat ${DIRECTORIES} | while read dir; do mkdir -p "${MOUNT_POINT}/$$dir"; done cat ${FILES} | while read file; do touch "${MOUNT_POINT}/$$file"; done rm -f "${MOUNT_POINT}/a" #remove some files rm -f "${MOUNT_POINT}/n" rm -f "${MOUNT_POINT}/z" until sudo umount ${MOUNT_POINT}; do sleep 1; done rmdir ${MOUNT_POINT} # alter file system as necessary for the test alterfs: populatefs # ++++++++++ Altering file system ++++++++++ # alter sne to change checksum ${BBE} -b x17cde1:1 -e "r 0 \x41" ${FS_IMG} > ${TMPFILE} cp -f ${TMPFILE} ${FS_IMG} rm -fr ${TMPFILE} execute: alterfs # ++++++++++ Executing tests ++++++++++ ${FATSORT} ${FS_IMG} > ${STDOUT} 2> ${STDERR}; [ $$? -ne 0 ] diff ${STDOUT} ${STDOUT_EXP} diff ${STDERR} ${STDERR_EXP} # check result fsck: execute # ++++++++++ Checking file system ++++++++++ fsck.vfat -n ${FS_IMG} .PHONY: fsck execute populatefs mkfs clean fatsort-1.3.365/tests/tc_neg_bad_dir_entry_checksum/stderr_expected.txt0000664000175000017500000000043312321036667025766 0ustar feanorfeanorcheckLongDirEntries: Checksum for LongDirEntry is 0xf7 but should be 0xa4! parseClusterChain: checkDirEntry failed in cluster 0000000a at entry 15! sortClusterChain: Failed to parse cluster chain! sortFileSystem: Failed to sort first cluster chain! main: Failed to sort file system! fatsort-1.3.365/tests/tc_neg_bad_dir_entry_checksum/stdout_expected.txt0000664000175000017500000000005112321036667026001 0ustar feanorfeanorFile system: FAT32. Sorting directory / fatsort-1.3.365/tests/tc_neg_bad_dir_entry_checksum/directories.txt0000664000175000017500000000004212321036667025112 0ustar feanorfeanorDirectory1 directory2 dir3/subDir fatsort-1.3.365/tests/tc_neg_fats_dont_match/0000775000175000017500000000000012321036667020507 5ustar feanorfeanorfatsort-1.3.365/tests/tc_neg_fats_dont_match/files.txt0000664000175000017500000000001112321036667022342 0ustar feanorfeanordir/test fatsort-1.3.365/tests/tc_neg_fats_dont_match/Makefile0000775000175000017500000000376112321036667022161 0ustar feanorfeanorinclude ../testconfig.mk FS_FATType=32 # 100 MiBytes FS_SIZE=100 FS_FATs=2 FS_VOL_NAME=test FS_ROOT_ENTRIES=512 FS_RSVD_SEC=32 FS_SEC_PER_CLUS=1 FS_SEC_SIZE=512 DIRECTORIES=directories.txt FILES=files.txt TESTLOG=test.log STDOUT=stdout.log STDOUT_EXP=stdout_expected.txt STDERR=stderr.log STDERR_EXP=stderr_expected.txt # no fsck in negative tests all: execute if [ ${DEL_FS_ON_PASS} -eq 1 ]; then rm -f ${FS_IMG}; fi clean: rm -fr *.log *.tmp ${FS_IMG} ${TMPFILE} ${TMPDIR} if [ -d ${MOUNT_POINT} ]; then \ until sudo umount ${MOUNT_POINT}; do sleep 1; done; \ rmdir ${MOUNT_POINT}; \ fi # create file system mkfs: # ++++++++++ Creating file ${FATType} system ++++++++++ rm -f ${FS_IMG} truncate -s ${FS_SIZE}MB ${FS_IMG} mkfs.vfat -F ${FS_FATType} -f ${FS_FATs} -n ${FS_VOL_NAME} -r ${FS_ROOT_ENTRIES} -R ${FS_RSVD_SEC} -s ${FS_SEC_PER_CLUS} -S ${FS_SEC_SIZE} ${FS_IMG} # populate fs populatefs: mkfs # ++++++++++ Populating file system with directories and files ++++++++++ mkdir -p ${MOUNT_POINT} sudo mount -o loop,codepage=850,iocharset=iso8859-1,utf8,uid=${MOUNT_UID},gid=${MOUNT_GID} ${FS_IMG} ${MOUNT_POINT} cat ${DIRECTORIES} | while read dir; do mkdir -p "${MOUNT_POINT}/$$dir"; done cat ${FILES} | while read file; do touch "${MOUNT_POINT}/$$file"; done rm -f "${MOUNT_POINT}/a" #remove some files rm -f "${MOUNT_POINT}/n" rm -f "${MOUNT_POINT}/z" until sudo umount ${MOUNT_POINT}; do sleep 1; done rmdir ${MOUNT_POINT} # alter file system as necessary for the test alterfs: populatefs # ++++++++++ Altering file system ++++++++++ # alter one FAT ${BBE} -b x0bfe08:4 -e "r 0 \x02\x00\x00\x00" ${FS_IMG} > ${TMPFILE} cp -f ${TMPFILE} ${FS_IMG} rm -fr ${TMPFILE} execute: alterfs # ++++++++++ Executing tests ++++++++++ ${FATSORT} ${FS_IMG} > ${STDOUT} 2> ${STDERR}; [ $$? -ne 0 ] diff ${STDOUT} ${STDOUT_EXP} diff ${STDERR} ${STDERR_EXP} # check result fsck: execute # ++++++++++ Checking file system ++++++++++ fsck.vfat -n ${FS_IMG} .PHONY: fsck execute populatefs mkfs clean fatsort-1.3.365/tests/tc_neg_fats_dont_match/stderr_expected.txt0000664000175000017500000000013712321036667024435 0ustar feanorfeanorsortFileSystem: FATs don't match! Please repair file system! main: Failed to sort file system! fatsort-1.3.365/tests/tc_neg_fats_dont_match/stdout_expected.txt0000664000175000017500000000000012321036667024441 0ustar feanorfeanorfatsort-1.3.365/tests/tc_neg_fats_dont_match/directories.txt0000664000175000017500000000000412321036667023556 0ustar feanorfeanordir fatsort-1.3.365/tests/tc_pos_sort_order_directories_fat16/0000775000175000017500000000000012321036667023161 5ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_sort_order_directories_fat16/files.txt0000664000175000017500000000043112321036667025022 0ustar feanorfeanora b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z Ä Ö Ü file3.bin file2.bin file1.bin Long file name with lots of words and characters just to test long file name entries in FAT file systems 1 2 3 4 5 6 7 8 9 10 01b 1a 001c fatsort-1.3.365/tests/tc_pos_sort_order_directories_fat16/Makefile0000775000175000017500000000345212321036667024630 0ustar feanorfeanorinclude ../testconfig.mk FS_FATType=16 # MiBytes FS_SIZE=10 FS_FATs=1 FS_VOL_NAME=test FS_ROOT_ENTRIES=512 FS_RSVD_SEC=32 FS_SEC_PER_CLUS=1 FS_SEC_SIZE=512 DIRECTORIES=directories.txt FILES=files.txt TESTLOG=test.log STDOUT=stdout.log STDOUT_EXP=stdout_expected.txt STDERR=stderr.log STDERR_EXP=stderr_expected.txt all: fsck if [ ${DEL_FS_ON_PASS} -eq 1 ]; then rm -f ${FS_IMG}; fi clean: rm -fr *.log *.tmp ${FS_IMG} ${TMPFILE} ${TMPDIR} if [ -d ${MOUNT_POINT} ]; then \ until sudo umount ${MOUNT_POINT}; do sleep 1; done; \ rmdir ${MOUNT_POINT}; \ fi # create file system mkfs: # ++++++++++ Creating file ${FATType} system ++++++++++ rm -f ${FS_IMG} truncate -s ${FS_SIZE}MB ${FS_IMG} mkfs.vfat -F ${FS_FATType} -f ${FS_FATs} -n ${FS_VOL_NAME} -r ${FS_ROOT_ENTRIES} -R ${FS_RSVD_SEC} -s ${FS_SEC_PER_CLUS} -S ${FS_SEC_SIZE} ${FS_IMG} # populate fs populatefs: mkfs # ++++++++++ Populating file system with directories and files ++++++++++ mkdir -p ${MOUNT_POINT} sudo mount -o loop,codepage=850,iocharset=iso8859-1,utf8,uid=${MOUNT_UID},gid=${MOUNT_GID} ${FS_IMG} ${MOUNT_POINT} cat ${DIRECTORIES} | while read dir; do mkdir -p "${MOUNT_POINT}/$$dir"; done cat ${FILES} | while read file; do touch "${MOUNT_POINT}/$$file"; done # delete some files until sudo umount ${MOUNT_POINT}; do sleep 1; done rmdir ${MOUNT_POINT} # alter file system as necessary for the test alterfs: populatefs # ++++++++++ Altering file system ++++++++++ # empty here rm -fr ${TMPFILE} execute: alterfs # ++++++++++ Executing tests ++++++++++ ${FATSORT} -od ${FS_IMG} ${FATSORT} -l ${FS_IMG} > ${STDOUT} 2> ${STDERR} diff ${STDOUT} ${STDOUT_EXP} diff ${STDERR} ${STDERR_EXP} # check result fsck: execute # ++++++++++ Checking file system ++++++++++ fsck.vfat -n ${FS_IMG} .PHONY: fsck execute populatefs mkfs clean fatsort-1.3.365/tests/tc_pos_sort_order_directories_fat16/stderr_expected.txt0000664000175000017500000000000012321036667027074 0ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_sort_order_directories_fat16/stdout_expected.txt0000664000175000017500000000052212321036667027124 0ustar feanorfeanorFile system: FAT16. / dir3 Directory1 directory2 001c 01b 1 10 1a 2 3 4 5 6 7 8 9 a Ä b c d e f file1.bin file2.bin file3.bin g h i j k l Long file name with lots of words and characters just to test long file name entries in FAT file systems m n o Ö p q r s t u Ü v w x y z /dir3/ subDir /dir3/subDir/ /Directory1/ /directory2/ fatsort-1.3.365/tests/tc_pos_sort_order_directories_fat16/directories.txt0000664000175000017500000000004212321036667026232 0ustar feanorfeanorDirectory1 directory2 dir3/subDir fatsort-1.3.365/tests/tc_pos_sort_default_fat32/0000775000175000017500000000000012321036667021074 5ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_sort_default_fat32/files.txt0000664000175000017500000000205512321036667022741 0ustar feanorfeanora b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z Ä Ö Ü file3.bin file2.bin file1.bin Long file name with lots of words and characters just to test long file name entries in FAT file systems1 Long file name with lots of words and characters just to test long file name entries in FAT file systems2 Long file name with lots of words and characters just to test long file name entries in FAT file systems3 Long file name with lots of words and characters just to test long file name entries in FAT file systems4 1 2 3 4 5 6 7 8 9 10 01b 1a 001c Directory1/Long file name with lots of words and characters just to test long file name entries in FAT file systems1 Directory1/Long file name with lots of words and characters just to test long file name entries in FAT file systems2 Directory1/Long file name with lots of words and characters just to test long file name entries in FAT file systems3 Directory1/Long file name with lots of words and characters just to test long file name entries in FAT file systems4 fatsort-1.3.365/tests/tc_pos_sort_default_fat32/Makefile0000775000175000017500000000355412321036667022546 0ustar feanorfeanorinclude ../testconfig.mk FS_FATType=32 # MiBytes FS_SIZE=100 FS_FATs=2 FS_VOL_NAME=test FS_ROOT_ENTRIES=512 FS_RSVD_SEC=32 FS_SEC_PER_CLUS=1 FS_SEC_SIZE=512 DIRECTORIES=directories.txt FILES=files.txt TESTLOG=test.log STDOUT=stdout.log STDOUT_EXP=stdout_expected.txt STDERR=stderr.log STDERR_EXP=stderr_expected.txt all: fsck if [ ${DEL_FS_ON_PASS} -eq 1 ]; then rm -f ${FS_IMG}; fi clean: rm -fr *.log *.tmp ${FS_IMG} ${TMPFILE} ${TMPDIR} if [ -d ${MOUNT_POINT} ]; then \ until sudo umount ${MOUNT_POINT}; do sleep 1; done; \ rmdir ${MOUNT_POINT}; \ fi # create file system mkfs: # ++++++++++ Creating file ${FATType} system ++++++++++ rm -f ${FS_IMG} truncate -s ${FS_SIZE}MB ${FS_IMG} mkfs.vfat -F ${FS_FATType} -f ${FS_FATs} -n ${FS_VOL_NAME} -r ${FS_ROOT_ENTRIES} -R ${FS_RSVD_SEC} -s ${FS_SEC_PER_CLUS} -S ${FS_SEC_SIZE} ${FS_IMG} # populate fs populatefs: mkfs # ++++++++++ Populating file system with directories and files ++++++++++ mkdir -p ${MOUNT_POINT} sudo mount -o loop,codepage=850,iocharset=iso8859-1,utf8,uid=${MOUNT_UID},gid=${MOUNT_GID} ${FS_IMG} ${MOUNT_POINT} cat ${DIRECTORIES} | while read dir; do mkdir -p "${MOUNT_POINT}/$$dir"; done cat ${FILES} | while read file; do touch "${MOUNT_POINT}/$$file"; done # delete some files rm "${MOUNT_POINT}/a" rm "${MOUNT_POINT}/n" rm "${MOUNT_POINT}/z" until sudo umount ${MOUNT_POINT}; do sleep 1; done rmdir ${MOUNT_POINT} # alter file system as necessary for the test alterfs: populatefs # ++++++++++ Altering file system ++++++++++ # empty here rm -fr ${TMPFILE} execute: alterfs # ++++++++++ Executing tests ++++++++++ ${FATSORT} ${FS_IMG} ${FATSORT} -l ${FS_IMG} > ${STDOUT} 2> ${STDERR} diff ${STDOUT} ${STDOUT_EXP} diff ${STDERR} ${STDERR_EXP} # check result fsck: execute # ++++++++++ Checking file system ++++++++++ fsck.vfat -n ${FS_IMG} .PHONY: fsck execute populatefs mkfs clean fatsort-1.3.365/tests/tc_pos_sort_default_fat32/stderr_expected.txt0000664000175000017500000000000012321036667025007 0ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_sort_default_fat32/stdout_expected.txt0000664000175000017500000000206312321036667025041 0ustar feanorfeanorFile system: FAT32. / dir3 Directory1 directory2 001c 01b 1 10 1a 2 3 4 5 6 7 8 9 Ä b c d e f file1.bin file2.bin file3.bin g h i j k l Long file name with lots of words and characters just to test long file name entries in FAT file systems1 Long file name with lots of words and characters just to test long file name entries in FAT file systems2 Long file name with lots of words and characters just to test long file name entries in FAT file systems3 Long file name with lots of words and characters just to test long file name entries in FAT file systems4 m o Ö p q r s t u Ü v w x y /dir3/ subDir /dir3/subDir/ /Directory1/ Long file name with lots of words and characters just to test long file name entries in FAT file systems1 Long file name with lots of words and characters just to test long file name entries in FAT file systems2 Long file name with lots of words and characters just to test long file name entries in FAT file systems3 Long file name with lots of words and characters just to test long file name entries in FAT file systems4 /directory2/ fatsort-1.3.365/tests/tc_pos_sort_default_fat32/directories.txt0000664000175000017500000000004212321036667024145 0ustar feanorfeanorDirectory1 directory2 dir3/subDir fatsort-1.3.365/tests/tc_pos_print_fs_info_fat16/0000775000175000017500000000000012321036667021242 5ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_print_fs_info_fat16/files.txt0000664000175000017500000000205512321036667023107 0ustar feanorfeanora b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z Ä Ö Ü file3.bin file2.bin file1.bin Long file name with lots of words and characters just to test long file name entries in FAT file systems1 Long file name with lots of words and characters just to test long file name entries in FAT file systems2 Long file name with lots of words and characters just to test long file name entries in FAT file systems3 Long file name with lots of words and characters just to test long file name entries in FAT file systems4 1 2 3 4 5 6 7 8 9 10 01b 1a 001c Directory1/Long file name with lots of words and characters just to test long file name entries in FAT file systems1 Directory1/Long file name with lots of words and characters just to test long file name entries in FAT file systems2 Directory1/Long file name with lots of words and characters just to test long file name entries in FAT file systems3 Directory1/Long file name with lots of words and characters just to test long file name entries in FAT file systems4 fatsort-1.3.365/tests/tc_pos_print_fs_info_fat16/Makefile0000775000175000017500000000346512321036667022715 0ustar feanorfeanorinclude ../testconfig.mk FS_FATType=16 # MiBytes FS_SIZE=10 FS_FATs=2 FS_VOL_NAME=test FS_ROOT_ENTRIES=512 FS_RSVD_SEC=32 FS_SEC_PER_CLUS=2 FS_SEC_SIZE=512 FS_BAD_BLOCKS_FILE=badblocks.txt DIRECTORIES=directories.txt FILES=files.txt TESTLOG=test.log STDOUT=stdout.log STDOUT_EXP=stdout_expected.txt STDERR=stderr.log STDERR_EXP=stderr_expected.txt all: fsck if [ ${DEL_FS_ON_PASS} -eq 1 ]; then rm -f ${FS_IMG}; fi clean: rm -fr *.log *.tmp ${FS_IMG} ${TMPFILE} ${TMPDIR} if [ -d ${MOUNT_POINT} ]; then \ until sudo umount ${MOUNT_POINT}; do sleep 1; done; \ rmdir ${MOUNT_POINT}; \ fi # create file system mkfs: # ++++++++++ Creating file ${FATType} system ++++++++++ rm -f ${FS_IMG} truncate -s ${FS_SIZE}MB ${FS_IMG} mkfs.vfat -F ${FS_FATType} -f ${FS_FATs} -n ${FS_VOL_NAME} -r ${FS_ROOT_ENTRIES} -R ${FS_RSVD_SEC} -s ${FS_SEC_PER_CLUS} -S ${FS_SEC_SIZE} -l ${FS_BAD_BLOCKS_FILE} ${FS_IMG} # populate fs populatefs: mkfs # ++++++++++ Populating file system with directories and files ++++++++++ mkdir -p ${MOUNT_POINT} sudo mount -o loop,codepage=850,iocharset=iso8859-1,utf8,uid=${MOUNT_UID},gid=${MOUNT_GID} ${FS_IMG} ${MOUNT_POINT} cat ${DIRECTORIES} | while read dir; do mkdir -p "${MOUNT_POINT}/$$dir"; done cat ${FILES} | while read file; do touch "${MOUNT_POINT}/$$file"; done until sudo umount ${MOUNT_POINT}; do sleep 1; done rmdir ${MOUNT_POINT} # alter file system as necessary for the test alterfs: populatefs # ++++++++++ Altering file system ++++++++++ # empty here rm -fr ${TMPFILE} execute: alterfs # ++++++++++ Executing tests ++++++++++ ${FATSORT} -i ${FS_IMG} > ${STDOUT} 2> ${STDERR} diff ${STDOUT} ${STDOUT_EXP} diff ${STDERR} ${STDERR_EXP} # check result fsck: execute # ++++++++++ Checking file system ++++++++++ fsck.vfat -n ${FS_IMG} .PHONY: fsck execute populatefs mkfs clean fatsort-1.3.365/tests/tc_pos_print_fs_info_fat16/badblocks.txt0000664000175000017500000000002612321036667023725 0ustar feanorfeanor1234 1337 2324 4242 fatsort-1.3.365/tests/tc_pos_print_fs_info_fat16/stderr_expected.txt0000664000175000017500000000000012321036667025155 0ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_print_fs_info_fat16/stdout_expected.txt0000664000175000017500000000056412321036667025213 0ustar feanorfeanor - File system information - Device: /tmp/fatsort-tc_pos_print_fs_info_fat16-fs.img Type: FAT16 Sector size: 512 bytes FAT size: 38 sectors (19456 bytes) Number of FATs: 2 Cluster size: 1024 bytes Max. cluster chain length: 4194303 clusters Data clusters (total / used / bad): 9695 / 9 / 4 FS size: 9.47 MiBytes FAT16 root directory Entries: 512 fatsort-1.3.365/tests/tc_pos_print_fs_info_fat16/directories.txt0000664000175000017500000000004212321036667024313 0ustar feanorfeanorDirectory1 directory2 dir3/subDir fatsort-1.3.365/tests/tc_pos_sort_default_fat12/0000775000175000017500000000000012321036667021072 5ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_sort_default_fat12/files.txt0000664000175000017500000000205512321036667022737 0ustar feanorfeanora b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z Ä Ö Ü file3.bin file2.bin file1.bin Long file name with lots of words and characters just to test long file name entries in FAT file systems1 Long file name with lots of words and characters just to test long file name entries in FAT file systems2 Long file name with lots of words and characters just to test long file name entries in FAT file systems3 Long file name with lots of words and characters just to test long file name entries in FAT file systems4 1 2 3 4 5 6 7 8 9 10 01b 1a 001c Directory1/Long file name with lots of words and characters just to test long file name entries in FAT file systems1 Directory1/Long file name with lots of words and characters just to test long file name entries in FAT file systems2 Directory1/Long file name with lots of words and characters just to test long file name entries in FAT file systems3 Directory1/Long file name with lots of words and characters just to test long file name entries in FAT file systems4 fatsort-1.3.365/tests/tc_pos_sort_default_fat12/Makefile0000775000175000017500000000355412321036667022544 0ustar feanorfeanorinclude ../testconfig.mk FS_FATType=12 # MiBytes FS_SIZE=10 FS_FATs=2 FS_VOL_NAME=test FS_ROOT_ENTRIES=512 FS_RSVD_SEC=32 FS_SEC_PER_CLUS=16 FS_SEC_SIZE=512 DIRECTORIES=directories.txt FILES=files.txt TESTLOG=test.log STDOUT=stdout.log STDOUT_EXP=stdout_expected.txt STDERR=stderr.log STDERR_EXP=stderr_expected.txt all: fsck if [ ${DEL_FS_ON_PASS} -eq 1 ]; then rm -f ${FS_IMG}; fi clean: rm -fr *.log *.tmp ${FS_IMG} ${TMPFILE} ${TMPDIR} if [ -d ${MOUNT_POINT} ]; then \ until sudo umount ${MOUNT_POINT}; do sleep 1; done; \ rmdir ${MOUNT_POINT}; \ fi # create file system mkfs: # ++++++++++ Creating file ${FATType} system ++++++++++ rm -f ${FS_IMG} truncate -s ${FS_SIZE}MB ${FS_IMG} mkfs.vfat -F ${FS_FATType} -f ${FS_FATs} -n ${FS_VOL_NAME} -r ${FS_ROOT_ENTRIES} -R ${FS_RSVD_SEC} -s ${FS_SEC_PER_CLUS} -S ${FS_SEC_SIZE} ${FS_IMG} # populate fs populatefs: mkfs # ++++++++++ Populating file system with directories and files ++++++++++ mkdir -p ${MOUNT_POINT} sudo mount -o loop,codepage=850,iocharset=iso8859-1,utf8,uid=${MOUNT_UID},gid=${MOUNT_GID} ${FS_IMG} ${MOUNT_POINT} cat ${DIRECTORIES} | while read dir; do mkdir -p "${MOUNT_POINT}/$$dir"; done cat ${FILES} | while read file; do touch "${MOUNT_POINT}/$$file"; done # delete some files rm "${MOUNT_POINT}/a" rm "${MOUNT_POINT}/n" rm "${MOUNT_POINT}/z" until sudo umount ${MOUNT_POINT}; do sleep 1; done rmdir ${MOUNT_POINT} # alter file system as necessary for the test alterfs: populatefs # ++++++++++ Altering file system ++++++++++ # empty here rm -fr ${TMPFILE} execute: alterfs # ++++++++++ Executing tests ++++++++++ ${FATSORT} ${FS_IMG} ${FATSORT} -l ${FS_IMG} > ${STDOUT} 2> ${STDERR} diff ${STDOUT} ${STDOUT_EXP} diff ${STDERR} ${STDERR_EXP} # check result fsck: execute # ++++++++++ Checking file system ++++++++++ fsck.vfat -n ${FS_IMG} .PHONY: fsck execute populatefs mkfs clean fatsort-1.3.365/tests/tc_pos_sort_default_fat12/stderr_expected.txt0000664000175000017500000000000012321036667025005 0ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_sort_default_fat12/stdout_expected.txt0000664000175000017500000000206312321036667025037 0ustar feanorfeanorFile system: FAT12. / dir3 Directory1 directory2 001c 01b 1 10 1a 2 3 4 5 6 7 8 9 Ä b c d e f file1.bin file2.bin file3.bin g h i j k l Long file name with lots of words and characters just to test long file name entries in FAT file systems1 Long file name with lots of words and characters just to test long file name entries in FAT file systems2 Long file name with lots of words and characters just to test long file name entries in FAT file systems3 Long file name with lots of words and characters just to test long file name entries in FAT file systems4 m o Ö p q r s t u Ü v w x y /dir3/ subDir /dir3/subDir/ /Directory1/ Long file name with lots of words and characters just to test long file name entries in FAT file systems1 Long file name with lots of words and characters just to test long file name entries in FAT file systems2 Long file name with lots of words and characters just to test long file name entries in FAT file systems3 Long file name with lots of words and characters just to test long file name entries in FAT file systems4 /directory2/ fatsort-1.3.365/tests/tc_pos_sort_default_fat12/directories.txt0000664000175000017500000000004212321036667024143 0ustar feanorfeanorDirectory1 directory2 dir3/subDir fatsort-1.3.365/tests/tc_pos_sort_dir6_fat32/0000775000175000017500000000000012321036667020314 5ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_sort_dir6_fat32/files.txt0000664000175000017500000000064412321036667022163 0ustar feanorfeanorz g u n w e o a c v dir1/z dir1/g dir1/u dir1/n dir1/w dir1/e dir1/o dir1/a dir1/c dir1/v dir2/z dir2/g dir2/u dir2/n dir2/w dir2/e dir2/o dir2/a dir2/c dir2/v dir3/z dir3/g dir3/u dir3/n dir3/w dir3/e dir3/o dir3/a dir3/c dir3/v dir4/z dir4/g dir4/u dir4/n dir4/w dir4/e dir4/o dir4/a dir4/c dir4/v dir4/dir5/z dir4/dir5/g dir4/dir5/u dir4/dir5/n dir4/dir5/w dir4/dir5/e dir4/dir5/o dir4/dir5/a dir4/dir5/c dir4/dir5/v fatsort-1.3.365/tests/tc_pos_sort_dir6_fat32/Makefile0000775000175000017500000000346412321036667021766 0ustar feanorfeanorinclude ../testconfig.mk FS_FATType=32 # MiBytes FS_SIZE=100 FS_FATs=1 FS_VOL_NAME=test FS_ROOT_ENTRIES=512 FS_RSVD_SEC=32 FS_SEC_PER_CLUS=1 FS_SEC_SIZE=512 DIRECTORIES=directories.txt FILES=files.txt TESTLOG=test.log STDOUT=stdout.log STDOUT_EXP=stdout_expected.txt STDERR=stderr.log STDERR_EXP=stderr_expected.txt all: fsck if [ ${DEL_FS_ON_PASS} -eq 1 ]; then rm -f ${FS_IMG}; fi clean: rm -fr *.log *.tmp ${FS_IMG} ${TMPFILE} ${TMPDIR} if [ -d ${MOUNT_POINT} ]; then \ until sudo umount ${MOUNT_POINT}; do sleep 1; done; \ rmdir ${MOUNT_POINT}; \ fi # create file system mkfs: # ++++++++++ Creating file ${FATType} system ++++++++++ rm -f ${FS_IMG} truncate -s ${FS_SIZE}MB ${FS_IMG} mkfs.vfat -F ${FS_FATType} -f ${FS_FATs} -n ${FS_VOL_NAME} -r ${FS_ROOT_ENTRIES} -R ${FS_RSVD_SEC} -s ${FS_SEC_PER_CLUS} -S ${FS_SEC_SIZE} ${FS_IMG} # populate fs populatefs: mkfs # ++++++++++ Populating file system with directories and files ++++++++++ mkdir -p ${MOUNT_POINT} sudo mount -o loop,codepage=850,iocharset=iso8859-1,utf8,uid=${MOUNT_UID},gid=${MOUNT_GID} ${FS_IMG} ${MOUNT_POINT} cat ${DIRECTORIES} | while read dir; do mkdir -p "${MOUNT_POINT}/$$dir"; done cat ${FILES} | while read file; do touch "${MOUNT_POINT}/$$file"; done # delete some files until sudo umount ${MOUNT_POINT}; do sleep 1; done rmdir ${MOUNT_POINT} # alter file system as necessary for the test alterfs: populatefs # ++++++++++ Altering file system ++++++++++ # empty here rm -fr ${TMPFILE} execute: alterfs # ++++++++++ Executing tests ++++++++++ ${FATSORT} -D / -X dir4 ${FS_IMG} ${FATSORT} -l ${FS_IMG} > ${STDOUT} 2> ${STDERR} diff ${STDOUT} ${STDOUT_EXP} diff ${STDERR} ${STDERR_EXP} # check result fsck: execute # ++++++++++ Checking file system ++++++++++ fsck.vfat -n ${FS_IMG} .PHONY: fsck execute populatefs mkfs clean fatsort-1.3.365/tests/tc_pos_sort_dir6_fat32/stderr_expected.txt0000664000175000017500000000000012321036667024227 0ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_sort_dir6_fat32/stdout_expected.txt0000664000175000017500000000032612321036667024261 0ustar feanorfeanorFile system: FAT32. / dir1 dir2 dir3 dir4 a c e g n o u v w z /dir1/ a c e g n o u v w z /dir2/ a c e g n o u v w z /dir3/ a c e g n o u v w z /dir4/ dir5 z g u n w e o a c v /dir4/dir5/ z g u n w e o a c v fatsort-1.3.365/tests/tc_pos_sort_dir6_fat32/directories.txt0000664000175000017500000000003112321036667023363 0ustar feanorfeanordir1 dir2 dir3 dir4/dir5 fatsort-1.3.365/tests/tc_pos_sort_order_files_fat12/0000775000175000017500000000000012321036670021735 5ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_sort_order_files_fat12/files.txt0000664000175000017500000000043112321036670023576 0ustar feanorfeanora b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z Ä Ö Ü file3.bin file2.bin file1.bin Long file name with lots of words and characters just to test long file name entries in FAT file systems 1 2 3 4 5 6 7 8 9 10 01b 1a 001c fatsort-1.3.365/tests/tc_pos_sort_order_files_fat12/Makefile0000775000175000017500000000345312321036670023405 0ustar feanorfeanorinclude ../testconfig.mk FS_FATType=12 # MiBytes FS_SIZE=10 FS_FATs=1 FS_VOL_NAME=test FS_ROOT_ENTRIES=512 FS_RSVD_SEC=32 FS_SEC_PER_CLUS=16 FS_SEC_SIZE=512 DIRECTORIES=directories.txt FILES=files.txt TESTLOG=test.log STDOUT=stdout.log STDOUT_EXP=stdout_expected.txt STDERR=stderr.log STDERR_EXP=stderr_expected.txt all: fsck if [ ${DEL_FS_ON_PASS} -eq 1 ]; then rm -f ${FS_IMG}; fi clean: rm -fr *.log *.tmp ${FS_IMG} ${TMPFILE} ${TMPDIR} if [ -d ${MOUNT_POINT} ]; then \ until sudo umount ${MOUNT_POINT}; do sleep 1; done; \ rmdir ${MOUNT_POINT}; \ fi # create file system mkfs: # ++++++++++ Creating file ${FATType} system ++++++++++ rm -f ${FS_IMG} truncate -s ${FS_SIZE}MB ${FS_IMG} mkfs.vfat -F ${FS_FATType} -f ${FS_FATs} -n ${FS_VOL_NAME} -r ${FS_ROOT_ENTRIES} -R ${FS_RSVD_SEC} -s ${FS_SEC_PER_CLUS} -S ${FS_SEC_SIZE} ${FS_IMG} # populate fs populatefs: mkfs # ++++++++++ Populating file system with directories and files ++++++++++ mkdir -p ${MOUNT_POINT} sudo mount -o loop,codepage=850,iocharset=iso8859-1,utf8,uid=${MOUNT_UID},gid=${MOUNT_GID} ${FS_IMG} ${MOUNT_POINT} cat ${DIRECTORIES} | while read dir; do mkdir -p "${MOUNT_POINT}/$$dir"; done cat ${FILES} | while read file; do touch "${MOUNT_POINT}/$$file"; done # delete some files until sudo umount ${MOUNT_POINT}; do sleep 1; done rmdir ${MOUNT_POINT} # alter file system as necessary for the test alterfs: populatefs # ++++++++++ Altering file system ++++++++++ # empty here rm -fr ${TMPFILE} execute: alterfs # ++++++++++ Executing tests ++++++++++ ${FATSORT} -of ${FS_IMG} ${FATSORT} -l ${FS_IMG} > ${STDOUT} 2> ${STDERR} diff ${STDOUT} ${STDOUT_EXP} diff ${STDERR} ${STDERR_EXP} # check result fsck: execute # ++++++++++ Checking file system ++++++++++ fsck.vfat -n ${FS_IMG} .PHONY: fsck execute populatefs mkfs clean fatsort-1.3.365/tests/tc_pos_sort_order_files_fat12/stderr_expected.txt0000664000175000017500000000000012321036670025650 0ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_sort_order_files_fat12/stdout_expected.txt0000664000175000017500000000052212321036670025700 0ustar feanorfeanorFile system: FAT12. / 001c 01b 1 10 1a 2 3 4 5 6 7 8 9 a Ä b c d e f file1.bin file2.bin file3.bin g h i j k l Long file name with lots of words and characters just to test long file name entries in FAT file systems m n o Ö p q r s t u Ü v w x y z dir3 Directory1 directory2 /dir3/ subDir /dir3/subDir/ /Directory1/ /directory2/ fatsort-1.3.365/tests/tc_pos_sort_order_files_fat12/directories.txt0000664000175000017500000000004212321036670025006 0ustar feanorfeanorDirectory1 directory2 dir3/subDir fatsort-1.3.365/tests/tc_neg_maximum_cluster_nr/0000775000175000017500000000000012321036667021267 5ustar feanorfeanorfatsort-1.3.365/tests/tc_neg_maximum_cluster_nr/files.txt0000664000175000017500000000001112321036667023122 0ustar feanorfeanordir/test fatsort-1.3.365/tests/tc_neg_maximum_cluster_nr/Makefile0000775000175000017500000000411012321036667022726 0ustar feanorfeanorinclude ../testconfig.mk FS_FATType=32 # 100 MiBytes FS_SIZE=100 FS_FATs=2 FS_VOL_NAME=test FS_ROOT_ENTRIES=512 FS_RSVD_SEC=32 FS_SEC_PER_CLUS=1 FS_SEC_SIZE=512 DIRECTORIES=directories.txt FILES=files.txt TESTLOG=test.log STDOUT=stdout.log STDOUT_EXP=stdout_expected.txt STDERR=stderr.log STDERR_EXP=stderr_expected.txt # no fsck in negative tests all: execute if [ ${DEL_FS_ON_PASS} -eq 1 ]; then rm -f ${FS_IMG}; fi clean: rm -fr *.log *.tmp ${FS_IMG} ${TMPFILE} ${TMPDIR} if [ -d ${MOUNT_POINT} ]; then \ until sudo umount ${MOUNT_POINT}; do sleep 1; done; \ rmdir ${MOUNT_POINT}; \ fi # create file system mkfs: # ++++++++++ Creating file ${FATType} system ++++++++++ rm -f ${FS_IMG} truncate -s ${FS_SIZE}MB ${FS_IMG} mkfs.vfat -F ${FS_FATType} -f ${FS_FATs} -n ${FS_VOL_NAME} -r ${FS_ROOT_ENTRIES} -R ${FS_RSVD_SEC} -s ${FS_SEC_PER_CLUS} -S ${FS_SEC_SIZE} ${FS_IMG} # populate fs populatefs: mkfs # ++++++++++ Populating file system with directories and files ++++++++++ mkdir -p ${MOUNT_POINT} sudo mount -o loop,codepage=850,iocharset=iso8859-1,utf8,uid=${MOUNT_UID},gid=${MOUNT_GID} ${FS_IMG} ${MOUNT_POINT} cat ${DIRECTORIES} | while read dir; do mkdir -p "${MOUNT_POINT}/$$dir"; done cat ${FILES} | while read file; do touch "${MOUNT_POINT}/$$file"; done rm -f "${MOUNT_POINT}/a" #remove some files rm -f "${MOUNT_POINT}/n" rm -f "${MOUNT_POINT}/z" until sudo umount ${MOUNT_POINT}; do sleep 1; done rmdir ${MOUNT_POINT} # alter file system as necessary for the test alterfs: populatefs # ++++++++++ Altering file system ++++++++++ # alter FAT to reference a cluster number higher than allowed ${BBE} -b x4008:4 -e "r 0 \x11\x11\x11\x01" ${FS_IMG} > ${TMPFILE} ${BBE} -b x0bfe08:4 -e "r 0 \x11\x11\x11\x01" ${TMPFILE} > ${FS_IMG} rm -fr ${TMPFILE} execute: alterfs # ++++++++++ Executing tests ++++++++++ ${FATSORT} ${FS_IMG} > ${STDOUT} 2> ${STDERR}; [ $$? -ne 0 ] diff ${STDOUT} ${STDOUT_EXP} diff ${STDERR} ${STDERR_EXP} # check result fsck: execute # ++++++++++ Checking file system ++++++++++ fsck.vfat -n ${FS_IMG} .PHONY: fsck execute populatefs mkfs clean fatsort-1.3.365/tests/tc_neg_maximum_cluster_nr/stderr_expected.txt0000664000175000017500000000026712321036667025221 0ustar feanorfeanorgetClusterChain: Cluster 01111111 does not exist! sortClusterChain: Failed to get cluster chain! sortFileSystem: Failed to sort first cluster chain! main: Failed to sort file system! fatsort-1.3.365/tests/tc_neg_maximum_cluster_nr/stdout_expected.txt0000664000175000017500000000002512321036667025230 0ustar feanorfeanorFile system: FAT32. fatsort-1.3.365/tests/tc_neg_maximum_cluster_nr/directories.txt0000664000175000017500000000000412321036667024336 0ustar feanorfeanordir fatsort-1.3.365/tests/tc_neg_bad_fat_size_fat32/0000775000175000017500000000000012321036667020763 5ustar feanorfeanorfatsort-1.3.365/tests/tc_neg_bad_fat_size_fat32/files.txt0000664000175000017500000000001112321036667022616 0ustar feanorfeanordir/test fatsort-1.3.365/tests/tc_neg_bad_fat_size_fat32/Makefile0000775000175000017500000000366312321036667022436 0ustar feanorfeanorinclude ../testconfig.mk FS_FATType=32 # 100 MiBytes FS_SIZE=100 FS_FATs=2 FS_VOL_NAME=test FS_ROOT_ENTRIES=512 FS_RSVD_SEC=32 FS_SEC_PER_CLUS=1 FS_SEC_SIZE=512 DIRECTORIES=directories.txt FILES=files.txt TESTLOG=test.log STDOUT=stdout.log STDOUT_EXP=stdout_expected.txt STDERR=stderr.log STDERR_EXP=stderr_expected.txt # no fsck in negative tests all: execute if [ ${DEL_FS_ON_PASS} -eq 1 ]; then rm -f ${FS_IMG}; fi clean: rm -fr *.log *.tmp ${FS_IMG} ${TMPFILE} ${TMPDIR} if [ -d ${MOUNT_POINT} ]; then \ until sudo umount ${MOUNT_POINT}; do sleep 1; done; \ rmdir ${MOUNT_POINT}; \ fi # create file system mkfs: # ++++++++++ Creating file ${FATType} system ++++++++++ rm -f ${FS_IMG} truncate -s ${FS_SIZE}MB ${FS_IMG} mkfs.vfat -F ${FS_FATType} -f ${FS_FATs} -n ${FS_VOL_NAME} -r ${FS_ROOT_ENTRIES} -R ${FS_RSVD_SEC} -s ${FS_SEC_PER_CLUS} -S ${FS_SEC_SIZE} ${FS_IMG} # populate fs populatefs: mkfs # ++++++++++ Populating file system with directories and files ++++++++++ mkdir -p ${MOUNT_POINT} sudo mount -o loop,codepage=850,iocharset=iso8859-1,utf8,uid=${MOUNT_UID},gid=${MOUNT_GID} ${FS_IMG} ${MOUNT_POINT} cat ${DIRECTORIES} | while read dir; do mkdir -p "${MOUNT_POINT}/$$dir"; done cat ${FILES} | while read file; do touch "${MOUNT_POINT}/$$file"; done until sudo umount ${MOUNT_POINT}; do sleep 1; done rmdir ${MOUNT_POINT} # alter file system as necessary for the test alterfs: populatefs # ++++++++++ Altering file system ++++++++++ # set 32-bit count of fat sectors to zero (bad for FAT32) ${BBE} -b x24:4 -e "r 0 \x00\x00\x00\x00" ${FS_IMG} > ${TMPFILE} cp ${TMPFILE} ${FS_IMG} rm -fr ${TMPFILE} execute: alterfs # ++++++++++ Executing tests ++++++++++ ${FATSORT} ${FS_IMG} > ${STDOUT} 2> ${STDERR}; [ $$? -ne 0 ] diff ${STDOUT} ${STDOUT_EXP} diff ${STDERR} ${STDERR_EXP} # check result fsck: execute # ++++++++++ Checking file system ++++++++++ fsck.vfat -n ${FS_IMG} .PHONY: fsck execute populatefs mkfs clean fatsort-1.3.365/tests/tc_neg_bad_fat_size_fat32/stderr_expected.txt0000664000175000017500000000022612321036667024710 0ustar feanorfeanoropenFileSystem: 32-bit count of FAT sectors must not be zero for FAT32! sortFileSystem: Failed to open file system! main: Failed to sort file system! fatsort-1.3.365/tests/tc_neg_bad_fat_size_fat32/stdout_expected.txt0000664000175000017500000000000012321036667024715 0ustar feanorfeanorfatsort-1.3.365/tests/tc_neg_bad_fat_size_fat32/directories.txt0000664000175000017500000000000412321036667024032 0ustar feanorfeanordir fatsort-1.3.365/tests/tc_pos_sort_order_any_fat12/0000775000175000017500000000000012321036667021430 5ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_sort_order_any_fat12/files.txt0000664000175000017500000000043112321036667023271 0ustar feanorfeanora b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z Ä Ö Ü file3.bin file2.bin file1.bin Long file name with lots of words and characters just to test long file name entries in FAT file systems 1 2 3 4 5 6 7 8 9 10 01b 1a 001c fatsort-1.3.365/tests/tc_pos_sort_order_any_fat12/Makefile0000775000175000017500000000345312321036667023100 0ustar feanorfeanorinclude ../testconfig.mk FS_FATType=12 # MiBytes FS_SIZE=10 FS_FATs=1 FS_VOL_NAME=test FS_ROOT_ENTRIES=512 FS_RSVD_SEC=32 FS_SEC_PER_CLUS=16 FS_SEC_SIZE=512 DIRECTORIES=directories.txt FILES=files.txt TESTLOG=test.log STDOUT=stdout.log STDOUT_EXP=stdout_expected.txt STDERR=stderr.log STDERR_EXP=stderr_expected.txt all: fsck if [ ${DEL_FS_ON_PASS} -eq 1 ]; then rm -f ${FS_IMG}; fi clean: rm -fr *.log *.tmp ${FS_IMG} ${TMPFILE} ${TMPDIR} if [ -d ${MOUNT_POINT} ]; then \ until sudo umount ${MOUNT_POINT}; do sleep 1; done; \ rmdir ${MOUNT_POINT}; \ fi # create file system mkfs: # ++++++++++ Creating file ${FATType} system ++++++++++ rm -f ${FS_IMG} truncate -s ${FS_SIZE}MB ${FS_IMG} mkfs.vfat -F ${FS_FATType} -f ${FS_FATs} -n ${FS_VOL_NAME} -r ${FS_ROOT_ENTRIES} -R ${FS_RSVD_SEC} -s ${FS_SEC_PER_CLUS} -S ${FS_SEC_SIZE} ${FS_IMG} # populate fs populatefs: mkfs # ++++++++++ Populating file system with directories and files ++++++++++ mkdir -p ${MOUNT_POINT} sudo mount -o loop,codepage=850,iocharset=iso8859-1,utf8,uid=${MOUNT_UID},gid=${MOUNT_GID} ${FS_IMG} ${MOUNT_POINT} cat ${DIRECTORIES} | while read dir; do mkdir -p "${MOUNT_POINT}/$$dir"; done cat ${FILES} | while read file; do touch "${MOUNT_POINT}/$$file"; done # delete some files until sudo umount ${MOUNT_POINT}; do sleep 1; done rmdir ${MOUNT_POINT} # alter file system as necessary for the test alterfs: populatefs # ++++++++++ Altering file system ++++++++++ # empty here rm -fr ${TMPFILE} execute: alterfs # ++++++++++ Executing tests ++++++++++ ${FATSORT} -oa ${FS_IMG} ${FATSORT} -l ${FS_IMG} > ${STDOUT} 2> ${STDERR} diff ${STDOUT} ${STDOUT_EXP} diff ${STDERR} ${STDERR_EXP} # check result fsck: execute # ++++++++++ Checking file system ++++++++++ fsck.vfat -n ${FS_IMG} .PHONY: fsck execute populatefs mkfs clean fatsort-1.3.365/tests/tc_pos_sort_order_any_fat12/stderr_expected.txt0000664000175000017500000000000012321036667025343 0ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_sort_order_any_fat12/stdout_expected.txt0000664000175000017500000000052212321036667025373 0ustar feanorfeanorFile system: FAT12. / 001c 01b 1 10 1a 2 3 4 5 6 7 8 9 a Ä b c d dir3 Directory1 directory2 e f file1.bin file2.bin file3.bin g h i j k l Long file name with lots of words and characters just to test long file name entries in FAT file systems m n o Ö p q r s t u Ü v w x y z /dir3/ subDir /dir3/subDir/ /Directory1/ /directory2/ fatsort-1.3.365/tests/tc_pos_sort_order_any_fat12/directories.txt0000664000175000017500000000004212321036667024501 0ustar feanorfeanorDirectory1 directory2 dir3/subDir fatsort-1.3.365/tests/tc_pos_char_enc_iso8859-1/0000775000175000017500000000000012321036667020512 5ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_char_enc_iso8859-1/files.txt0000664000175000017500000000015412321036667022355 0ustar feanorfeanorBärbel Brötchen Büchse Stoßzahn Directory1/Bärbel Directory1/Brötchen Directory1/Büchse Directory1/Stoßzahn fatsort-1.3.365/tests/tc_pos_char_enc_iso8859-1/Makefile0000664000175000017500000000345212321036667022156 0ustar feanorfeanorinclude ../testconfig.mk export LC_ALL=en_US.iso88591 FS_FATType=32 # MiBytes FS_SIZE=100 FS_FATs=2 FS_VOL_NAME=test FS_ROOT_ENTRIES=512 FS_RSVD_SEC=32 FS_SEC_PER_CLUS=1 FS_SEC_SIZE=512 DIRECTORIES=directories.txt FILES=files.txt TESTLOG=test.log STDOUT=stdout.log STDOUT_EXP=stdout_expected.txt STDERR=stderr.log STDERR_EXP=stderr_expected.txt all: fsck if [ ${DEL_FS_ON_PASS} -eq 1 ]; then rm -f ${FS_IMG}; fi clean: rm -fr *.log *.tmp ${FS_IMG} ${TMPFILE} ${TMPDIR} if [ -d ${MOUNT_POINT} ]; then \ until sudo umount ${MOUNT_POINT}; do sleep 1; done; \ rmdir ${MOUNT_POINT}; \ fi # create file system mkfs: # ++++++++++ Creating file ${FATType} system ++++++++++ rm -f ${FS_IMG} truncate -s ${FS_SIZE}MB ${FS_IMG} mkfs.vfat -F ${FS_FATType} -f ${FS_FATs} -n ${FS_VOL_NAME} -r ${FS_ROOT_ENTRIES} -R ${FS_RSVD_SEC} -s ${FS_SEC_PER_CLUS} -S ${FS_SEC_SIZE} ${FS_IMG} # populate fs populatefs: mkfs # ++++++++++ Populating file system with directories and files ++++++++++ mkdir -p ${MOUNT_POINT} sudo mount -o loop,codepage=850,iocharset=iso8859-1,uid=${MOUNT_UID},gid=${MOUNT_GID} ${FS_IMG} ${MOUNT_POINT} cat ${DIRECTORIES} | while read dir; do mkdir -p "${MOUNT_POINT}/$$dir"; done cat ${FILES} | while read file; do touch "${MOUNT_POINT}/$$file"; done until sudo umount ${MOUNT_POINT}; do sleep 1; done rmdir ${MOUNT_POINT} # alter file system as necessary for the test alterfs: populatefs # ++++++++++ Altering file system ++++++++++ # empty here rm -fr ${TMPFILE} execute: alterfs # ++++++++++ Executing tests ++++++++++ ${FATSORT} ${FS_IMG} ${FATSORT} -l ${FS_IMG} > ${STDOUT} 2> ${STDERR} diff ${STDOUT} ${STDOUT_EXP} diff ${STDERR} ${STDERR_EXP} # check result fsck: execute # ++++++++++ Checking file system ++++++++++ fsck.vfat -n ${FS_IMG} .PHONY: fsck execute populatefs mkfs clean fatsort-1.3.365/tests/tc_pos_char_enc_iso8859-1/stderr_expected.txt0000664000175000017500000000000012321036667024425 0ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_char_enc_iso8859-1/stdout_expected.txt0000664000175000017500000000016112321036667024454 0ustar feanorfeanorFile system: FAT32. / Directory1 Bärbel Brötchen Büchse Stoßzahn /Directory1/ Bärbel Brötchen Büchse Stoßzahn fatsort-1.3.365/tests/tc_pos_char_enc_iso8859-1/directories.txt0000664000175000017500000000001312321036667023561 0ustar feanorfeanorDirectory1 fatsort-1.3.365/tests/tc_pos_sort_prefixes_fat16/0000775000175000017500000000000012321036667021277 5ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_sort_prefixes_fat16/files.txt0000664000175000017500000000012212321036667023135 0ustar feanorfeanorTest/The Beatles Test/Beat me Test/The Unknown Test/UFO Test/ABC Test/Teletubbie fatsort-1.3.365/tests/tc_pos_sort_prefixes_fat16/Makefile0000775000175000017500000000346012321036667022745 0ustar feanorfeanorinclude ../testconfig.mk FS_FATType=16 # MiBytes FS_SIZE=10 FS_FATs=1 FS_VOL_NAME=test FS_ROOT_ENTRIES=512 FS_RSVD_SEC=32 FS_SEC_PER_CLUS=1 FS_SEC_SIZE=512 DIRECTORIES=directories.txt FILES=files.txt TESTLOG=test.log STDOUT=stdout.log STDOUT_EXP=stdout_expected.txt STDERR=stderr.log STDERR_EXP=stderr_expected.txt all: fsck if [ ${DEL_FS_ON_PASS} -eq 1 ]; then rm -f ${FS_IMG}; fi clean: rm -fr *.log *.tmp ${FS_IMG} ${TMPFILE} ${TMPDIR} if [ -d ${MOUNT_POINT} ]; then \ until sudo umount ${MOUNT_POINT}; do sleep 1; done; \ rmdir ${MOUNT_POINT}; \ fi # create file system mkfs: # ++++++++++ Creating file ${FATType} system ++++++++++ rm -f ${FS_IMG} truncate -s ${FS_SIZE}MB ${FS_IMG} mkfs.vfat -F ${FS_FATType} -f ${FS_FATs} -n ${FS_VOL_NAME} -r ${FS_ROOT_ENTRIES} -R ${FS_RSVD_SEC} -s ${FS_SEC_PER_CLUS} -S ${FS_SEC_SIZE} ${FS_IMG} # populate fs populatefs: mkfs # ++++++++++ Populating file system with directories and files ++++++++++ mkdir -p ${MOUNT_POINT} sudo mount -o loop,codepage=850,iocharset=iso8859-1,utf8,uid=${MOUNT_UID},gid=${MOUNT_GID} ${FS_IMG} ${MOUNT_POINT} cat ${DIRECTORIES} | while read dir; do mkdir -p "${MOUNT_POINT}/$$dir"; done cat ${FILES} | while read file; do touch "${MOUNT_POINT}/$$file"; done # delete some files until sudo umount ${MOUNT_POINT}; do sleep 1; done rmdir ${MOUNT_POINT} # alter file system as necessary for the test alterfs: populatefs # ++++++++++ Altering file system ++++++++++ # empty here rm -fr ${TMPFILE} execute: alterfs # ++++++++++ Executing tests ++++++++++ ${FATSORT} -I "The " ${FS_IMG} ${FATSORT} -l ${FS_IMG} > ${STDOUT} 2> ${STDERR} diff ${STDOUT} ${STDOUT_EXP} diff ${STDERR} ${STDERR_EXP} # check result fsck: execute # ++++++++++ Checking file system ++++++++++ fsck.vfat -n ${FS_IMG} .PHONY: fsck execute populatefs mkfs clean fatsort-1.3.365/tests/tc_pos_sort_prefixes_fat16/stderr_expected.txt0000664000175000017500000000000012321036667025212 0ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_sort_prefixes_fat16/stdout_expected.txt0000664000175000017500000000032012321036667025236 0ustar feanorfeanorFile system: FAT16. / ABC The Beatles Beat me Teletubbie Test UFO The Unknown /ABC/ /The Beatles/ /Beat me/ /Teletubbie/ /Test/ ABC The Beatles Beat me Teletubbie UFO The Unknown /UFO/ /The Unknown/ fatsort-1.3.365/tests/tc_pos_sort_prefixes_fat16/directories.txt0000664000175000017500000000007112321036667024352 0ustar feanorfeanorThe Beatles Beat me The Unknown UFO ABC Teletubbie Test fatsort-1.3.365/tests/tc_neg_bad_count_of_root_dir_entries_fat12/0000775000175000017500000000000012321036667024423 5ustar feanorfeanorfatsort-1.3.365/tests/tc_neg_bad_count_of_root_dir_entries_fat12/files.txt0000664000175000017500000000001112321036667026256 0ustar feanorfeanordir/test fatsort-1.3.365/tests/tc_neg_bad_count_of_root_dir_entries_fat12/Makefile0000775000175000017500000000364212321036667026073 0ustar feanorfeanorinclude ../testconfig.mk FS_FATType=12 # 100 MiBytes FS_SIZE=10 FS_FATs=2 FS_VOL_NAME=test FS_ROOT_ENTRIES=512 FS_RSVD_SEC=1 FS_SEC_PER_CLUS=16 FS_SEC_SIZE=512 DIRECTORIES=directories.txt FILES=files.txt TESTLOG=test.log STDOUT=stdout.log STDOUT_EXP=stdout_expected.txt STDERR=stderr.log STDERR_EXP=stderr_expected.txt # no fsck in negative tests all: execute if [ ${DEL_FS_ON_PASS} -eq 1 ]; then rm -f ${FS_IMG}; fi clean: rm -fr *.log *.tmp ${FS_IMG} ${TMPFILE} ${TMPDIR} if [ -d ${MOUNT_POINT} ]; then \ until sudo umount ${MOUNT_POINT}; do sleep 1; done; \ rmdir ${MOUNT_POINT}; \ fi # create file system mkfs: # ++++++++++ Creating file ${FATType} system ++++++++++ rm -f ${FS_IMG} truncate -s ${FS_SIZE}MB ${FS_IMG} mkfs.vfat -F ${FS_FATType} -f ${FS_FATs} -n ${FS_VOL_NAME} -r ${FS_ROOT_ENTRIES} -R ${FS_RSVD_SEC} -s ${FS_SEC_PER_CLUS} -S ${FS_SEC_SIZE} ${FS_IMG} # populate fs populatefs: mkfs # ++++++++++ Populating file system with directories and files ++++++++++ mkdir -p ${MOUNT_POINT} sudo mount -o loop,codepage=850,iocharset=iso8859-1,utf8,uid=${MOUNT_UID},gid=${MOUNT_GID} ${FS_IMG} ${MOUNT_POINT} cat ${DIRECTORIES} | while read dir; do mkdir -p "${MOUNT_POINT}/$$dir"; done cat ${FILES} | while read file; do touch "${MOUNT_POINT}/$$file"; done until sudo umount ${MOUNT_POINT}; do sleep 1; done rmdir ${MOUNT_POINT} # alter file system as necessary for the test alterfs: populatefs # ++++++++++ Altering file system ++++++++++ # set root dir entries to 0 (bad for FAT16/FAT12) ${BBE} -b x11:2 -e "r 0 \x00\x00" ${FS_IMG} > ${TMPFILE} cp ${TMPFILE} ${FS_IMG} rm -fr ${TMPFILE} execute: alterfs # ++++++++++ Executing tests ++++++++++ ${FATSORT} ${FS_IMG} > ${STDOUT} 2> ${STDERR}; [ $$? -ne 0 ] diff ${STDOUT} ${STDOUT_EXP} diff ${STDERR} ${STDERR_EXP} # check result fsck: execute # ++++++++++ Checking file system ++++++++++ fsck.vfat -n ${FS_IMG} .PHONY: fsck execute populatefs mkfs clean fatsort-1.3.365/tests/tc_neg_bad_count_of_root_dir_entries_fat12/stderr_expected.txt0000664000175000017500000000023212321036667030345 0ustar feanorfeanoropenFileSystem: Count of root directory entries must not be zero for FAT1x! sortFileSystem: Failed to open file system! main: Failed to sort file system! fatsort-1.3.365/tests/tc_neg_bad_count_of_root_dir_entries_fat12/stdout_expected.txt0000664000175000017500000000000012321036667030355 0ustar feanorfeanorfatsort-1.3.365/tests/tc_neg_bad_count_of_root_dir_entries_fat12/directories.txt0000664000175000017500000000000412321036667027472 0ustar feanorfeanordir fatsort-1.3.365/tests/tc_pos_sort_dir6_fat12/0000775000175000017500000000000012321036667020312 5ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_sort_dir6_fat12/files.txt0000664000175000017500000000064412321036667022161 0ustar feanorfeanorz g u n w e o a c v dir1/z dir1/g dir1/u dir1/n dir1/w dir1/e dir1/o dir1/a dir1/c dir1/v dir2/z dir2/g dir2/u dir2/n dir2/w dir2/e dir2/o dir2/a dir2/c dir2/v dir3/z dir3/g dir3/u dir3/n dir3/w dir3/e dir3/o dir3/a dir3/c dir3/v dir4/z dir4/g dir4/u dir4/n dir4/w dir4/e dir4/o dir4/a dir4/c dir4/v dir4/dir5/z dir4/dir5/g dir4/dir5/u dir4/dir5/n dir4/dir5/w dir4/dir5/e dir4/dir5/o dir4/dir5/a dir4/dir5/c dir4/dir5/v fatsort-1.3.365/tests/tc_pos_sort_dir6_fat12/Makefile0000775000175000017500000000346412321036667021764 0ustar feanorfeanorinclude ../testconfig.mk FS_FATType=12 # MiBytes FS_SIZE=10 FS_FATs=1 FS_VOL_NAME=test FS_ROOT_ENTRIES=512 FS_RSVD_SEC=32 FS_SEC_PER_CLUS=16 FS_SEC_SIZE=512 DIRECTORIES=directories.txt FILES=files.txt TESTLOG=test.log STDOUT=stdout.log STDOUT_EXP=stdout_expected.txt STDERR=stderr.log STDERR_EXP=stderr_expected.txt all: fsck if [ ${DEL_FS_ON_PASS} -eq 1 ]; then rm -f ${FS_IMG}; fi clean: rm -fr *.log *.tmp ${FS_IMG} ${TMPFILE} ${TMPDIR} if [ -d ${MOUNT_POINT} ]; then \ until sudo umount ${MOUNT_POINT}; do sleep 1; done; \ rmdir ${MOUNT_POINT}; \ fi # create file system mkfs: # ++++++++++ Creating file ${FATType} system ++++++++++ rm -f ${FS_IMG} truncate -s ${FS_SIZE}MB ${FS_IMG} mkfs.vfat -F ${FS_FATType} -f ${FS_FATs} -n ${FS_VOL_NAME} -r ${FS_ROOT_ENTRIES} -R ${FS_RSVD_SEC} -s ${FS_SEC_PER_CLUS} -S ${FS_SEC_SIZE} ${FS_IMG} # populate fs populatefs: mkfs # ++++++++++ Populating file system with directories and files ++++++++++ mkdir -p ${MOUNT_POINT} sudo mount -o loop,codepage=850,iocharset=iso8859-1,utf8,uid=${MOUNT_UID},gid=${MOUNT_GID} ${FS_IMG} ${MOUNT_POINT} cat ${DIRECTORIES} | while read dir; do mkdir -p "${MOUNT_POINT}/$$dir"; done cat ${FILES} | while read file; do touch "${MOUNT_POINT}/$$file"; done # delete some files until sudo umount ${MOUNT_POINT}; do sleep 1; done rmdir ${MOUNT_POINT} # alter file system as necessary for the test alterfs: populatefs # ++++++++++ Altering file system ++++++++++ # empty here rm -fr ${TMPFILE} execute: alterfs # ++++++++++ Executing tests ++++++++++ ${FATSORT} -D / -X dir4 ${FS_IMG} ${FATSORT} -l ${FS_IMG} > ${STDOUT} 2> ${STDERR} diff ${STDOUT} ${STDOUT_EXP} diff ${STDERR} ${STDERR_EXP} # check result fsck: execute # ++++++++++ Checking file system ++++++++++ fsck.vfat -n ${FS_IMG} .PHONY: fsck execute populatefs mkfs clean fatsort-1.3.365/tests/tc_pos_sort_dir6_fat12/stderr_expected.txt0000664000175000017500000000000012321036667024225 0ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_sort_dir6_fat12/stdout_expected.txt0000664000175000017500000000032612321036667024257 0ustar feanorfeanorFile system: FAT12. / dir1 dir2 dir3 dir4 a c e g n o u v w z /dir1/ a c e g n o u v w z /dir2/ a c e g n o u v w z /dir3/ a c e g n o u v w z /dir4/ dir5 z g u n w e o a c v /dir4/dir5/ z g u n w e o a c v fatsort-1.3.365/tests/tc_pos_sort_dir6_fat12/directories.txt0000664000175000017500000000003112321036667023361 0ustar feanorfeanordir1 dir2 dir3 dir4/dir5 fatsort-1.3.365/tests/tc_pos_sort_ascii_fat16/0000775000175000017500000000000012321036667020542 5ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_sort_ascii_fat16/files.txt0000664000175000017500000000001712321036667022403 0ustar feanorfeanorABC1 Abc2 abc3 fatsort-1.3.365/tests/tc_pos_sort_ascii_fat16/Makefile0000775000175000017500000000342412321036667022210 0ustar feanorfeanorinclude ../testconfig.mk FS_FATType=16 # MiBytes FS_SIZE=10 FS_FATs=2 FS_VOL_NAME=test FS_ROOT_ENTRIES=512 FS_RSVD_SEC=32 FS_SEC_PER_CLUS=1 FS_SEC_SIZE=512 DIRECTORIES=directories.txt FILES=files.txt TESTLOG=test.log STDOUT=stdout.log STDOUT_EXP=stdout_expected.txt STDERR=stderr.log STDERR_EXP=stderr_expected.txt all: fsck if [ ${DEL_FS_ON_PASS} -eq 1 ]; then rm -f ${FS_IMG}; fi clean: rm -fr *.log *.tmp ${FS_IMG} ${TMPFILE} ${TMPDIR} if [ -d ${MOUNT_POINT} ]; then \ until sudo umount ${MOUNT_POINT}; do sleep 1; done; \ rmdir ${MOUNT_POINT}; \ fi # create file system mkfs: # ++++++++++ Creating file ${FATType} system ++++++++++ rm -f ${FS_IMG} truncate -s ${FS_SIZE}MB ${FS_IMG} mkfs.vfat -F ${FS_FATType} -f ${FS_FATs} -n ${FS_VOL_NAME} -r ${FS_ROOT_ENTRIES} -R ${FS_RSVD_SEC} -s ${FS_SEC_PER_CLUS} -S ${FS_SEC_SIZE} ${FS_IMG} # populate fs populatefs: mkfs # ++++++++++ Populating file system with directories and files ++++++++++ mkdir -p ${MOUNT_POINT} sudo mount -o loop,codepage=850,iocharset=iso8859-1,utf8,uid=${MOUNT_UID},gid=${MOUNT_GID} ${FS_IMG} ${MOUNT_POINT} cat ${DIRECTORIES} | while read dir; do mkdir -p "${MOUNT_POINT}/$$dir"; done cat ${FILES} | while read file; do touch "${MOUNT_POINT}/$$file"; done until sudo umount ${MOUNT_POINT}; do sleep 1; done rmdir ${MOUNT_POINT} # alter file system as necessary for the test alterfs: populatefs # ++++++++++ Altering file system ++++++++++ # empty here rm -fr ${TMPFILE} execute: alterfs # ++++++++++ Executing tests ++++++++++ ${FATSORT} -a ${FS_IMG} ${FATSORT} -l ${FS_IMG} > ${STDOUT} 2> ${STDERR} diff ${STDOUT} ${STDOUT_EXP} diff ${STDERR} ${STDERR_EXP} # check result fsck: execute # ++++++++++ Checking file system ++++++++++ fsck.vfat -n ${FS_IMG} .PHONY: fsck execute populatefs mkfs clean fatsort-1.3.365/tests/tc_pos_sort_ascii_fat16/stderr_expected.txt0000664000175000017500000000000012321036667024455 0ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_sort_ascii_fat16/stdout_expected.txt0000664000175000017500000000014612321036667024507 0ustar feanorfeanorFile system: FAT16. / dir_ABC2 dir_Abc1 dir_abc3 ABC1 Abc2 abc3 /dir_ABC2/ /dir_Abc1/ /dir_abc3/ fatsort-1.3.365/tests/tc_pos_sort_ascii_fat16/directories.txt0000664000175000017500000000003312321036667023613 0ustar feanorfeanordir_Abc1 dir_ABC2 dir_abc3 fatsort-1.3.365/tests/tc_pos_sort_order_any_fat16/0000775000175000017500000000000012321036667021434 5ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_sort_order_any_fat16/files.txt0000664000175000017500000000043112321036667023275 0ustar feanorfeanora b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z Ä Ö Ü file3.bin file2.bin file1.bin Long file name with lots of words and characters just to test long file name entries in FAT file systems 1 2 3 4 5 6 7 8 9 10 01b 1a 001c fatsort-1.3.365/tests/tc_pos_sort_order_any_fat16/Makefile0000775000175000017500000000345212321036667023103 0ustar feanorfeanorinclude ../testconfig.mk FS_FATType=16 # MiBytes FS_SIZE=10 FS_FATs=1 FS_VOL_NAME=test FS_ROOT_ENTRIES=512 FS_RSVD_SEC=32 FS_SEC_PER_CLUS=1 FS_SEC_SIZE=512 DIRECTORIES=directories.txt FILES=files.txt TESTLOG=test.log STDOUT=stdout.log STDOUT_EXP=stdout_expected.txt STDERR=stderr.log STDERR_EXP=stderr_expected.txt all: fsck if [ ${DEL_FS_ON_PASS} -eq 1 ]; then rm -f ${FS_IMG}; fi clean: rm -fr *.log *.tmp ${FS_IMG} ${TMPFILE} ${TMPDIR} if [ -d ${MOUNT_POINT} ]; then \ until sudo umount ${MOUNT_POINT}; do sleep 1; done; \ rmdir ${MOUNT_POINT}; \ fi # create file system mkfs: # ++++++++++ Creating file ${FATType} system ++++++++++ rm -f ${FS_IMG} truncate -s ${FS_SIZE}MB ${FS_IMG} mkfs.vfat -F ${FS_FATType} -f ${FS_FATs} -n ${FS_VOL_NAME} -r ${FS_ROOT_ENTRIES} -R ${FS_RSVD_SEC} -s ${FS_SEC_PER_CLUS} -S ${FS_SEC_SIZE} ${FS_IMG} # populate fs populatefs: mkfs # ++++++++++ Populating file system with directories and files ++++++++++ mkdir -p ${MOUNT_POINT} sudo mount -o loop,codepage=850,iocharset=iso8859-1,utf8,uid=${MOUNT_UID},gid=${MOUNT_GID} ${FS_IMG} ${MOUNT_POINT} cat ${DIRECTORIES} | while read dir; do mkdir -p "${MOUNT_POINT}/$$dir"; done cat ${FILES} | while read file; do touch "${MOUNT_POINT}/$$file"; done # delete some files until sudo umount ${MOUNT_POINT}; do sleep 1; done rmdir ${MOUNT_POINT} # alter file system as necessary for the test alterfs: populatefs # ++++++++++ Altering file system ++++++++++ # empty here rm -fr ${TMPFILE} execute: alterfs # ++++++++++ Executing tests ++++++++++ ${FATSORT} -oa ${FS_IMG} ${FATSORT} -l ${FS_IMG} > ${STDOUT} 2> ${STDERR} diff ${STDOUT} ${STDOUT_EXP} diff ${STDERR} ${STDERR_EXP} # check result fsck: execute # ++++++++++ Checking file system ++++++++++ fsck.vfat -n ${FS_IMG} .PHONY: fsck execute populatefs mkfs clean fatsort-1.3.365/tests/tc_pos_sort_order_any_fat16/stderr_expected.txt0000664000175000017500000000000012321036667025347 0ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_sort_order_any_fat16/stdout_expected.txt0000664000175000017500000000052212321036667025377 0ustar feanorfeanorFile system: FAT16. / 001c 01b 1 10 1a 2 3 4 5 6 7 8 9 a Ä b c d dir3 Directory1 directory2 e f file1.bin file2.bin file3.bin g h i j k l Long file name with lots of words and characters just to test long file name entries in FAT file systems m n o Ö p q r s t u Ü v w x y z /dir3/ subDir /dir3/subDir/ /Directory1/ /directory2/ fatsort-1.3.365/tests/tc_pos_sort_order_any_fat16/directories.txt0000664000175000017500000000004212321036667024505 0ustar feanorfeanorDirectory1 directory2 dir3/subDir fatsort-1.3.365/tests/tc_pos_sort_reverse_fat16/0000775000175000017500000000000012321036667021125 5ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_sort_reverse_fat16/files.txt0000664000175000017500000000043112321036667022766 0ustar feanorfeanora b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z Ä Ö Ü file3.bin file2.bin file1.bin Long file name with lots of words and characters just to test long file name entries in FAT file systems 1 2 3 4 5 6 7 8 9 10 01b 1a 001c fatsort-1.3.365/tests/tc_pos_sort_reverse_fat16/Makefile0000775000175000017500000000345112321036667022573 0ustar feanorfeanorinclude ../testconfig.mk FS_FATType=16 # MiBytes FS_SIZE=10 FS_FATs=1 FS_VOL_NAME=test FS_ROOT_ENTRIES=512 FS_RSVD_SEC=32 FS_SEC_PER_CLUS=1 FS_SEC_SIZE=512 DIRECTORIES=directories.txt FILES=files.txt TESTLOG=test.log STDOUT=stdout.log STDOUT_EXP=stdout_expected.txt STDERR=stderr.log STDERR_EXP=stderr_expected.txt all: fsck if [ ${DEL_FS_ON_PASS} -eq 1 ]; then rm -f ${FS_IMG}; fi clean: rm -fr *.log *.tmp ${FS_IMG} ${TMPFILE} ${TMPDIR} if [ -d ${MOUNT_POINT} ]; then \ until sudo umount ${MOUNT_POINT}; do sleep 1; done; \ rmdir ${MOUNT_POINT}; \ fi # create file system mkfs: # ++++++++++ Creating file ${FATType} system ++++++++++ rm -f ${FS_IMG} truncate -s ${FS_SIZE}MB ${FS_IMG} mkfs.vfat -F ${FS_FATType} -f ${FS_FATs} -n ${FS_VOL_NAME} -r ${FS_ROOT_ENTRIES} -R ${FS_RSVD_SEC} -s ${FS_SEC_PER_CLUS} -S ${FS_SEC_SIZE} ${FS_IMG} # populate fs populatefs: mkfs # ++++++++++ Populating file system with directories and files ++++++++++ mkdir -p ${MOUNT_POINT} sudo mount -o loop,codepage=850,iocharset=iso8859-1,utf8,uid=${MOUNT_UID},gid=${MOUNT_GID} ${FS_IMG} ${MOUNT_POINT} cat ${DIRECTORIES} | while read dir; do mkdir -p "${MOUNT_POINT}/$$dir"; done cat ${FILES} | while read file; do touch "${MOUNT_POINT}/$$file"; done # delete some files until sudo umount ${MOUNT_POINT}; do sleep 1; done rmdir ${MOUNT_POINT} # alter file system as necessary for the test alterfs: populatefs # ++++++++++ Altering file system ++++++++++ # empty here rm -fr ${TMPFILE} execute: alterfs # ++++++++++ Executing tests ++++++++++ ${FATSORT} -r ${FS_IMG} ${FATSORT} -l ${FS_IMG} > ${STDOUT} 2> ${STDERR} diff ${STDOUT} ${STDOUT_EXP} diff ${STDERR} ${STDERR_EXP} # check result fsck: execute # ++++++++++ Checking file system ++++++++++ fsck.vfat -n ${FS_IMG} .PHONY: fsck execute populatefs mkfs clean fatsort-1.3.365/tests/tc_pos_sort_reverse_fat16/stderr_expected.txt0000664000175000017500000000000012321036667025040 0ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_sort_reverse_fat16/stdout_expected.txt0000664000175000017500000000052212321036667025070 0ustar feanorfeanorFile system: FAT16. / directory2 Directory1 dir3 z y x w v Ü u t s r q p Ö o n m Long file name with lots of words and characters just to test long file name entries in FAT file systems l k j i h g file3.bin file2.bin file1.bin f e d c b Ä a 9 8 7 6 5 4 3 2 1a 10 1 01b 001c /directory2/ /Directory1/ /dir3/ subDir /dir3/subDir/ fatsort-1.3.365/tests/tc_pos_sort_reverse_fat16/directories.txt0000664000175000017500000000004212321036667024176 0ustar feanorfeanorDirectory1 directory2 dir3/subDir fatsort-1.3.365/tests/tc_neg_cluster_chain_loop/0000775000175000017500000000000012321036667021226 5ustar feanorfeanorfatsort-1.3.365/tests/tc_neg_cluster_chain_loop/files.txt0000664000175000017500000000001112321036667023061 0ustar feanorfeanordir/test fatsort-1.3.365/tests/tc_neg_cluster_chain_loop/Makefile0000775000175000017500000000406312321036667022674 0ustar feanorfeanorinclude ../testconfig.mk FS_FATType=32 # 100 MiBytes FS_SIZE=100 FS_FATs=2 FS_VOL_NAME=test FS_ROOT_ENTRIES=512 FS_RSVD_SEC=32 FS_SEC_PER_CLUS=1 FS_SEC_SIZE=512 DIRECTORIES=directories.txt FILES=files.txt TESTLOG=test.log STDOUT=stdout.log STDOUT_EXP=stdout_expected.txt STDERR=stderr.log STDERR_EXP=stderr_expected.txt # no fsck in negative tests all: execute if [ ${DEL_FS_ON_PASS} -eq 1 ]; then rm -f ${FS_IMG}; fi clean: rm -fr *.log *.tmp ${FS_IMG} ${TMPFILE} ${TMPDIR} if [ -d ${MOUNT_POINT} ]; then \ until sudo umount ${MOUNT_POINT}; do sleep 1; done; \ rmdir ${MOUNT_POINT}; \ fi # create file system mkfs: # ++++++++++ Creating file ${FATType} system ++++++++++ rm -f ${FS_IMG} truncate -s ${FS_SIZE}MB ${FS_IMG} mkfs.vfat -F ${FS_FATType} -f ${FS_FATs} -n ${FS_VOL_NAME} -r ${FS_ROOT_ENTRIES} -R ${FS_RSVD_SEC} -s ${FS_SEC_PER_CLUS} -S ${FS_SEC_SIZE} ${FS_IMG} # populate fs populatefs: mkfs # ++++++++++ Populating file system with directories and files ++++++++++ mkdir -p ${MOUNT_POINT} sudo mount -o loop,codepage=850,iocharset=iso8859-1,utf8,uid=${MOUNT_UID},gid=${MOUNT_GID} ${FS_IMG} ${MOUNT_POINT} cat ${DIRECTORIES} | while read dir; do mkdir -p "${MOUNT_POINT}/$$dir"; done cat ${FILES} | while read file; do touch "${MOUNT_POINT}/$$file"; done rm -f "${MOUNT_POINT}/a" #remove some files rm -f "${MOUNT_POINT}/n" rm -f "${MOUNT_POINT}/z" until sudo umount ${MOUNT_POINT}; do sleep 1; done rmdir ${MOUNT_POINT} # alter file system as necessary for the test alterfs: populatefs # ++++++++++ Altering file system ++++++++++ # alter fs to create a cluster chain loop ${BBE} -b x4008:4 -e "r 0 \x02\x00\x00\x00" ${FS_IMG} > ${TMPFILE} ${BBE} -b x0bfe08:4 -e "r 0 \x02\x00\x00\x00" ${TMPFILE} > ${FS_IMG} rm -fr ${TMPFILE} execute: alterfs # ++++++++++ Executing tests ++++++++++ ${FATSORT} ${FS_IMG} > ${STDOUT} 2> ${STDERR}; [ $$? -ne 0 ] diff ${STDOUT} ${STDOUT_EXP} diff ${STDERR} ${STDERR_EXP} # check result fsck: execute # ++++++++++ Checking file system ++++++++++ fsck.vfat -n ${FS_IMG} .PHONY: fsck execute populatefs mkfs clean fatsort-1.3.365/tests/tc_neg_cluster_chain_loop/stderr_expected.txt0000664000175000017500000000035212321036667025153 0ustar feanorfeanorinsertCluster: Loop in cluster chain detected (00000002)! getClusterChain: Failed to insert cluster! sortClusterChain: Failed to get cluster chain! sortFileSystem: Failed to sort first cluster chain! main: Failed to sort file system! fatsort-1.3.365/tests/tc_neg_cluster_chain_loop/stdout_expected.txt0000664000175000017500000000002512321036667025167 0ustar feanorfeanorFile system: FAT32. fatsort-1.3.365/tests/tc_neg_cluster_chain_loop/directories.txt0000664000175000017500000000000412321036667024275 0ustar feanorfeanordir fatsort-1.3.365/tests/tc_pos_sort_prefixes_fat12/0000775000175000017500000000000012321036667021273 5ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_sort_prefixes_fat12/files.txt0000664000175000017500000000012212321036667023131 0ustar feanorfeanorTest/The Beatles Test/Beat me Test/The Unknown Test/UFO Test/ABC Test/Teletubbie fatsort-1.3.365/tests/tc_pos_sort_prefixes_fat12/Makefile0000775000175000017500000000346112321036667022742 0ustar feanorfeanorinclude ../testconfig.mk FS_FATType=12 # MiBytes FS_SIZE=10 FS_FATs=1 FS_VOL_NAME=test FS_ROOT_ENTRIES=512 FS_RSVD_SEC=32 FS_SEC_PER_CLUS=16 FS_SEC_SIZE=512 DIRECTORIES=directories.txt FILES=files.txt TESTLOG=test.log STDOUT=stdout.log STDOUT_EXP=stdout_expected.txt STDERR=stderr.log STDERR_EXP=stderr_expected.txt all: fsck if [ ${DEL_FS_ON_PASS} -eq 1 ]; then rm -f ${FS_IMG}; fi clean: rm -fr *.log *.tmp ${FS_IMG} ${TMPFILE} ${TMPDIR} if [ -d ${MOUNT_POINT} ]; then \ until sudo umount ${MOUNT_POINT}; do sleep 1; done; \ rmdir ${MOUNT_POINT}; \ fi # create file system mkfs: # ++++++++++ Creating file ${FATType} system ++++++++++ rm -f ${FS_IMG} truncate -s ${FS_SIZE}MB ${FS_IMG} mkfs.vfat -F ${FS_FATType} -f ${FS_FATs} -n ${FS_VOL_NAME} -r ${FS_ROOT_ENTRIES} -R ${FS_RSVD_SEC} -s ${FS_SEC_PER_CLUS} -S ${FS_SEC_SIZE} ${FS_IMG} # populate fs populatefs: mkfs # ++++++++++ Populating file system with directories and files ++++++++++ mkdir -p ${MOUNT_POINT} sudo mount -o loop,codepage=850,iocharset=iso8859-1,utf8,uid=${MOUNT_UID},gid=${MOUNT_GID} ${FS_IMG} ${MOUNT_POINT} cat ${DIRECTORIES} | while read dir; do mkdir -p "${MOUNT_POINT}/$$dir"; done cat ${FILES} | while read file; do touch "${MOUNT_POINT}/$$file"; done # delete some files until sudo umount ${MOUNT_POINT}; do sleep 1; done rmdir ${MOUNT_POINT} # alter file system as necessary for the test alterfs: populatefs # ++++++++++ Altering file system ++++++++++ # empty here rm -fr ${TMPFILE} execute: alterfs # ++++++++++ Executing tests ++++++++++ ${FATSORT} -I "The " ${FS_IMG} ${FATSORT} -l ${FS_IMG} > ${STDOUT} 2> ${STDERR} diff ${STDOUT} ${STDOUT_EXP} diff ${STDERR} ${STDERR_EXP} # check result fsck: execute # ++++++++++ Checking file system ++++++++++ fsck.vfat -n ${FS_IMG} .PHONY: fsck execute populatefs mkfs clean fatsort-1.3.365/tests/tc_pos_sort_prefixes_fat12/stderr_expected.txt0000664000175000017500000000000012321036667025206 0ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_sort_prefixes_fat12/stdout_expected.txt0000664000175000017500000000032012321036667025232 0ustar feanorfeanorFile system: FAT12. / ABC The Beatles Beat me Teletubbie Test UFO The Unknown /ABC/ /The Beatles/ /Beat me/ /Teletubbie/ /Test/ ABC The Beatles Beat me Teletubbie UFO The Unknown /UFO/ /The Unknown/ fatsort-1.3.365/tests/tc_pos_sort_prefixes_fat12/directories.txt0000664000175000017500000000007112321036667024346 0ustar feanorfeanorThe Beatles Beat me The Unknown UFO ABC Teletubbie Test fatsort-1.3.365/tests/tc_check_consistent_version/0000775000175000017500000000000012321036667021614 5ustar feanorfeanorfatsort-1.3.365/tests/tc_check_consistent_version/Makefile0000775000175000017500000000067212321036667023264 0ustar feanorfeanorinclude ../testconfig.mk all: manver=\ `head -2 ../../man/fatsort.1 | tail -1 | sed -e "s/^.*\"fatsort \([0-9.]\+\)\".*$$/\1/"`; \ progver=`../../src/fatsort --version | head -1 | sed -e "s/^fatsort \([0-9.]\+\).*$$/\1/"`; \ changesver=`head -1 ../../CHANGES | sed -e "s/^.*v\([0-9.]\+\)$$/\1/"`; \ echo "#$$manver#$$progver#$$changesver#"; \ [ "$$manver" = "$$progver" ]; \ [ "$$changesver" = "$$progver" ] clean: .PHONY: clean fatsort-1.3.365/tests/testconfig.mk0000664000175000017500000000056212321036670016526 0ustar feanorfeanorSHELL=/bin/bash BBE=bbe FATSORT=../../src/fatsort CURRENT_DIR=$(shell basename ${CURDIR}) MOUNT_POINT=/tmp/fatsort-${CURRENT_DIR}-mountpoint MOUNT_UID=1000 MOUNT_GID=1000 FS_IMG=/tmp/fatsort-${CURRENT_DIR}-fs.img # delete fs when test passed DEL_FS_ON_PASS=1 TMPFILE=/tmp/fatsort-${CURRENT_DIR}-tmpfile TMPDIR=/tmp/fatsort-${CURRENT_DIR}-tmpdir export LC_ALL=en_US.utf8 fatsort-1.3.365/tests/tc_neg_bad_count_of_root_dir_entries_fat32/0000775000175000017500000000000012321036667024425 5ustar feanorfeanorfatsort-1.3.365/tests/tc_neg_bad_count_of_root_dir_entries_fat32/files.txt0000664000175000017500000000001112321036667026260 0ustar feanorfeanordir/test fatsort-1.3.365/tests/tc_neg_bad_count_of_root_dir_entries_fat32/Makefile0000775000175000017500000000363612321036667026100 0ustar feanorfeanorinclude ../testconfig.mk FS_FATType=32 # 100 MiBytes FS_SIZE=100 FS_FATs=2 FS_VOL_NAME=test FS_ROOT_ENTRIES=512 FS_RSVD_SEC=32 FS_SEC_PER_CLUS=1 FS_SEC_SIZE=512 DIRECTORIES=directories.txt FILES=files.txt TESTLOG=test.log STDOUT=stdout.log STDOUT_EXP=stdout_expected.txt STDERR=stderr.log STDERR_EXP=stderr_expected.txt # no fsck in negative tests all: execute if [ ${DEL_FS_ON_PASS} -eq 1 ]; then rm -f ${FS_IMG}; fi clean: rm -fr *.log *.tmp ${FS_IMG} ${TMPFILE} ${TMPDIR} if [ -d ${MOUNT_POINT} ]; then \ until sudo umount ${MOUNT_POINT}; do sleep 1; done; \ rmdir ${MOUNT_POINT}; \ fi # create file system mkfs: # ++++++++++ Creating file ${FATType} system ++++++++++ rm -f ${FS_IMG} truncate -s ${FS_SIZE}MB ${FS_IMG} mkfs.vfat -F ${FS_FATType} -f ${FS_FATs} -n ${FS_VOL_NAME} -r ${FS_ROOT_ENTRIES} -R ${FS_RSVD_SEC} -s ${FS_SEC_PER_CLUS} -S ${FS_SEC_SIZE} ${FS_IMG} # populate fs populatefs: mkfs # ++++++++++ Populating file system with directories and files ++++++++++ mkdir -p ${MOUNT_POINT} sudo mount -o loop,codepage=850,iocharset=iso8859-1,utf8,uid=${MOUNT_UID},gid=${MOUNT_GID} ${FS_IMG} ${MOUNT_POINT} cat ${DIRECTORIES} | while read dir; do mkdir -p "${MOUNT_POINT}/$$dir"; done cat ${FILES} | while read file; do touch "${MOUNT_POINT}/$$file"; done until sudo umount ${MOUNT_POINT}; do sleep 1; done rmdir ${MOUNT_POINT} # alter file system as necessary for the test alterfs: populatefs # ++++++++++ Altering file system ++++++++++ # set root dir entries to 32 (bad for FAT32) ${BBE} -b x11:2 -e "r 0 \x20\x00" ${FS_IMG} > ${TMPFILE} cp ${TMPFILE} ${FS_IMG} rm -fr ${TMPFILE} execute: alterfs # ++++++++++ Executing tests ++++++++++ ${FATSORT} ${FS_IMG} > ${STDOUT} 2> ${STDERR}; [ $$? -ne 0 ] diff ${STDOUT} ${STDOUT_EXP} diff ${STDERR} ${STDERR_EXP} # check result fsck: execute # ++++++++++ Checking file system ++++++++++ fsck.vfat -n ${FS_IMG} .PHONY: fsck execute populatefs mkfs clean fatsort-1.3.365/tests/tc_neg_bad_count_of_root_dir_entries_fat32/stderr_expected.txt0000664000175000017500000000023312321036667030350 0ustar feanorfeanoropenFileSystem: Count of root directory entries must be zero for FAT32 (32)! sortFileSystem: Failed to open file system! main: Failed to sort file system! fatsort-1.3.365/tests/tc_neg_bad_count_of_root_dir_entries_fat32/stdout_expected.txt0000664000175000017500000000000012321036667030357 0ustar feanorfeanorfatsort-1.3.365/tests/tc_neg_bad_count_of_root_dir_entries_fat32/directories.txt0000664000175000017500000000000412321036667027474 0ustar feanorfeanordir fatsort-1.3.365/tests/tc_neg_eob_missing/0000775000175000017500000000000012321036670017642 5ustar feanorfeanorfatsort-1.3.365/tests/tc_neg_eob_missing/files.txt0000664000175000017500000000001112321036670021475 0ustar feanorfeanordir/test fatsort-1.3.365/tests/tc_neg_eob_missing/Makefile0000775000175000017500000000362412321036670021312 0ustar feanorfeanorinclude ../testconfig.mk FS_FATType=32 # 100 MiBytes FS_SIZE=100 FS_FATs=2 FS_VOL_NAME=test FS_ROOT_ENTRIES=512 FS_RSVD_SEC=32 FS_SEC_PER_CLUS=1 FS_SEC_SIZE=512 DIRECTORIES=directories.txt FILES=files.txt TESTLOG=test.log STDOUT=stdout.log STDOUT_EXP=stdout_expected.txt STDERR=stderr.log STDERR_EXP=stderr_expected.txt # no fsck in negative tests all: execute if [ ${DEL_FS_ON_PASS} -eq 1 ]; then rm -f ${FS_IMG}; fi clean: rm -fr *.log *.tmp ${FS_IMG} ${TMPFILE} ${TMPDIR} if [ -d ${MOUNT_POINT} ]; then \ until sudo umount ${MOUNT_POINT}; do sleep 1; done; \ rmdir ${MOUNT_POINT}; \ fi # create file system mkfs: # ++++++++++ Creating file ${FATType} system ++++++++++ rm -f ${FS_IMG} truncate -s ${FS_SIZE}MB ${FS_IMG} mkfs.vfat -F ${FS_FATType} -f ${FS_FATs} -n ${FS_VOL_NAME} -r ${FS_ROOT_ENTRIES} -R ${FS_RSVD_SEC} -s ${FS_SEC_PER_CLUS} -S ${FS_SEC_SIZE} ${FS_IMG} # populate fs populatefs: mkfs # ++++++++++ Populating file system with directories and files ++++++++++ mkdir -p ${MOUNT_POINT} sudo mount -o loop,codepage=850,iocharset=iso8859-1,utf8,uid=${MOUNT_UID},gid=${MOUNT_GID} ${FS_IMG} ${MOUNT_POINT} cat ${DIRECTORIES} | while read dir; do mkdir -p "${MOUNT_POINT}/$$dir"; done cat ${FILES} | while read file; do touch "${MOUNT_POINT}/$$file"; done until sudo umount ${MOUNT_POINT}; do sleep 1; done rmdir ${MOUNT_POINT} # alter file system as necessary for the test alterfs: populatefs # ++++++++++ Altering file system ++++++++++ # alter end of boot sector marker ${BBE} -b x1fe:2 -e "r 0 \x00\x00" ${FS_IMG} > ${TMPFILE} cp ${TMPFILE} ${FS_IMG} rm -fr ${TMPFILE} execute: alterfs # ++++++++++ Executing tests ++++++++++ ${FATSORT} ${FS_IMG} > ${STDOUT} 2> ${STDERR}; [ $$? -ne 0 ] diff ${STDOUT} ${STDOUT_EXP} diff ${STDERR} ${STDERR_EXP} # check result fsck: execute # ++++++++++ Checking file system ++++++++++ fsck.vfat -n ${FS_IMG} .PHONY: fsck execute populatefs mkfs clean fatsort-1.3.365/tests/tc_neg_eob_missing/stderr_expected.txt0000664000175000017500000000036712321036670023575 0ustar feanorfeanorcheck_bootsector: End of boot sector marker is missing! read_bootsector: This is not a FAT boot sector or sector is damaged! openFileSystem: Failed to read boot sector! sortFileSystem: Failed to open file system! main: Failed to sort file system! fatsort-1.3.365/tests/tc_neg_eob_missing/stdout_expected.txt0000664000175000017500000000000012321036670023574 0ustar feanorfeanorfatsort-1.3.365/tests/tc_neg_eob_missing/directories.txt0000664000175000017500000000000412321036670022711 0ustar feanorfeanordir fatsort-1.3.365/tests/tc_pos_sort_dir3_fat32/0000775000175000017500000000000012321036667020311 5ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_sort_dir3_fat32/files.txt0000664000175000017500000000064412321036667022160 0ustar feanorfeanorz g u n w e o a c v dir1/z dir1/g dir1/u dir1/n dir1/w dir1/e dir1/o dir1/a dir1/c dir1/v dir2/z dir2/g dir2/u dir2/n dir2/w dir2/e dir2/o dir2/a dir2/c dir2/v dir3/z dir3/g dir3/u dir3/n dir3/w dir3/e dir3/o dir3/a dir3/c dir3/v dir4/z dir4/g dir4/u dir4/n dir4/w dir4/e dir4/o dir4/a dir4/c dir4/v dir4/dir5/z dir4/dir5/g dir4/dir5/u dir4/dir5/n dir4/dir5/w dir4/dir5/e dir4/dir5/o dir4/dir5/a dir4/dir5/c dir4/dir5/v fatsort-1.3.365/tests/tc_pos_sort_dir3_fat32/Makefile0000775000175000017500000000347112321036667021761 0ustar feanorfeanorinclude ../testconfig.mk FS_FATType=32 # MiBytes FS_SIZE=100 FS_FATs=1 FS_VOL_NAME=test FS_ROOT_ENTRIES=512 FS_RSVD_SEC=32 FS_SEC_PER_CLUS=1 FS_SEC_SIZE=512 DIRECTORIES=directories.txt FILES=files.txt TESTLOG=test.log STDOUT=stdout.log STDOUT_EXP=stdout_expected.txt STDERR=stderr.log STDERR_EXP=stderr_expected.txt all: fsck if [ ${DEL_FS_ON_PASS} -eq 1 ]; then rm -f ${FS_IMG}; fi clean: rm -fr *.log *.tmp ${FS_IMG} ${TMPFILE} ${TMPDIR} if [ -d ${MOUNT_POINT} ]; then \ until sudo umount ${MOUNT_POINT}; do sleep 1; done; \ rmdir ${MOUNT_POINT}; \ fi # create file system mkfs: # ++++++++++ Creating file ${FATType} system ++++++++++ rm -f ${FS_IMG} truncate -s ${FS_SIZE}MB ${FS_IMG} mkfs.vfat -F ${FS_FATType} -f ${FS_FATs} -n ${FS_VOL_NAME} -r ${FS_ROOT_ENTRIES} -R ${FS_RSVD_SEC} -s ${FS_SEC_PER_CLUS} -S ${FS_SEC_SIZE} ${FS_IMG} # populate fs populatefs: mkfs # ++++++++++ Populating file system with directories and files ++++++++++ mkdir -p ${MOUNT_POINT} sudo mount -o loop,codepage=850,iocharset=iso8859-1,utf8,uid=${MOUNT_UID},gid=${MOUNT_GID} ${FS_IMG} ${MOUNT_POINT} cat ${DIRECTORIES} | while read dir; do mkdir -p "${MOUNT_POINT}/$$dir"; done cat ${FILES} | while read file; do touch "${MOUNT_POINT}/$$file"; done # delete some files until sudo umount ${MOUNT_POINT}; do sleep 1; done rmdir ${MOUNT_POINT} # alter file system as necessary for the test alterfs: populatefs # ++++++++++ Altering file system ++++++++++ # empty here rm -fr ${TMPFILE} execute: alterfs # ++++++++++ Executing tests ++++++++++ ${FATSORT} -x /dir2 -x /dir4 ${FS_IMG} ${FATSORT} -l ${FS_IMG} > ${STDOUT} 2> ${STDERR} diff ${STDOUT} ${STDOUT_EXP} diff ${STDERR} ${STDERR_EXP} # check result fsck: execute # ++++++++++ Checking file system ++++++++++ fsck.vfat -n ${FS_IMG} .PHONY: fsck execute populatefs mkfs clean fatsort-1.3.365/tests/tc_pos_sort_dir3_fat32/stderr_expected.txt0000664000175000017500000000000012321036667024224 0ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_sort_dir3_fat32/stdout_expected.txt0000664000175000017500000000032612321036667024256 0ustar feanorfeanorFile system: FAT32. / dir1 dir2 dir3 dir4 a c e g n o u v w z /dir1/ a c e g n o u v w z /dir2/ z g u n w e o a c v /dir3/ a c e g n o u v w z /dir4/ dir5 z g u n w e o a c v /dir4/dir5/ a c e g n o u v w z fatsort-1.3.365/tests/tc_pos_sort_dir3_fat32/directories.txt0000664000175000017500000000003112321036667023360 0ustar feanorfeanordir1 dir2 dir3 dir4/dir5 fatsort-1.3.365/tests/tc_pos_sort_order_files_fat16/0000775000175000017500000000000012321036670021741 5ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_sort_order_files_fat16/files.txt0000664000175000017500000000043112321036670023602 0ustar feanorfeanora b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z Ä Ö Ü file3.bin file2.bin file1.bin Long file name with lots of words and characters just to test long file name entries in FAT file systems 1 2 3 4 5 6 7 8 9 10 01b 1a 001c fatsort-1.3.365/tests/tc_pos_sort_order_files_fat16/Makefile0000775000175000017500000000345212321036670023410 0ustar feanorfeanorinclude ../testconfig.mk FS_FATType=16 # MiBytes FS_SIZE=10 FS_FATs=1 FS_VOL_NAME=test FS_ROOT_ENTRIES=512 FS_RSVD_SEC=32 FS_SEC_PER_CLUS=1 FS_SEC_SIZE=512 DIRECTORIES=directories.txt FILES=files.txt TESTLOG=test.log STDOUT=stdout.log STDOUT_EXP=stdout_expected.txt STDERR=stderr.log STDERR_EXP=stderr_expected.txt all: fsck if [ ${DEL_FS_ON_PASS} -eq 1 ]; then rm -f ${FS_IMG}; fi clean: rm -fr *.log *.tmp ${FS_IMG} ${TMPFILE} ${TMPDIR} if [ -d ${MOUNT_POINT} ]; then \ until sudo umount ${MOUNT_POINT}; do sleep 1; done; \ rmdir ${MOUNT_POINT}; \ fi # create file system mkfs: # ++++++++++ Creating file ${FATType} system ++++++++++ rm -f ${FS_IMG} truncate -s ${FS_SIZE}MB ${FS_IMG} mkfs.vfat -F ${FS_FATType} -f ${FS_FATs} -n ${FS_VOL_NAME} -r ${FS_ROOT_ENTRIES} -R ${FS_RSVD_SEC} -s ${FS_SEC_PER_CLUS} -S ${FS_SEC_SIZE} ${FS_IMG} # populate fs populatefs: mkfs # ++++++++++ Populating file system with directories and files ++++++++++ mkdir -p ${MOUNT_POINT} sudo mount -o loop,codepage=850,iocharset=iso8859-1,utf8,uid=${MOUNT_UID},gid=${MOUNT_GID} ${FS_IMG} ${MOUNT_POINT} cat ${DIRECTORIES} | while read dir; do mkdir -p "${MOUNT_POINT}/$$dir"; done cat ${FILES} | while read file; do touch "${MOUNT_POINT}/$$file"; done # delete some files until sudo umount ${MOUNT_POINT}; do sleep 1; done rmdir ${MOUNT_POINT} # alter file system as necessary for the test alterfs: populatefs # ++++++++++ Altering file system ++++++++++ # empty here rm -fr ${TMPFILE} execute: alterfs # ++++++++++ Executing tests ++++++++++ ${FATSORT} -of ${FS_IMG} ${FATSORT} -l ${FS_IMG} > ${STDOUT} 2> ${STDERR} diff ${STDOUT} ${STDOUT_EXP} diff ${STDERR} ${STDERR_EXP} # check result fsck: execute # ++++++++++ Checking file system ++++++++++ fsck.vfat -n ${FS_IMG} .PHONY: fsck execute populatefs mkfs clean fatsort-1.3.365/tests/tc_pos_sort_order_files_fat16/stderr_expected.txt0000664000175000017500000000000012321036670025654 0ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_sort_order_files_fat16/stdout_expected.txt0000664000175000017500000000052212321036670025704 0ustar feanorfeanorFile system: FAT16. / 001c 01b 1 10 1a 2 3 4 5 6 7 8 9 a Ä b c d e f file1.bin file2.bin file3.bin g h i j k l Long file name with lots of words and characters just to test long file name entries in FAT file systems m n o Ö p q r s t u Ü v w x y z dir3 Directory1 directory2 /dir3/ subDir /dir3/subDir/ /Directory1/ /directory2/ fatsort-1.3.365/tests/tc_pos_sort_order_files_fat16/directories.txt0000664000175000017500000000004212321036670025012 0ustar feanorfeanorDirectory1 directory2 dir3/subDir fatsort-1.3.365/tests/tc_pos_one_fat_fat12/0000775000175000017500000000000012321036667020012 5ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_one_fat_fat12/files.txt0000664000175000017500000000043112321036667021653 0ustar feanorfeanora b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z Ä Ö Ü file3.bin file2.bin file1.bin Long file name with lots of words and characters just to test long file name entries in FAT file systems 1 2 3 4 5 6 7 8 9 10 01b 1a 001c fatsort-1.3.365/tests/tc_pos_one_fat_fat12/Makefile0000775000175000017500000000342212321036667021456 0ustar feanorfeanorinclude ../testconfig.mk FS_FATType=12 # MiBytes FS_SIZE=10 FS_FATs=1 FS_VOL_NAME=test FS_ROOT_ENTRIES=512 FS_RSVD_SEC=32 FS_SEC_PER_CLUS=16 FS_SEC_SIZE=512 DIRECTORIES=directories.txt FILES=files.txt TESTLOG=test.log STDOUT=stdout.log STDOUT_EXP=stdout_expected.txt STDERR=stderr.log STDERR_EXP=stderr_expected.txt all: fsck if [ ${DEL_FS_ON_PASS} -eq 1 ]; then rm -f ${FS_IMG}; fi clean: rm -fr *.log *.tmp ${FS_IMG} ${TMPFILE} ${TMPDIR} if [ -d ${MOUNT_POINT} ]; then \ until sudo umount ${MOUNT_POINT}; do sleep 1; done; \ rmdir ${MOUNT_POINT}; \ fi # create file system mkfs: # ++++++++++ Creating file ${FATType} system ++++++++++ rm -f ${FS_IMG} truncate -s ${FS_SIZE}MB ${FS_IMG} mkfs.vfat -F ${FS_FATType} -f ${FS_FATs} -n ${FS_VOL_NAME} -r ${FS_ROOT_ENTRIES} -R ${FS_RSVD_SEC} -s ${FS_SEC_PER_CLUS} -S ${FS_SEC_SIZE} ${FS_IMG} # populate fs populatefs: mkfs # ++++++++++ Populating file system with directories and files ++++++++++ mkdir -p ${MOUNT_POINT} sudo mount -o loop,codepage=850,iocharset=iso8859-1,utf8,uid=${MOUNT_UID},gid=${MOUNT_GID} ${FS_IMG} ${MOUNT_POINT} cat ${DIRECTORIES} | while read dir; do mkdir -p "${MOUNT_POINT}/$$dir"; done cat ${FILES} | while read file; do touch "${MOUNT_POINT}/$$file"; done until sudo umount ${MOUNT_POINT}; do sleep 1; done rmdir ${MOUNT_POINT} # alter file system as necessary for the test alterfs: populatefs # ++++++++++ Altering file system ++++++++++ # empty here rm -fr ${TMPFILE} execute: alterfs # ++++++++++ Executing tests ++++++++++ ${FATSORT} ${FS_IMG} ${FATSORT} -l ${FS_IMG} > ${STDOUT} 2> ${STDERR} diff ${STDOUT} ${STDOUT_EXP} diff ${STDERR} ${STDERR_EXP} # check result fsck: execute # ++++++++++ Checking file system ++++++++++ fsck.vfat -n ${FS_IMG} .PHONY: fsck execute populatefs mkfs clean fatsort-1.3.365/tests/tc_pos_one_fat_fat12/stderr_expected.txt0000664000175000017500000000000012321036667023725 0ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_one_fat_fat12/stdout_expected.txt0000664000175000017500000000052212321036667023755 0ustar feanorfeanorFile system: FAT12. / dir3 Directory1 directory2 001c 01b 1 10 1a 2 3 4 5 6 7 8 9 a Ä b c d e f file1.bin file2.bin file3.bin g h i j k l Long file name with lots of words and characters just to test long file name entries in FAT file systems m n o Ö p q r s t u Ü v w x y z /dir3/ subDir /dir3/subDir/ /Directory1/ /directory2/ fatsort-1.3.365/tests/tc_pos_one_fat_fat12/directories.txt0000664000175000017500000000004212321036667023063 0ustar feanorfeanorDirectory1 directory2 dir3/subDir fatsort-1.3.365/tests/tc_pos_sort_dir4_fat32/0000775000175000017500000000000012321036667020312 5ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_sort_dir4_fat32/files.txt0000664000175000017500000000064412321036667022161 0ustar feanorfeanorz g u n w e o a c v dir1/z dir1/g dir1/u dir1/n dir1/w dir1/e dir1/o dir1/a dir1/c dir1/v dir2/z dir2/g dir2/u dir2/n dir2/w dir2/e dir2/o dir2/a dir2/c dir2/v dir3/z dir3/g dir3/u dir3/n dir3/w dir3/e dir3/o dir3/a dir3/c dir3/v dir4/z dir4/g dir4/u dir4/n dir4/w dir4/e dir4/o dir4/a dir4/c dir4/v dir4/dir5/z dir4/dir5/g dir4/dir5/u dir4/dir5/n dir4/dir5/w dir4/dir5/e dir4/dir5/o dir4/dir5/a dir4/dir5/c dir4/dir5/v fatsort-1.3.365/tests/tc_pos_sort_dir4_fat32/Makefile0000775000175000017500000000346012321036667021760 0ustar feanorfeanorinclude ../testconfig.mk FS_FATType=32 # MiBytes FS_SIZE=100 FS_FATs=1 FS_VOL_NAME=test FS_ROOT_ENTRIES=512 FS_RSVD_SEC=32 FS_SEC_PER_CLUS=1 FS_SEC_SIZE=512 DIRECTORIES=directories.txt FILES=files.txt TESTLOG=test.log STDOUT=stdout.log STDOUT_EXP=stdout_expected.txt STDERR=stderr.log STDERR_EXP=stderr_expected.txt all: fsck if [ ${DEL_FS_ON_PASS} -eq 1 ]; then rm -f ${FS_IMG}; fi clean: rm -fr *.log *.tmp ${FS_IMG} ${TMPFILE} ${TMPDIR} if [ -d ${MOUNT_POINT} ]; then \ until sudo umount ${MOUNT_POINT}; do sleep 1; done; \ rmdir ${MOUNT_POINT}; \ fi # create file system mkfs: # ++++++++++ Creating file ${FATType} system ++++++++++ rm -f ${FS_IMG} truncate -s ${FS_SIZE}MB ${FS_IMG} mkfs.vfat -F ${FS_FATType} -f ${FS_FATs} -n ${FS_VOL_NAME} -r ${FS_ROOT_ENTRIES} -R ${FS_RSVD_SEC} -s ${FS_SEC_PER_CLUS} -S ${FS_SEC_SIZE} ${FS_IMG} # populate fs populatefs: mkfs # ++++++++++ Populating file system with directories and files ++++++++++ mkdir -p ${MOUNT_POINT} sudo mount -o loop,codepage=850,iocharset=iso8859-1,utf8,uid=${MOUNT_UID},gid=${MOUNT_GID} ${FS_IMG} ${MOUNT_POINT} cat ${DIRECTORIES} | while read dir; do mkdir -p "${MOUNT_POINT}/$$dir"; done cat ${FILES} | while read file; do touch "${MOUNT_POINT}/$$file"; done # delete some files until sudo umount ${MOUNT_POINT}; do sleep 1; done rmdir ${MOUNT_POINT} # alter file system as necessary for the test alterfs: populatefs # ++++++++++ Altering file system ++++++++++ # empty here rm -fr ${TMPFILE} execute: alterfs # ++++++++++ Executing tests ++++++++++ ${FATSORT} -X /dir4 ${FS_IMG} ${FATSORT} -l ${FS_IMG} > ${STDOUT} 2> ${STDERR} diff ${STDOUT} ${STDOUT_EXP} diff ${STDERR} ${STDERR_EXP} # check result fsck: execute # ++++++++++ Checking file system ++++++++++ fsck.vfat -n ${FS_IMG} .PHONY: fsck execute populatefs mkfs clean fatsort-1.3.365/tests/tc_pos_sort_dir4_fat32/stderr_expected.txt0000664000175000017500000000000012321036667024225 0ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_sort_dir4_fat32/stdout_expected.txt0000664000175000017500000000032612321036667024257 0ustar feanorfeanorFile system: FAT32. / dir1 dir2 dir3 dir4 a c e g n o u v w z /dir1/ a c e g n o u v w z /dir2/ a c e g n o u v w z /dir3/ a c e g n o u v w z /dir4/ dir5 z g u n w e o a c v /dir4/dir5/ z g u n w e o a c v fatsort-1.3.365/tests/tc_pos_sort_dir4_fat32/directories.txt0000664000175000017500000000003112321036667023361 0ustar feanorfeanordir1 dir2 dir3 dir4/dir5 fatsort-1.3.365/tests/tc_pos_sort_dir1_fat32/0000775000175000017500000000000012321036667020307 5ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_sort_dir1_fat32/files.txt0000664000175000017500000000064412321036667022156 0ustar feanorfeanorz g u n w e o a c v dir1/z dir1/g dir1/u dir1/n dir1/w dir1/e dir1/o dir1/a dir1/c dir1/v dir2/z dir2/g dir2/u dir2/n dir2/w dir2/e dir2/o dir2/a dir2/c dir2/v dir3/z dir3/g dir3/u dir3/n dir3/w dir3/e dir3/o dir3/a dir3/c dir3/v dir4/z dir4/g dir4/u dir4/n dir4/w dir4/e dir4/o dir4/a dir4/c dir4/v dir4/dir5/z dir4/dir5/g dir4/dir5/u dir4/dir5/n dir4/dir5/w dir4/dir5/e dir4/dir5/o dir4/dir5/a dir4/dir5/c dir4/dir5/v fatsort-1.3.365/tests/tc_pos_sort_dir1_fat32/Makefile0000775000175000017500000000347112321036667021757 0ustar feanorfeanorinclude ../testconfig.mk FS_FATType=32 # MiBytes FS_SIZE=100 FS_FATs=1 FS_VOL_NAME=test FS_ROOT_ENTRIES=512 FS_RSVD_SEC=32 FS_SEC_PER_CLUS=1 FS_SEC_SIZE=512 DIRECTORIES=directories.txt FILES=files.txt TESTLOG=test.log STDOUT=stdout.log STDOUT_EXP=stdout_expected.txt STDERR=stderr.log STDERR_EXP=stderr_expected.txt all: fsck if [ ${DEL_FS_ON_PASS} -eq 1 ]; then rm -f ${FS_IMG}; fi clean: rm -fr *.log *.tmp ${FS_IMG} ${TMPFILE} ${TMPDIR} if [ -d ${MOUNT_POINT} ]; then \ until sudo umount ${MOUNT_POINT}; do sleep 1; done; \ rmdir ${MOUNT_POINT}; \ fi # create file system mkfs: # ++++++++++ Creating file ${FATType} system ++++++++++ rm -f ${FS_IMG} truncate -s ${FS_SIZE}MB ${FS_IMG} mkfs.vfat -F ${FS_FATType} -f ${FS_FATs} -n ${FS_VOL_NAME} -r ${FS_ROOT_ENTRIES} -R ${FS_RSVD_SEC} -s ${FS_SEC_PER_CLUS} -S ${FS_SEC_SIZE} ${FS_IMG} # populate fs populatefs: mkfs # ++++++++++ Populating file system with directories and files ++++++++++ mkdir -p ${MOUNT_POINT} sudo mount -o loop,codepage=850,iocharset=iso8859-1,utf8,uid=${MOUNT_UID},gid=${MOUNT_GID} ${FS_IMG} ${MOUNT_POINT} cat ${DIRECTORIES} | while read dir; do mkdir -p "${MOUNT_POINT}/$$dir"; done cat ${FILES} | while read file; do touch "${MOUNT_POINT}/$$file"; done # delete some files until sudo umount ${MOUNT_POINT}; do sleep 1; done rmdir ${MOUNT_POINT} # alter file system as necessary for the test alterfs: populatefs # ++++++++++ Altering file system ++++++++++ # empty here rm -fr ${TMPFILE} execute: alterfs # ++++++++++ Executing tests ++++++++++ ${FATSORT} -d /dir1 -d /dir3 ${FS_IMG} ${FATSORT} -l ${FS_IMG} > ${STDOUT} 2> ${STDERR} diff ${STDOUT} ${STDOUT_EXP} diff ${STDERR} ${STDERR_EXP} # check result fsck: execute # ++++++++++ Checking file system ++++++++++ fsck.vfat -n ${FS_IMG} .PHONY: fsck execute populatefs mkfs clean fatsort-1.3.365/tests/tc_pos_sort_dir1_fat32/stderr_expected.txt0000664000175000017500000000000012321036667024222 0ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_sort_dir1_fat32/stdout_expected.txt0000664000175000017500000000032612321036667024254 0ustar feanorfeanorFile system: FAT32. / dir1 dir2 dir3 dir4 z g u n w e o a c v /dir1/ a c e g n o u v w z /dir2/ z g u n w e o a c v /dir3/ a c e g n o u v w z /dir4/ dir5 z g u n w e o a c v /dir4/dir5/ z g u n w e o a c v fatsort-1.3.365/tests/tc_pos_sort_dir1_fat32/directories.txt0000664000175000017500000000003112321036667023356 0ustar feanorfeanordir1 dir2 dir3 dir4/dir5 fatsort-1.3.365/tests/tc_neg_missing_sne_in_root_dir_fat16/0000775000175000017500000000000012321036667023260 5ustar feanorfeanorfatsort-1.3.365/tests/tc_neg_missing_sne_in_root_dir_fat16/files.txt0000664000175000017500000000012412321036667025120 0ustar feanorfeanorlong_filename___________________________1 long_filename___________________________2 fatsort-1.3.365/tests/tc_neg_missing_sne_in_root_dir_fat16/Makefile0000775000175000017500000000413212321036667024723 0ustar feanorfeanorinclude ../testconfig.mk FS_FATType=16 # MiBytes FS_SIZE=10 FS_FATs=2 FS_VOL_NAME=test FS_ROOT_ENTRIES=512 FS_RSVD_SEC=32 FS_SEC_PER_CLUS=1 FS_SEC_SIZE=512 DIRECTORIES=directories.txt FILES=files.txt TESTLOG=test.log STDOUT=stdout.log STDOUT_EXP=stdout_expected.txt STDERR=stderr.log STDERR_EXP=stderr_expected.txt # no fsck in negative tests all: execute if [ ${DEL_FS_ON_PASS} -eq 1 ]; then rm -f ${FS_IMG}; fi clean: rm -fr *.log *.tmp ${FS_IMG} ${TMPFILE} ${TMPDIR} if [ -d ${MOUNT_POINT} ]; then \ until sudo umount ${MOUNT_POINT}; do sleep 1; done; \ rmdir ${MOUNT_POINT}; \ fi # create file system mkfs: # ++++++++++ Creating file ${FATType} system ++++++++++ rm -f ${FS_IMG} truncate -s ${FS_SIZE}MB ${FS_IMG} mkfs.vfat -F ${FS_FATType} -f ${FS_FATs} -n ${FS_VOL_NAME} -r ${FS_ROOT_ENTRIES} -R ${FS_RSVD_SEC} -s ${FS_SEC_PER_CLUS} -S ${FS_SEC_SIZE} ${FS_IMG} # populate fs populatefs: mkfs # ++++++++++ Populating file system with directories and files ++++++++++ mkdir -p ${MOUNT_POINT} sudo mount -o loop,codepage=850,iocharset=iso8859-1,utf8,uid=${MOUNT_UID},gid=${MOUNT_GID} ${FS_IMG} ${MOUNT_POINT} cat ${DIRECTORIES} | while read dir; do mkdir -p "${MOUNT_POINT}/$$dir"; done cat ${FILES} | while read file; do touch "${MOUNT_POINT}/$$file"; done rm -f "${MOUNT_POINT}/a" #remove some files rm -f "${MOUNT_POINT}/n" rm -f "${MOUNT_POINT}/z" until sudo umount ${MOUNT_POINT}; do sleep 1; done rmdir ${MOUNT_POINT} # alter file system as necessary for the test alterfs: populatefs # ++++++++++ Altering file system ++++++++++ # remove sne ${BBE} -b x17140:32 -e "r 0 \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" ${FS_IMG} > ${TMPFILE} cp -f ${TMPFILE} ${FS_IMG} rm -fr ${TMPFILE} execute: alterfs # ++++++++++ Executing tests ++++++++++ ${FATSORT} ${FS_IMG} > ${STDOUT} 2> ${STDERR}; [ $$? -ne 0 ] diff ${STDOUT} ${STDOUT_EXP} diff ${STDERR} ${STDERR_EXP} # check result fsck: execute # ++++++++++ Checking file system ++++++++++ fsck.vfat -n ${FS_IMG} .PHONY: fsck execute populatefs mkfs clean fatsort-1.3.365/tests/tc_neg_missing_sne_in_root_dir_fat16/stderr_expected.txt0000664000175000017500000000037212321036667027207 0ustar feanorfeanorparseFAT1xRootDirEntries: ShortDirEntry is missing after LongDirEntries (root directory entry 10)! sortFAT1xRootDirectory: Failed to parse root directory entries! sortFileSystem: Failed to sort FAT16 root directory! main: Failed to sort file system! fatsort-1.3.365/tests/tc_neg_missing_sne_in_root_dir_fat16/stdout_expected.txt0000664000175000017500000000005112321036667027220 0ustar feanorfeanorFile system: FAT16. Sorting directory / fatsort-1.3.365/tests/tc_neg_missing_sne_in_root_dir_fat16/directories.txt0000664000175000017500000000000012321036667026323 0ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_sort_dir5_fat12/0000775000175000017500000000000012321036667020311 5ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_sort_dir5_fat12/files.txt0000664000175000017500000000064412321036667022160 0ustar feanorfeanorz g u n w e o a c v dir1/z dir1/g dir1/u dir1/n dir1/w dir1/e dir1/o dir1/a dir1/c dir1/v dir2/z dir2/g dir2/u dir2/n dir2/w dir2/e dir2/o dir2/a dir2/c dir2/v dir3/z dir3/g dir3/u dir3/n dir3/w dir3/e dir3/o dir3/a dir3/c dir3/v dir4/z dir4/g dir4/u dir4/n dir4/w dir4/e dir4/o dir4/a dir4/c dir4/v dir4/dir5/z dir4/dir5/g dir4/dir5/u dir4/dir5/n dir4/dir5/w dir4/dir5/e dir4/dir5/o dir4/dir5/a dir4/dir5/c dir4/dir5/v fatsort-1.3.365/tests/tc_pos_sort_dir5_fat12/Makefile0000775000175000017500000000347412321036667021764 0ustar feanorfeanorinclude ../testconfig.mk FS_FATType=12 # MiBytes FS_SIZE=10 FS_FATs=1 FS_VOL_NAME=test FS_ROOT_ENTRIES=512 FS_RSVD_SEC=32 FS_SEC_PER_CLUS=16 FS_SEC_SIZE=512 DIRECTORIES=directories.txt FILES=files.txt TESTLOG=test.log STDOUT=stdout.log STDOUT_EXP=stdout_expected.txt STDERR=stderr.log STDERR_EXP=stderr_expected.txt all: fsck if [ ${DEL_FS_ON_PASS} -eq 1 ]; then rm -f ${FS_IMG}; fi clean: rm -fr *.log *.tmp ${FS_IMG} ${TMPFILE} ${TMPDIR} if [ -d ${MOUNT_POINT} ]; then \ until sudo umount ${MOUNT_POINT}; do sleep 1; done; \ rmdir ${MOUNT_POINT}; \ fi # create file system mkfs: # ++++++++++ Creating file ${FATType} system ++++++++++ rm -f ${FS_IMG} truncate -s ${FS_SIZE}MB ${FS_IMG} mkfs.vfat -F ${FS_FATType} -f ${FS_FATs} -n ${FS_VOL_NAME} -r ${FS_ROOT_ENTRIES} -R ${FS_RSVD_SEC} -s ${FS_SEC_PER_CLUS} -S ${FS_SEC_SIZE} ${FS_IMG} # populate fs populatefs: mkfs # ++++++++++ Populating file system with directories and files ++++++++++ mkdir -p ${MOUNT_POINT} sudo mount -o loop,codepage=850,iocharset=iso8859-1,utf8,uid=${MOUNT_UID},gid=${MOUNT_GID} ${FS_IMG} ${MOUNT_POINT} cat ${DIRECTORIES} | while read dir; do mkdir -p "${MOUNT_POINT}/$$dir"; done cat ${FILES} | while read file; do touch "${MOUNT_POINT}/$$file"; done # delete some files until sudo umount ${MOUNT_POINT}; do sleep 1; done rmdir ${MOUNT_POINT} # alter file system as necessary for the test alterfs: populatefs # ++++++++++ Altering file system ++++++++++ # empty here rm -fr ${TMPFILE} execute: alterfs # ++++++++++ Executing tests ++++++++++ ${FATSORT} -D dir4 -x dir4/dir5 ${FS_IMG} ${FATSORT} -l ${FS_IMG} > ${STDOUT} 2> ${STDERR} diff ${STDOUT} ${STDOUT_EXP} diff ${STDERR} ${STDERR_EXP} # check result fsck: execute # ++++++++++ Checking file system ++++++++++ fsck.vfat -n ${FS_IMG} .PHONY: fsck execute populatefs mkfs clean fatsort-1.3.365/tests/tc_pos_sort_dir5_fat12/stderr_expected.txt0000664000175000017500000000000012321036667024224 0ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_sort_dir5_fat12/stdout_expected.txt0000664000175000017500000000032612321036667024256 0ustar feanorfeanorFile system: FAT12. / dir1 dir2 dir3 dir4 z g u n w e o a c v /dir1/ z g u n w e o a c v /dir2/ z g u n w e o a c v /dir3/ z g u n w e o a c v /dir4/ dir5 a c e g n o u v w z /dir4/dir5/ z g u n w e o a c v fatsort-1.3.365/tests/tc_pos_sort_dir5_fat12/directories.txt0000664000175000017500000000003112321036667023360 0ustar feanorfeanordir1 dir2 dir3 dir4/dir5 fatsort-1.3.365/tests/tc_check_for_open_TODOs/0000775000175000017500000000000012321036667020475 5ustar feanorfeanorfatsort-1.3.365/tests/tc_check_for_open_TODOs/Makefile0000664000175000017500000000013012321036667022127 0ustar feanorfeanorinclude ../testconfig.mk all: ! grep "TODO" ../../src/*.[hc] clean: .PHONY: clean fatsort-1.3.365/tests/tc_pos_three_fats_fat12/0000775000175000017500000000000012321036667020523 5ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_three_fats_fat12/files.txt0000664000175000017500000000043112321036667022364 0ustar feanorfeanora b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z Ä Ö Ü file3.bin file2.bin file1.bin Long file name with lots of words and characters just to test long file name entries in FAT file systems 1 2 3 4 5 6 7 8 9 10 01b 1a 001c fatsort-1.3.365/tests/tc_pos_three_fats_fat12/Makefile0000775000175000017500000000342312321036667022170 0ustar feanorfeanorinclude ../testconfig.mk FS_FATType=12 # MiBytes FS_SIZE=10 FS_FATs=3 FS_VOL_NAME=test FS_ROOT_ENTRIES=512 FS_RSVD_SEC=32 FS_SEC_PER_CLUS=16 FS_SEC_SIZE=512 DIRECTORIES=directories.txt FILES=files.txt TESTLOG=test.log STDOUT=stdout.log STDOUT_EXP=stdout_expected.txt STDERR=stderr.log STDERR_EXP=stderr_expected.txt all: fsck if [ ${DEL_FS_ON_PASS} -eq 1 ]; then rm -f ${FS_IMG}; fi clean: rm -fr *.log *.tmp ${FS_IMG} ${TMPFILE} ${TMPDIR} if [ -d ${MOUNT_POINT} ]; then \ until sudo umount ${MOUNT_POINT}; do sleep 1; done; \ rmdir ${MOUNT_POINT}; \ fi # create file system mkfs: # ++++++++++ Creating file ${FATType} system ++++++++++ rm -f ${FS_IMG} truncate -s ${FS_SIZE}MB ${FS_IMG} mkfs.vfat -F ${FS_FATType} -f ${FS_FATs} -n ${FS_VOL_NAME} -r ${FS_ROOT_ENTRIES} -R ${FS_RSVD_SEC} -s ${FS_SEC_PER_CLUS} -S ${FS_SEC_SIZE} ${FS_IMG} # populate fs populatefs: mkfs # ++++++++++ Populating file system with directories and files ++++++++++ mkdir -p ${MOUNT_POINT} sudo mount -o loop,codepage=850,iocharset=iso8859-1,utf8,uid=${MOUNT_UID},gid=${MOUNT_GID} ${FS_IMG} ${MOUNT_POINT} cat ${DIRECTORIES} | while read dir; do mkdir -p "${MOUNT_POINT}/$$dir"; done cat ${FILES} | while read file; do touch "${MOUNT_POINT}/$$file"; done until sudo umount ${MOUNT_POINT}; do sleep 1; done rmdir ${MOUNT_POINT} # alter file system as necessary for the test alterfs: populatefs # ++++++++++ Altering file system ++++++++++ # empty here rm -fr ${TMPFILE} execute: alterfs # ++++++++++ Executing tests ++++++++++ ${FATSORT} ${FS_IMG} ${FATSORT} -l ${FS_IMG} > ${STDOUT} 2> ${STDERR} diff ${STDOUT} ${STDOUT_EXP} diff ${STDERR} ${STDERR_EXP} # check result fsck: execute # ++++++++++ Checking file system ++++++++++ #fsck.vfat -n ${FS_IMG} .PHONY: fsck execute populatefs mkfs clean fatsort-1.3.365/tests/tc_pos_three_fats_fat12/stderr_expected.txt0000664000175000017500000000000012321036667024436 0ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_three_fats_fat12/stdout_expected.txt0000664000175000017500000000052212321036667024466 0ustar feanorfeanorFile system: FAT12. / dir3 Directory1 directory2 001c 01b 1 10 1a 2 3 4 5 6 7 8 9 a Ä b c d e f file1.bin file2.bin file3.bin g h i j k l Long file name with lots of words and characters just to test long file name entries in FAT file systems m n o Ö p q r s t u Ü v w x y z /dir3/ subDir /dir3/subDir/ /Directory1/ /directory2/ fatsort-1.3.365/tests/tc_pos_three_fats_fat12/directories.txt0000664000175000017500000000004212321036667023574 0ustar feanorfeanorDirectory1 directory2 dir3/subDir fatsort-1.3.365/tests/tc_neg_missing_last_lne_in_root_dir_fat32/0000775000175000017500000000000012321036667024272 5ustar feanorfeanorfatsort-1.3.365/tests/tc_neg_missing_last_lne_in_root_dir_fat32/files.txt0000664000175000017500000000012412321036667026132 0ustar feanorfeanorlong_filename___________________________1 long_filename___________________________2 fatsort-1.3.365/tests/tc_neg_missing_last_lne_in_root_dir_fat32/Makefile0000775000175000017500000000375412321036667025746 0ustar feanorfeanorinclude ../testconfig.mk FS_FATType=32 # 100 MiBytes FS_SIZE=100 FS_FATs=2 FS_VOL_NAME=test FS_ROOT_ENTRIES=512 FS_RSVD_SEC=32 FS_SEC_PER_CLUS=1 FS_SEC_SIZE=512 DIRECTORIES=directories.txt FILES=files.txt TESTLOG=test.log STDOUT=stdout.log STDOUT_EXP=stdout_expected.txt STDERR=stderr.log STDERR_EXP=stderr_expected.txt # no fsck in negative tests all: execute if [ ${DEL_FS_ON_PASS} -eq 1 ]; then rm -f ${FS_IMG}; fi clean: rm -fr *.log *.tmp ${FS_IMG} ${TMPFILE} ${TMPDIR} if [ -d ${MOUNT_POINT} ]; then \ until sudo umount ${MOUNT_POINT}; do sleep 1; done; \ rmdir ${MOUNT_POINT}; \ fi # create file system mkfs: # ++++++++++ Creating file ${FATType} system ++++++++++ rm -f ${FS_IMG} truncate -s ${FS_SIZE}MB ${FS_IMG} mkfs.vfat -F ${FS_FATType} -f ${FS_FATs} -n ${FS_VOL_NAME} -r ${FS_ROOT_ENTRIES} -R ${FS_RSVD_SEC} -s ${FS_SEC_PER_CLUS} -S ${FS_SEC_SIZE} ${FS_IMG} # populate fs populatefs: mkfs # ++++++++++ Populating file system with directories and files ++++++++++ mkdir -p ${MOUNT_POINT} sudo mount -o loop,codepage=850,iocharset=iso8859-1,utf8,uid=${MOUNT_UID},gid=${MOUNT_GID} ${FS_IMG} ${MOUNT_POINT} cat ${DIRECTORIES} | while read dir; do mkdir -p "${MOUNT_POINT}/$$dir"; done cat ${FILES} | while read file; do touch "${MOUNT_POINT}/$$file"; done rm -f "${MOUNT_POINT}/a" #remove some files rm -f "${MOUNT_POINT}/n" rm -f "${MOUNT_POINT}/z" until sudo umount ${MOUNT_POINT}; do sleep 1; done rmdir ${MOUNT_POINT} # alter file system as necessary for the test alterfs: populatefs # ++++++++++ Altering file system ++++++++++ # change last lde ord ${BBE} -b x17bc20:1 -e "r 0 \x04" ${FS_IMG} > ${TMPFILE} cp -f ${TMPFILE} ${FS_IMG} rm -fr ${TMPFILE} execute: alterfs # ++++++++++ Executing tests ++++++++++ ${FATSORT} ${FS_IMG} > ${STDOUT} 2> ${STDERR}; [ $$? -ne 0 ] diff ${STDOUT} ${STDOUT_EXP} diff ${STDERR} ${STDERR_EXP} # check result fsck: execute # ++++++++++ Checking file system ++++++++++ fsck.vfat -n ${FS_IMG} .PHONY: fsck execute populatefs mkfs clean fatsort-1.3.365/tests/tc_neg_missing_last_lne_in_root_dir_fat32/stderr_expected.txt0000664000175000017500000000044412321036667030221 0ustar feanorfeanorcheckLongDirEntries: LongDirEntry should be marked as last long dir entry but isn't! parseClusterChain: checkDirEntry failed in cluster 00000002 at entry 5! sortClusterChain: Failed to parse cluster chain! sortFileSystem: Failed to sort first cluster chain! main: Failed to sort file system! fatsort-1.3.365/tests/tc_neg_missing_last_lne_in_root_dir_fat32/stdout_expected.txt0000664000175000017500000000005112321036667030232 0ustar feanorfeanorFile system: FAT32. Sorting directory / fatsort-1.3.365/tests/tc_neg_missing_last_lne_in_root_dir_fat32/directories.txt0000664000175000017500000000000012321036667027335 0ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_sort_dir5_fat16/0000775000175000017500000000000012321036667020315 5ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_sort_dir5_fat16/files.txt0000664000175000017500000000064412321036667022164 0ustar feanorfeanorz g u n w e o a c v dir1/z dir1/g dir1/u dir1/n dir1/w dir1/e dir1/o dir1/a dir1/c dir1/v dir2/z dir2/g dir2/u dir2/n dir2/w dir2/e dir2/o dir2/a dir2/c dir2/v dir3/z dir3/g dir3/u dir3/n dir3/w dir3/e dir3/o dir3/a dir3/c dir3/v dir4/z dir4/g dir4/u dir4/n dir4/w dir4/e dir4/o dir4/a dir4/c dir4/v dir4/dir5/z dir4/dir5/g dir4/dir5/u dir4/dir5/n dir4/dir5/w dir4/dir5/e dir4/dir5/o dir4/dir5/a dir4/dir5/c dir4/dir5/v fatsort-1.3.365/tests/tc_pos_sort_dir5_fat16/Makefile0000775000175000017500000000347312321036667021767 0ustar feanorfeanorinclude ../testconfig.mk FS_FATType=16 # MiBytes FS_SIZE=10 FS_FATs=1 FS_VOL_NAME=test FS_ROOT_ENTRIES=512 FS_RSVD_SEC=32 FS_SEC_PER_CLUS=1 FS_SEC_SIZE=512 DIRECTORIES=directories.txt FILES=files.txt TESTLOG=test.log STDOUT=stdout.log STDOUT_EXP=stdout_expected.txt STDERR=stderr.log STDERR_EXP=stderr_expected.txt all: fsck if [ ${DEL_FS_ON_PASS} -eq 1 ]; then rm -f ${FS_IMG}; fi clean: rm -fr *.log *.tmp ${FS_IMG} ${TMPFILE} ${TMPDIR} if [ -d ${MOUNT_POINT} ]; then \ until sudo umount ${MOUNT_POINT}; do sleep 1; done; \ rmdir ${MOUNT_POINT}; \ fi # create file system mkfs: # ++++++++++ Creating file ${FATType} system ++++++++++ rm -f ${FS_IMG} truncate -s ${FS_SIZE}MB ${FS_IMG} mkfs.vfat -F ${FS_FATType} -f ${FS_FATs} -n ${FS_VOL_NAME} -r ${FS_ROOT_ENTRIES} -R ${FS_RSVD_SEC} -s ${FS_SEC_PER_CLUS} -S ${FS_SEC_SIZE} ${FS_IMG} # populate fs populatefs: mkfs # ++++++++++ Populating file system with directories and files ++++++++++ mkdir -p ${MOUNT_POINT} sudo mount -o loop,codepage=850,iocharset=iso8859-1,utf8,uid=${MOUNT_UID},gid=${MOUNT_GID} ${FS_IMG} ${MOUNT_POINT} cat ${DIRECTORIES} | while read dir; do mkdir -p "${MOUNT_POINT}/$$dir"; done cat ${FILES} | while read file; do touch "${MOUNT_POINT}/$$file"; done # delete some files until sudo umount ${MOUNT_POINT}; do sleep 1; done rmdir ${MOUNT_POINT} # alter file system as necessary for the test alterfs: populatefs # ++++++++++ Altering file system ++++++++++ # empty here rm -fr ${TMPFILE} execute: alterfs # ++++++++++ Executing tests ++++++++++ ${FATSORT} -D dir4 -x dir4/dir5 ${FS_IMG} ${FATSORT} -l ${FS_IMG} > ${STDOUT} 2> ${STDERR} diff ${STDOUT} ${STDOUT_EXP} diff ${STDERR} ${STDERR_EXP} # check result fsck: execute # ++++++++++ Checking file system ++++++++++ fsck.vfat -n ${FS_IMG} .PHONY: fsck execute populatefs mkfs clean fatsort-1.3.365/tests/tc_pos_sort_dir5_fat16/stderr_expected.txt0000664000175000017500000000000012321036667024230 0ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_sort_dir5_fat16/stdout_expected.txt0000664000175000017500000000032612321036667024262 0ustar feanorfeanorFile system: FAT16. / dir1 dir2 dir3 dir4 z g u n w e o a c v /dir1/ z g u n w e o a c v /dir2/ z g u n w e o a c v /dir3/ z g u n w e o a c v /dir4/ dir5 a c e g n o u v w z /dir4/dir5/ z g u n w e o a c v fatsort-1.3.365/tests/tc_pos_sort_dir5_fat16/directories.txt0000664000175000017500000000003112321036667023364 0ustar feanorfeanordir1 dir2 dir3 dir4/dir5 fatsort-1.3.365/tests/tc_neg_bad_fat_size_fat16/0000775000175000017500000000000012321036667020765 5ustar feanorfeanorfatsort-1.3.365/tests/tc_neg_bad_fat_size_fat16/files.txt0000664000175000017500000000001112321036667022620 0ustar feanorfeanordir/test fatsort-1.3.365/tests/tc_neg_bad_fat_size_fat16/tc_neg_bad_fat_size_fat12/0000775000175000017500000000000012321036667025713 5ustar feanorfeanorfatsort-1.3.365/tests/tc_neg_bad_fat_size_fat16/tc_neg_bad_fat_size_fat12/files.txt0000664000175000017500000000001112321036667027546 0ustar feanorfeanordir/test fatsort-1.3.365/tests/tc_neg_bad_fat_size_fat16/Makefile0000775000175000017500000000400212321036667022424 0ustar feanorfeanorinclude ../testconfig.mk FS_FATType=16 # 100 MiBytes FS_SIZE=10 FS_FATs=2 FS_VOL_NAME=test FS_ROOT_ENTRIES=512 FS_RSVD_SEC=32 FS_SEC_PER_CLUS=1 FS_SEC_SIZE=512 DIRECTORIES=directories.txt FILES=files.txt TESTLOG=test.log STDOUT=stdout.log STDOUT_EXP=stdout_expected.txt STDERR=stderr.log STDERR_EXP=stderr_expected.txt # no fsck in negative tests all: execute if [ ${DEL_FS_ON_PASS} -eq 1 ]; then rm -f ${FS_IMG}; fi clean: rm -fr *.log *.tmp ${FS_IMG} ${TMPFILE} ${TMPDIR} if [ -d ${MOUNT_POINT} ]; then \ until sudo umount ${MOUNT_POINT}; do sleep 1; done; \ rmdir ${MOUNT_POINT}; \ fi # create file system mkfs: # ++++++++++ Creating file ${FATType} system ++++++++++ rm -f ${FS_IMG} truncate -s ${FS_SIZE}MB ${FS_IMG} mkfs.vfat -F ${FS_FATType} -f ${FS_FATs} -n ${FS_VOL_NAME} -r ${FS_ROOT_ENTRIES} -R ${FS_RSVD_SEC} -s ${FS_SEC_PER_CLUS} -S ${FS_SEC_SIZE} ${FS_IMG} # populate fs populatefs: mkfs # ++++++++++ Populating file system with directories and files ++++++++++ mkdir -p ${MOUNT_POINT} sudo mount -o loop,codepage=850,iocharset=iso8859-1,utf8,uid=${MOUNT_UID},gid=${MOUNT_GID} ${FS_IMG} ${MOUNT_POINT} cat ${DIRECTORIES} | while read dir; do mkdir -p "${MOUNT_POINT}/$$dir"; done cat ${FILES} | while read file; do touch "${MOUNT_POINT}/$$file"; done until sudo umount ${MOUNT_POINT}; do sleep 1; done rmdir ${MOUNT_POINT} # alter file system as necessary for the test alterfs: populatefs # ++++++++++ Altering file system ++++++++++ # set 16-bit count of fat sectors to zero (bad for FAT1x) ${BBE} -b x16:2 -e "r 0 \x00\x00" ${FS_IMG} > ${TMPFILE} # necessary to fake a large amout of clusters ${BBE} -b x24:4 -e "r 0 \x00\xff\xff\xff" ${TMPFILE} > ${FS_IMG} rm -fr ${TMPFILE} execute: alterfs # ++++++++++ Executing tests ++++++++++ ${FATSORT} ${FS_IMG} > ${STDOUT} 2> ${STDERR}; [ $$? -ne 0 ] diff ${STDOUT} ${STDOUT_EXP} diff ${STDERR} ${STDERR_EXP} # check result fsck: execute # ++++++++++ Checking file system ++++++++++ fsck.vfat -n ${FS_IMG} .PHONY: fsck execute populatefs mkfs clean fatsort-1.3.365/tests/tc_neg_bad_fat_size_fat16/stderr_expected.txt0000664000175000017500000000022612321036667024712 0ustar feanorfeanoropenFileSystem: 16-bit count of FAT sectors must not be zero for FAT1x! sortFileSystem: Failed to open file system! main: Failed to sort file system! fatsort-1.3.365/tests/tc_neg_bad_fat_size_fat16/stdout_expected.txt0000664000175000017500000000000012321036667024717 0ustar feanorfeanorfatsort-1.3.365/tests/tc_neg_bad_fat_size_fat16/directories.txt0000664000175000017500000000000412321036667024034 0ustar feanorfeanordir fatsort-1.3.365/tests/tc_pos_sort_dir3_fat12/0000775000175000017500000000000012321036667020307 5ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_sort_dir3_fat12/files.txt0000664000175000017500000000064412321036667022156 0ustar feanorfeanorz g u n w e o a c v dir1/z dir1/g dir1/u dir1/n dir1/w dir1/e dir1/o dir1/a dir1/c dir1/v dir2/z dir2/g dir2/u dir2/n dir2/w dir2/e dir2/o dir2/a dir2/c dir2/v dir3/z dir3/g dir3/u dir3/n dir3/w dir3/e dir3/o dir3/a dir3/c dir3/v dir4/z dir4/g dir4/u dir4/n dir4/w dir4/e dir4/o dir4/a dir4/c dir4/v dir4/dir5/z dir4/dir5/g dir4/dir5/u dir4/dir5/n dir4/dir5/w dir4/dir5/e dir4/dir5/o dir4/dir5/a dir4/dir5/c dir4/dir5/v fatsort-1.3.365/tests/tc_pos_sort_dir3_fat12/Makefile0000775000175000017500000000347112321036667021757 0ustar feanorfeanorinclude ../testconfig.mk FS_FATType=12 # MiBytes FS_SIZE=10 FS_FATs=1 FS_VOL_NAME=test FS_ROOT_ENTRIES=512 FS_RSVD_SEC=32 FS_SEC_PER_CLUS=16 FS_SEC_SIZE=512 DIRECTORIES=directories.txt FILES=files.txt TESTLOG=test.log STDOUT=stdout.log STDOUT_EXP=stdout_expected.txt STDERR=stderr.log STDERR_EXP=stderr_expected.txt all: fsck if [ ${DEL_FS_ON_PASS} -eq 1 ]; then rm -f ${FS_IMG}; fi clean: rm -fr *.log *.tmp ${FS_IMG} ${TMPFILE} ${TMPDIR} if [ -d ${MOUNT_POINT} ]; then \ until sudo umount ${MOUNT_POINT}; do sleep 1; done; \ rmdir ${MOUNT_POINT}; \ fi # create file system mkfs: # ++++++++++ Creating file ${FATType} system ++++++++++ rm -f ${FS_IMG} truncate -s ${FS_SIZE}MB ${FS_IMG} mkfs.vfat -F ${FS_FATType} -f ${FS_FATs} -n ${FS_VOL_NAME} -r ${FS_ROOT_ENTRIES} -R ${FS_RSVD_SEC} -s ${FS_SEC_PER_CLUS} -S ${FS_SEC_SIZE} ${FS_IMG} # populate fs populatefs: mkfs # ++++++++++ Populating file system with directories and files ++++++++++ mkdir -p ${MOUNT_POINT} sudo mount -o loop,codepage=850,iocharset=iso8859-1,utf8,uid=${MOUNT_UID},gid=${MOUNT_GID} ${FS_IMG} ${MOUNT_POINT} cat ${DIRECTORIES} | while read dir; do mkdir -p "${MOUNT_POINT}/$$dir"; done cat ${FILES} | while read file; do touch "${MOUNT_POINT}/$$file"; done # delete some files until sudo umount ${MOUNT_POINT}; do sleep 1; done rmdir ${MOUNT_POINT} # alter file system as necessary for the test alterfs: populatefs # ++++++++++ Altering file system ++++++++++ # empty here rm -fr ${TMPFILE} execute: alterfs # ++++++++++ Executing tests ++++++++++ ${FATSORT} -x /dir2 -x /dir4 ${FS_IMG} ${FATSORT} -l ${FS_IMG} > ${STDOUT} 2> ${STDERR} diff ${STDOUT} ${STDOUT_EXP} diff ${STDERR} ${STDERR_EXP} # check result fsck: execute # ++++++++++ Checking file system ++++++++++ fsck.vfat -n ${FS_IMG} .PHONY: fsck execute populatefs mkfs clean fatsort-1.3.365/tests/tc_pos_sort_dir3_fat12/stderr_expected.txt0000664000175000017500000000000012321036667024222 0ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_sort_dir3_fat12/stdout_expected.txt0000664000175000017500000000032612321036667024254 0ustar feanorfeanorFile system: FAT12. / dir1 dir2 dir3 dir4 a c e g n o u v w z /dir1/ a c e g n o u v w z /dir2/ z g u n w e o a c v /dir3/ a c e g n o u v w z /dir4/ dir5 z g u n w e o a c v /dir4/dir5/ a c e g n o u v w z fatsort-1.3.365/tests/tc_pos_sort_dir3_fat12/directories.txt0000664000175000017500000000003112321036667023356 0ustar feanorfeanordir1 dir2 dir3 dir4/dir5 fatsort-1.3.365/tests/tc_pos_one_fat_fat16/0000775000175000017500000000000012321036667020016 5ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_one_fat_fat16/files.txt0000664000175000017500000000043112321036667021657 0ustar feanorfeanora b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z Ä Ö Ü file3.bin file2.bin file1.bin Long file name with lots of words and characters just to test long file name entries in FAT file systems 1 2 3 4 5 6 7 8 9 10 01b 1a 001c fatsort-1.3.365/tests/tc_pos_one_fat_fat16/Makefile0000775000175000017500000000342112321036667021461 0ustar feanorfeanorinclude ../testconfig.mk FS_FATType=16 # MiBytes FS_SIZE=10 FS_FATs=1 FS_VOL_NAME=test FS_ROOT_ENTRIES=512 FS_RSVD_SEC=32 FS_SEC_PER_CLUS=1 FS_SEC_SIZE=512 DIRECTORIES=directories.txt FILES=files.txt TESTLOG=test.log STDOUT=stdout.log STDOUT_EXP=stdout_expected.txt STDERR=stderr.log STDERR_EXP=stderr_expected.txt all: fsck if [ ${DEL_FS_ON_PASS} -eq 1 ]; then rm -f ${FS_IMG}; fi clean: rm -fr *.log *.tmp ${FS_IMG} ${TMPFILE} ${TMPDIR} if [ -d ${MOUNT_POINT} ]; then \ until sudo umount ${MOUNT_POINT}; do sleep 1; done; \ rmdir ${MOUNT_POINT}; \ fi # create file system mkfs: # ++++++++++ Creating file ${FATType} system ++++++++++ rm -f ${FS_IMG} truncate -s ${FS_SIZE}MB ${FS_IMG} mkfs.vfat -F ${FS_FATType} -f ${FS_FATs} -n ${FS_VOL_NAME} -r ${FS_ROOT_ENTRIES} -R ${FS_RSVD_SEC} -s ${FS_SEC_PER_CLUS} -S ${FS_SEC_SIZE} ${FS_IMG} # populate fs populatefs: mkfs # ++++++++++ Populating file system with directories and files ++++++++++ mkdir -p ${MOUNT_POINT} sudo mount -o loop,codepage=850,iocharset=iso8859-1,utf8,uid=${MOUNT_UID},gid=${MOUNT_GID} ${FS_IMG} ${MOUNT_POINT} cat ${DIRECTORIES} | while read dir; do mkdir -p "${MOUNT_POINT}/$$dir"; done cat ${FILES} | while read file; do touch "${MOUNT_POINT}/$$file"; done until sudo umount ${MOUNT_POINT}; do sleep 1; done rmdir ${MOUNT_POINT} # alter file system as necessary for the test alterfs: populatefs # ++++++++++ Altering file system ++++++++++ # empty here rm -fr ${TMPFILE} execute: alterfs # ++++++++++ Executing tests ++++++++++ ${FATSORT} ${FS_IMG} ${FATSORT} -l ${FS_IMG} > ${STDOUT} 2> ${STDERR} diff ${STDOUT} ${STDOUT_EXP} diff ${STDERR} ${STDERR_EXP} # check result fsck: execute # ++++++++++ Checking file system ++++++++++ fsck.vfat -n ${FS_IMG} .PHONY: fsck execute populatefs mkfs clean fatsort-1.3.365/tests/tc_pos_one_fat_fat16/stderr_expected.txt0000664000175000017500000000000012321036667023731 0ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_one_fat_fat16/stdout_expected.txt0000664000175000017500000000052212321036667023761 0ustar feanorfeanorFile system: FAT16. / dir3 Directory1 directory2 001c 01b 1 10 1a 2 3 4 5 6 7 8 9 a Ä b c d e f file1.bin file2.bin file3.bin g h i j k l Long file name with lots of words and characters just to test long file name entries in FAT file systems m n o Ö p q r s t u Ü v w x y z /dir3/ subDir /dir3/subDir/ /Directory1/ /directory2/ fatsort-1.3.365/tests/tc_pos_one_fat_fat16/directories.txt0000664000175000017500000000004212321036667023067 0ustar feanorfeanorDirectory1 directory2 dir3/subDir fatsort-1.3.365/tests/tc_pos_sort_case_fat32/0000775000175000017500000000000012321036667020363 5ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_sort_case_fat32/files.txt0000664000175000017500000000043112321036667022224 0ustar feanorfeanora b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z Ä Ö Ü file3.bin file2.bin file1.bin Long file name with lots of words and characters just to test long file name entries in FAT file systems 1 2 3 4 5 6 7 8 9 10 01b 1a 001c fatsort-1.3.365/tests/tc_pos_sort_case_fat32/Makefile0000775000175000017500000000342512321036667022032 0ustar feanorfeanorinclude ../testconfig.mk FS_FATType=32 # MiBytes FS_SIZE=100 FS_FATs=1 FS_VOL_NAME=test FS_ROOT_ENTRIES=512 FS_RSVD_SEC=32 FS_SEC_PER_CLUS=1 FS_SEC_SIZE=512 DIRECTORIES=directories.txt FILES=files.txt TESTLOG=test.log STDOUT=stdout.log STDOUT_EXP=stdout_expected.txt STDERR=stderr.log STDERR_EXP=stderr_expected.txt all: fsck if [ ${DEL_FS_ON_PASS} -eq 1 ]; then rm -f ${FS_IMG}; fi clean: rm -fr *.log *.tmp ${FS_IMG} ${TMPFILE} ${TMPDIR} if [ -d ${MOUNT_POINT} ]; then \ until sudo umount ${MOUNT_POINT}; do sleep 1; done; \ rmdir ${MOUNT_POINT}; \ fi # create file system mkfs: # ++++++++++ Creating file ${FATType} system ++++++++++ rm -f ${FS_IMG} truncate -s ${FS_SIZE}MB ${FS_IMG} mkfs.vfat -F ${FS_FATType} -f ${FS_FATs} -n ${FS_VOL_NAME} -r ${FS_ROOT_ENTRIES} -R ${FS_RSVD_SEC} -s ${FS_SEC_PER_CLUS} -S ${FS_SEC_SIZE} ${FS_IMG} # populate fs populatefs: mkfs # ++++++++++ Populating file system with directories and files ++++++++++ mkdir -p ${MOUNT_POINT} sudo mount -o loop,codepage=850,iocharset=iso8859-1,utf8,uid=${MOUNT_UID},gid=${MOUNT_GID} ${FS_IMG} ${MOUNT_POINT} cat ${DIRECTORIES} | while read dir; do mkdir -p "${MOUNT_POINT}/$$dir"; done cat ${FILES} | while read file; do touch "${MOUNT_POINT}/$$file"; done until sudo umount ${MOUNT_POINT}; do sleep 1; done rmdir ${MOUNT_POINT} # alter file system as necessary for the test alterfs: populatefs # ++++++++++ Altering file system ++++++++++ # empty here rm -fr ${TMPFILE} execute: alterfs # ++++++++++ Executing tests ++++++++++ ${FATSORT} -c ${FS_IMG} ${FATSORT} -l ${FS_IMG} > ${STDOUT} 2> ${STDERR} diff ${STDOUT} ${STDOUT_EXP} diff ${STDERR} ${STDERR_EXP} # check result fsck: execute # ++++++++++ Checking file system ++++++++++ fsck.vfat -n ${FS_IMG} .PHONY: fsck execute populatefs mkfs clean fatsort-1.3.365/tests/tc_pos_sort_case_fat32/stderr_expected.txt0000664000175000017500000000000012321036667024276 0ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_sort_case_fat32/stdout_expected.txt0000664000175000017500000000052212321036667024326 0ustar feanorfeanorFile system: FAT32. / dir3 Directory1 directory2 001c 01b 1 10 1a 2 3 4 5 6 7 8 9 a Ä b c d e f file1.bin file2.bin file3.bin g h i j k l Long file name with lots of words and characters just to test long file name entries in FAT file systems m n o Ö p q r s t u Ü v w x y z /dir3/ subDir /dir3/subDir/ /Directory1/ /directory2/ fatsort-1.3.365/tests/tc_pos_sort_case_fat32/directories.txt0000664000175000017500000000004212321036667023434 0ustar feanorfeanorDirectory1 directory2 dir3/subDir fatsort-1.3.365/tests/tc_neg_cluster_size_too_big/0000775000175000017500000000000012321036667021567 5ustar feanorfeanorfatsort-1.3.365/tests/tc_neg_cluster_size_too_big/files.txt0000664000175000017500000000012412321036667023427 0ustar feanorfeanorlong_filename___________________________1 long_filename___________________________2 fatsort-1.3.365/tests/tc_neg_cluster_size_too_big/Makefile0000775000175000017500000000376212321036667023242 0ustar feanorfeanorinclude ../testconfig.mk FS_FATType=32 # 100 MiBytes FS_SIZE=100 FS_FATs=2 FS_VOL_NAME=test FS_ROOT_ENTRIES=512 FS_RSVD_SEC=32 FS_SEC_PER_CLUS=1 FS_SEC_SIZE=512 DIRECTORIES=directories.txt FILES=files.txt TESTLOG=test.log STDOUT=stdout.log STDOUT_EXP=stdout_expected.txt STDERR=stderr.log STDERR_EXP=stderr_expected.txt # no fsck in negative tests all: execute if [ ${DEL_FS_ON_PASS} -eq 1 ]; then rm -f ${FS_IMG}; fi clean: rm -fr *.log *.tmp ${FS_IMG} ${TMPFILE} ${TMPDIR} if [ -d ${MOUNT_POINT} ]; then \ until sudo umount ${MOUNT_POINT}; do sleep 1; done; \ rmdir ${MOUNT_POINT}; \ fi # create file system mkfs: # ++++++++++ Creating file ${FATType} system ++++++++++ rm -f ${FS_IMG} truncate -s ${FS_SIZE}MB ${FS_IMG} mkfs.vfat -F ${FS_FATType} -f ${FS_FATs} -n ${FS_VOL_NAME} -r ${FS_ROOT_ENTRIES} -R ${FS_RSVD_SEC} -s ${FS_SEC_PER_CLUS} -S ${FS_SEC_SIZE} ${FS_IMG} # populate fs populatefs: mkfs # ++++++++++ Populating file system with directories and files ++++++++++ mkdir -p ${MOUNT_POINT} sudo mount -o loop,codepage=850,iocharset=iso8859-1,utf8,uid=${MOUNT_UID},gid=${MOUNT_GID} ${FS_IMG} ${MOUNT_POINT} cat ${DIRECTORIES} | while read dir; do mkdir -p "${MOUNT_POINT}/$$dir"; done cat ${FILES} | while read file; do touch "${MOUNT_POINT}/$$file"; done rm -f "${MOUNT_POINT}/a" #remove some files rm -f "${MOUNT_POINT}/n" rm -f "${MOUNT_POINT}/z" until sudo umount ${MOUNT_POINT}; do sleep 1; done rmdir ${MOUNT_POINT} # alter file system as necessary for the test alterfs: populatefs # ++++++++++ Altering file system ++++++++++ # set sectors per cluster to 128 ${BBE} -b xd:1 -e "r 0 \x80" ${FS_IMG} > ${TMPFILE} cp -f ${TMPFILE} ${FS_IMG} rm -fr ${TMPFILE} execute: alterfs # ++++++++++ Executing tests ++++++++++ ${FATSORT} ${FS_IMG} > ${STDOUT} 2> ${STDERR}; [ $$? -ne 0 ] diff ${STDOUT} ${STDOUT_EXP} diff ${STDERR} ${STDERR_EXP} # check result fsck: execute # ++++++++++ Checking file system ++++++++++ fsck.vfat -n ${FS_IMG} .PHONY: fsck execute populatefs mkfs clean fatsort-1.3.365/tests/tc_neg_cluster_size_too_big/stderr_expected.txt0000664000175000017500000000036212321036667025515 0ustar feanorfeanorcheck_bootsector: Cluster size is larger than 32k! read_bootsector: This is not a FAT boot sector or sector is damaged! openFileSystem: Failed to read boot sector! sortFileSystem: Failed to open file system! main: Failed to sort file system! fatsort-1.3.365/tests/tc_neg_cluster_size_too_big/stdout_expected.txt0000664000175000017500000000000012321036667025521 0ustar feanorfeanorfatsort-1.3.365/tests/tc_neg_cluster_size_too_big/directories.txt0000664000175000017500000000000012321036667024632 0ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_three_fats_fat16/0000775000175000017500000000000012321036667020527 5ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_three_fats_fat16/files.txt0000664000175000017500000000043112321036667022370 0ustar feanorfeanora b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z Ä Ö Ü file3.bin file2.bin file1.bin Long file name with lots of words and characters just to test long file name entries in FAT file systems 1 2 3 4 5 6 7 8 9 10 01b 1a 001c fatsort-1.3.365/tests/tc_pos_three_fats_fat16/Makefile0000775000175000017500000000342212321036667022173 0ustar feanorfeanorinclude ../testconfig.mk FS_FATType=16 # MiBytes FS_SIZE=10 FS_FATs=3 FS_VOL_NAME=test FS_ROOT_ENTRIES=512 FS_RSVD_SEC=32 FS_SEC_PER_CLUS=1 FS_SEC_SIZE=512 DIRECTORIES=directories.txt FILES=files.txt TESTLOG=test.log STDOUT=stdout.log STDOUT_EXP=stdout_expected.txt STDERR=stderr.log STDERR_EXP=stderr_expected.txt all: fsck if [ ${DEL_FS_ON_PASS} -eq 1 ]; then rm -f ${FS_IMG}; fi clean: rm -fr *.log *.tmp ${FS_IMG} ${TMPFILE} ${TMPDIR} if [ -d ${MOUNT_POINT} ]; then \ until sudo umount ${MOUNT_POINT}; do sleep 1; done; \ rmdir ${MOUNT_POINT}; \ fi # create file system mkfs: # ++++++++++ Creating file ${FATType} system ++++++++++ rm -f ${FS_IMG} truncate -s ${FS_SIZE}MB ${FS_IMG} mkfs.vfat -F ${FS_FATType} -f ${FS_FATs} -n ${FS_VOL_NAME} -r ${FS_ROOT_ENTRIES} -R ${FS_RSVD_SEC} -s ${FS_SEC_PER_CLUS} -S ${FS_SEC_SIZE} ${FS_IMG} # populate fs populatefs: mkfs # ++++++++++ Populating file system with directories and files ++++++++++ mkdir -p ${MOUNT_POINT} sudo mount -o loop,codepage=850,iocharset=iso8859-1,utf8,uid=${MOUNT_UID},gid=${MOUNT_GID} ${FS_IMG} ${MOUNT_POINT} cat ${DIRECTORIES} | while read dir; do mkdir -p "${MOUNT_POINT}/$$dir"; done cat ${FILES} | while read file; do touch "${MOUNT_POINT}/$$file"; done until sudo umount ${MOUNT_POINT}; do sleep 1; done rmdir ${MOUNT_POINT} # alter file system as necessary for the test alterfs: populatefs # ++++++++++ Altering file system ++++++++++ # empty here rm -fr ${TMPFILE} execute: alterfs # ++++++++++ Executing tests ++++++++++ ${FATSORT} ${FS_IMG} ${FATSORT} -l ${FS_IMG} > ${STDOUT} 2> ${STDERR} diff ${STDOUT} ${STDOUT_EXP} diff ${STDERR} ${STDERR_EXP} # check result fsck: execute # ++++++++++ Checking file system ++++++++++ #fsck.vfat -n ${FS_IMG} .PHONY: fsck execute populatefs mkfs clean fatsort-1.3.365/tests/tc_pos_three_fats_fat16/stderr_expected.txt0000664000175000017500000000000012321036667024442 0ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_three_fats_fat16/stdout_expected.txt0000664000175000017500000000052212321036667024472 0ustar feanorfeanorFile system: FAT16. / dir3 Directory1 directory2 001c 01b 1 10 1a 2 3 4 5 6 7 8 9 a Ä b c d e f file1.bin file2.bin file3.bin g h i j k l Long file name with lots of words and characters just to test long file name entries in FAT file systems m n o Ö p q r s t u Ü v w x y z /dir3/ subDir /dir3/subDir/ /Directory1/ /directory2/ fatsort-1.3.365/tests/tc_pos_three_fats_fat16/directories.txt0000664000175000017500000000004212321036667023600 0ustar feanorfeanorDirectory1 directory2 dir3/subDir fatsort-1.3.365/tests/tc_pos_sort_reverse_fat12/0000775000175000017500000000000012321036667021121 5ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_sort_reverse_fat12/files.txt0000664000175000017500000000043112321036667022762 0ustar feanorfeanora b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z Ä Ö Ü file3.bin file2.bin file1.bin Long file name with lots of words and characters just to test long file name entries in FAT file systems 1 2 3 4 5 6 7 8 9 10 01b 1a 001c fatsort-1.3.365/tests/tc_pos_sort_reverse_fat12/Makefile0000775000175000017500000000345212321036667022570 0ustar feanorfeanorinclude ../testconfig.mk FS_FATType=12 # MiBytes FS_SIZE=10 FS_FATs=1 FS_VOL_NAME=test FS_ROOT_ENTRIES=512 FS_RSVD_SEC=32 FS_SEC_PER_CLUS=16 FS_SEC_SIZE=512 DIRECTORIES=directories.txt FILES=files.txt TESTLOG=test.log STDOUT=stdout.log STDOUT_EXP=stdout_expected.txt STDERR=stderr.log STDERR_EXP=stderr_expected.txt all: fsck if [ ${DEL_FS_ON_PASS} -eq 1 ]; then rm -f ${FS_IMG}; fi clean: rm -fr *.log *.tmp ${FS_IMG} ${TMPFILE} ${TMPDIR} if [ -d ${MOUNT_POINT} ]; then \ until sudo umount ${MOUNT_POINT}; do sleep 1; done; \ rmdir ${MOUNT_POINT}; \ fi # create file system mkfs: # ++++++++++ Creating file ${FATType} system ++++++++++ rm -f ${FS_IMG} truncate -s ${FS_SIZE}MB ${FS_IMG} mkfs.vfat -F ${FS_FATType} -f ${FS_FATs} -n ${FS_VOL_NAME} -r ${FS_ROOT_ENTRIES} -R ${FS_RSVD_SEC} -s ${FS_SEC_PER_CLUS} -S ${FS_SEC_SIZE} ${FS_IMG} # populate fs populatefs: mkfs # ++++++++++ Populating file system with directories and files ++++++++++ mkdir -p ${MOUNT_POINT} sudo mount -o loop,codepage=850,iocharset=iso8859-1,utf8,uid=${MOUNT_UID},gid=${MOUNT_GID} ${FS_IMG} ${MOUNT_POINT} cat ${DIRECTORIES} | while read dir; do mkdir -p "${MOUNT_POINT}/$$dir"; done cat ${FILES} | while read file; do touch "${MOUNT_POINT}/$$file"; done # delete some files until sudo umount ${MOUNT_POINT}; do sleep 1; done rmdir ${MOUNT_POINT} # alter file system as necessary for the test alterfs: populatefs # ++++++++++ Altering file system ++++++++++ # empty here rm -fr ${TMPFILE} execute: alterfs # ++++++++++ Executing tests ++++++++++ ${FATSORT} -r ${FS_IMG} ${FATSORT} -l ${FS_IMG} > ${STDOUT} 2> ${STDERR} diff ${STDOUT} ${STDOUT_EXP} diff ${STDERR} ${STDERR_EXP} # check result fsck: execute # ++++++++++ Checking file system ++++++++++ fsck.vfat -n ${FS_IMG} .PHONY: fsck execute populatefs mkfs clean fatsort-1.3.365/tests/tc_pos_sort_reverse_fat12/stderr_expected.txt0000664000175000017500000000000012321036667025034 0ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_sort_reverse_fat12/stdout_expected.txt0000664000175000017500000000052212321036667025064 0ustar feanorfeanorFile system: FAT12. / directory2 Directory1 dir3 z y x w v Ü u t s r q p Ö o n m Long file name with lots of words and characters just to test long file name entries in FAT file systems l k j i h g file3.bin file2.bin file1.bin f e d c b Ä a 9 8 7 6 5 4 3 2 1a 10 1 01b 001c /directory2/ /Directory1/ /dir3/ subDir /dir3/subDir/ fatsort-1.3.365/tests/tc_pos_sort_reverse_fat12/directories.txt0000664000175000017500000000004212321036667024172 0ustar feanorfeanorDirectory1 directory2 dir3/subDir fatsort-1.3.365/tests/tc_pos_sort_dir2_fat32/0000775000175000017500000000000012321036667020310 5ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_sort_dir2_fat32/files.txt0000664000175000017500000000064412321036667022157 0ustar feanorfeanorz g u n w e o a c v dir1/z dir1/g dir1/u dir1/n dir1/w dir1/e dir1/o dir1/a dir1/c dir1/v dir2/z dir2/g dir2/u dir2/n dir2/w dir2/e dir2/o dir2/a dir2/c dir2/v dir3/z dir3/g dir3/u dir3/n dir3/w dir3/e dir3/o dir3/a dir3/c dir3/v dir4/z dir4/g dir4/u dir4/n dir4/w dir4/e dir4/o dir4/a dir4/c dir4/v dir4/dir5/z dir4/dir5/g dir4/dir5/u dir4/dir5/n dir4/dir5/w dir4/dir5/e dir4/dir5/o dir4/dir5/a dir4/dir5/c dir4/dir5/v fatsort-1.3.365/tests/tc_pos_sort_dir2_fat32/Makefile0000775000175000017500000000346012321036667021756 0ustar feanorfeanorinclude ../testconfig.mk FS_FATType=32 # MiBytes FS_SIZE=100 FS_FATs=1 FS_VOL_NAME=test FS_ROOT_ENTRIES=512 FS_RSVD_SEC=32 FS_SEC_PER_CLUS=1 FS_SEC_SIZE=512 DIRECTORIES=directories.txt FILES=files.txt TESTLOG=test.log STDOUT=stdout.log STDOUT_EXP=stdout_expected.txt STDERR=stderr.log STDERR_EXP=stderr_expected.txt all: fsck if [ ${DEL_FS_ON_PASS} -eq 1 ]; then rm -f ${FS_IMG}; fi clean: rm -fr *.log *.tmp ${FS_IMG} ${TMPFILE} ${TMPDIR} if [ -d ${MOUNT_POINT} ]; then \ until sudo umount ${MOUNT_POINT}; do sleep 1; done; \ rmdir ${MOUNT_POINT}; \ fi # create file system mkfs: # ++++++++++ Creating file ${FATType} system ++++++++++ rm -f ${FS_IMG} truncate -s ${FS_SIZE}MB ${FS_IMG} mkfs.vfat -F ${FS_FATType} -f ${FS_FATs} -n ${FS_VOL_NAME} -r ${FS_ROOT_ENTRIES} -R ${FS_RSVD_SEC} -s ${FS_SEC_PER_CLUS} -S ${FS_SEC_SIZE} ${FS_IMG} # populate fs populatefs: mkfs # ++++++++++ Populating file system with directories and files ++++++++++ mkdir -p ${MOUNT_POINT} sudo mount -o loop,codepage=850,iocharset=iso8859-1,utf8,uid=${MOUNT_UID},gid=${MOUNT_GID} ${FS_IMG} ${MOUNT_POINT} cat ${DIRECTORIES} | while read dir; do mkdir -p "${MOUNT_POINT}/$$dir"; done cat ${FILES} | while read file; do touch "${MOUNT_POINT}/$$file"; done # delete some files until sudo umount ${MOUNT_POINT}; do sleep 1; done rmdir ${MOUNT_POINT} # alter file system as necessary for the test alterfs: populatefs # ++++++++++ Altering file system ++++++++++ # empty here rm -fr ${TMPFILE} execute: alterfs # ++++++++++ Executing tests ++++++++++ ${FATSORT} -D /dir4 ${FS_IMG} ${FATSORT} -l ${FS_IMG} > ${STDOUT} 2> ${STDERR} diff ${STDOUT} ${STDOUT_EXP} diff ${STDERR} ${STDERR_EXP} # check result fsck: execute # ++++++++++ Checking file system ++++++++++ fsck.vfat -n ${FS_IMG} .PHONY: fsck execute populatefs mkfs clean fatsort-1.3.365/tests/tc_pos_sort_dir2_fat32/stderr_expected.txt0000664000175000017500000000000012321036667024223 0ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_sort_dir2_fat32/stdout_expected.txt0000664000175000017500000000032612321036667024255 0ustar feanorfeanorFile system: FAT32. / dir1 dir2 dir3 dir4 z g u n w e o a c v /dir1/ z g u n w e o a c v /dir2/ z g u n w e o a c v /dir3/ z g u n w e o a c v /dir4/ dir5 a c e g n o u v w z /dir4/dir5/ a c e g n o u v w z fatsort-1.3.365/tests/tc_pos_sort_dir2_fat32/directories.txt0000664000175000017500000000003112321036667023357 0ustar feanorfeanordir1 dir2 dir3 dir4/dir5 fatsort-1.3.365/tests/tc_neg_bad_total_sector_size_fat32/0000775000175000017500000000000012321036667022713 5ustar feanorfeanorfatsort-1.3.365/tests/tc_neg_bad_total_sector_size_fat32/files.txt0000664000175000017500000000001112321036667024546 0ustar feanorfeanordir/test fatsort-1.3.365/tests/tc_neg_bad_total_sector_size_fat32/Makefile0000775000175000017500000000366512321036667024370 0ustar feanorfeanorinclude ../testconfig.mk FS_FATType=32 # 100 MiBytes FS_SIZE=100 FS_FATs=2 FS_VOL_NAME=test FS_ROOT_ENTRIES=512 FS_RSVD_SEC=32 FS_SEC_PER_CLUS=1 FS_SEC_SIZE=512 DIRECTORIES=directories.txt FILES=files.txt TESTLOG=test.log STDOUT=stdout.log STDOUT_EXP=stdout_expected.txt STDERR=stderr.log STDERR_EXP=stderr_expected.txt # no fsck in negative tests all: execute if [ ${DEL_FS_ON_PASS} -eq 1 ]; then rm -f ${FS_IMG}; fi clean: rm -fr *.log *.tmp ${FS_IMG} ${TMPFILE} ${TMPDIR} if [ -d ${MOUNT_POINT} ]; then \ until sudo umount ${MOUNT_POINT}; do sleep 1; done; \ rmdir ${MOUNT_POINT}; \ fi # create file system mkfs: # ++++++++++ Creating file ${FATType} system ++++++++++ rm -f ${FS_IMG} truncate -s ${FS_SIZE}MB ${FS_IMG} mkfs.vfat -F ${FS_FATType} -f ${FS_FATs} -n ${FS_VOL_NAME} -r ${FS_ROOT_ENTRIES} -R ${FS_RSVD_SEC} -s ${FS_SEC_PER_CLUS} -S ${FS_SEC_SIZE} ${FS_IMG} # populate fs populatefs: mkfs # ++++++++++ Populating file system with directories and files ++++++++++ mkdir -p ${MOUNT_POINT} sudo mount -o loop,codepage=850,iocharset=iso8859-1,utf8,uid=${MOUNT_UID},gid=${MOUNT_GID} ${FS_IMG} ${MOUNT_POINT} cat ${DIRECTORIES} | while read dir; do mkdir -p "${MOUNT_POINT}/$$dir"; done cat ${FILES} | while read file; do touch "${MOUNT_POINT}/$$file"; done until sudo umount ${MOUNT_POINT}; do sleep 1; done rmdir ${MOUNT_POINT} # alter file system as necessary for the test alterfs: populatefs # ++++++++++ Altering file system ++++++++++ # set 32-bit count of total sectors to zero (bad for FAT32) ${BBE} -b x20:4 -e "r 0 \x00\x00\x00\x00" ${FS_IMG} > ${TMPFILE} cp ${TMPFILE} ${FS_IMG} rm -fr ${TMPFILE} execute: alterfs # ++++++++++ Executing tests ++++++++++ ${FATSORT} ${FS_IMG} > ${STDOUT} 2> ${STDERR}; [ $$? -ne 0 ] diff ${STDOUT} ${STDOUT_EXP} diff ${STDERR} ${STDERR_EXP} # check result fsck: execute # ++++++++++ Checking file system ++++++++++ fsck.vfat -n ${FS_IMG} .PHONY: fsck execute populatefs mkfs clean fatsort-1.3.365/tests/tc_neg_bad_total_sector_size_fat32/stderr_expected.txt0000664000175000017500000000020712321036667026637 0ustar feanorfeanoropenFileSystem: Count of total sectors must not be zero! sortFileSystem: Failed to open file system! main: Failed to sort file system! fatsort-1.3.365/tests/tc_neg_bad_total_sector_size_fat32/stdout_expected.txt0000664000175000017500000000000012321036667026645 0ustar feanorfeanorfatsort-1.3.365/tests/tc_neg_bad_total_sector_size_fat32/directories.txt0000664000175000017500000000000412321036667025762 0ustar feanorfeanordir fatsort-1.3.365/tests/tc_pos_sort_natural_fat16/0000775000175000017500000000000012321036667021120 5ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_sort_natural_fat16/files.txt0000664000175000017500000000054012321036667022762 0ustar feanorfeanor0abcdfgh 0defgh 0zgrth 1ihihu 2oijoj 3trgtrgrtgrtgr 4gtrjgr 5grtgrtg 6htzhzt 7jztjztj 8fesfnffre 9arefawiufneirg 01forejgoiregiog 02oirjfoirejg 03zthrrtr 04rrtdsefi 05eeeeirg 06mvdvvfvd 07oeweff 08xmcncew 09reiregerg 001rieortert 002iiewfref 003rgrgegeg 004nnbrferf 005wiiewfe 006ootot 007zttt 00822eeewr 009qqeqeun 5abc06defg 05abc6abc 005abc00006aaa fatsort-1.3.365/tests/tc_pos_sort_natural_fat16/Makefile0000775000175000017500000000345112321036667022566 0ustar feanorfeanorinclude ../testconfig.mk FS_FATType=16 # MiBytes FS_SIZE=10 FS_FATs=1 FS_VOL_NAME=test FS_ROOT_ENTRIES=512 FS_RSVD_SEC=32 FS_SEC_PER_CLUS=1 FS_SEC_SIZE=512 DIRECTORIES=directories.txt FILES=files.txt TESTLOG=test.log STDOUT=stdout.log STDOUT_EXP=stdout_expected.txt STDERR=stderr.log STDERR_EXP=stderr_expected.txt all: fsck if [ ${DEL_FS_ON_PASS} -eq 1 ]; then rm -f ${FS_IMG}; fi clean: rm -fr *.log *.tmp ${FS_IMG} ${TMPFILE} ${TMPDIR} if [ -d ${MOUNT_POINT} ]; then \ until sudo umount ${MOUNT_POINT}; do sleep 1; done; \ rmdir ${MOUNT_POINT}; \ fi # create file system mkfs: # ++++++++++ Creating file ${FATType} system ++++++++++ rm -f ${FS_IMG} truncate -s ${FS_SIZE}MB ${FS_IMG} mkfs.vfat -F ${FS_FATType} -f ${FS_FATs} -n ${FS_VOL_NAME} -r ${FS_ROOT_ENTRIES} -R ${FS_RSVD_SEC} -s ${FS_SEC_PER_CLUS} -S ${FS_SEC_SIZE} ${FS_IMG} # populate fs populatefs: mkfs # ++++++++++ Populating file system with directories and files ++++++++++ mkdir -p ${MOUNT_POINT} sudo mount -o loop,codepage=850,iocharset=iso8859-1,utf8,uid=${MOUNT_UID},gid=${MOUNT_GID} ${FS_IMG} ${MOUNT_POINT} cat ${DIRECTORIES} | while read dir; do mkdir -p "${MOUNT_POINT}/$$dir"; done cat ${FILES} | while read file; do touch "${MOUNT_POINT}/$$file"; done # delete some files until sudo umount ${MOUNT_POINT}; do sleep 1; done rmdir ${MOUNT_POINT} # alter file system as necessary for the test alterfs: populatefs # ++++++++++ Altering file system ++++++++++ # empty here rm -fr ${TMPFILE} execute: alterfs # ++++++++++ Executing tests ++++++++++ ${FATSORT} -n ${FS_IMG} ${FATSORT} -l ${FS_IMG} > ${STDOUT} 2> ${STDERR} diff ${STDOUT} ${STDOUT_EXP} diff ${STDERR} ${STDERR_EXP} # check result fsck: execute # ++++++++++ Checking file system ++++++++++ fsck.vfat -n ${FS_IMG} .PHONY: fsck execute populatefs mkfs clean fatsort-1.3.365/tests/tc_pos_sort_natural_fat16/stderr_expected.txt0000664000175000017500000000000012321036667025033 0ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_sort_natural_fat16/stdout_expected.txt0000664000175000017500000000057012321036667025066 0ustar feanorfeanorFile system: FAT16. / 0abcdfgh 0defgh 0zgrth 01forejgoiregiog 1ihihu 001rieortert 002iiewfref 2oijoj 02oirjfoirejg 003rgrgegeg 3trgtrgrtgrtgr 03zthrrtr 4gtrjgr 004nnbrferf 04rrtdsefi 005abc00006aaa 05abc6abc 5abc06defg 05eeeeirg 5grtgrtg 005wiiewfe 6htzhzt 06mvdvvfvd 006ootot 7jztjztj 07oeweff 007zttt 8fesfnffre 08xmcncew 9arefawiufneirg 009qqeqeun 09reiregerg 00822eeewr fatsort-1.3.365/tests/tc_pos_sort_natural_fat16/directories.txt0000664000175000017500000000000012321036667024163 0ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_print_fs_info_fat12/0000775000175000017500000000000012321036667021236 5ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_print_fs_info_fat12/files.txt0000664000175000017500000000205512321036667023103 0ustar feanorfeanora b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z Ä Ö Ü file3.bin file2.bin file1.bin Long file name with lots of words and characters just to test long file name entries in FAT file systems1 Long file name with lots of words and characters just to test long file name entries in FAT file systems2 Long file name with lots of words and characters just to test long file name entries in FAT file systems3 Long file name with lots of words and characters just to test long file name entries in FAT file systems4 1 2 3 4 5 6 7 8 9 10 01b 1a 001c Directory1/Long file name with lots of words and characters just to test long file name entries in FAT file systems1 Directory1/Long file name with lots of words and characters just to test long file name entries in FAT file systems2 Directory1/Long file name with lots of words and characters just to test long file name entries in FAT file systems3 Directory1/Long file name with lots of words and characters just to test long file name entries in FAT file systems4 fatsort-1.3.365/tests/tc_pos_print_fs_info_fat12/Makefile0000775000175000017500000000346612321036667022712 0ustar feanorfeanorinclude ../testconfig.mk FS_FATType=12 # MiBytes FS_SIZE=10 FS_FATs=2 FS_VOL_NAME=test FS_ROOT_ENTRIES=512 FS_RSVD_SEC=32 FS_SEC_PER_CLUS=16 FS_SEC_SIZE=512 FS_BAD_BLOCKS_FILE=badblocks.txt DIRECTORIES=directories.txt FILES=files.txt TESTLOG=test.log STDOUT=stdout.log STDOUT_EXP=stdout_expected.txt STDERR=stderr.log STDERR_EXP=stderr_expected.txt all: fsck if [ ${DEL_FS_ON_PASS} -eq 1 ]; then rm -f ${FS_IMG}; fi clean: rm -fr *.log *.tmp ${FS_IMG} ${TMPFILE} ${TMPDIR} if [ -d ${MOUNT_POINT} ]; then \ until sudo umount ${MOUNT_POINT}; do sleep 1; done; \ rmdir ${MOUNT_POINT}; \ fi # create file system mkfs: # ++++++++++ Creating file ${FATType} system ++++++++++ rm -f ${FS_IMG} truncate -s ${FS_SIZE}MB ${FS_IMG} mkfs.vfat -F ${FS_FATType} -f ${FS_FATs} -n ${FS_VOL_NAME} -r ${FS_ROOT_ENTRIES} -R ${FS_RSVD_SEC} -s ${FS_SEC_PER_CLUS} -S ${FS_SEC_SIZE} -l ${FS_BAD_BLOCKS_FILE} ${FS_IMG} # populate fs populatefs: mkfs # ++++++++++ Populating file system with directories and files ++++++++++ mkdir -p ${MOUNT_POINT} sudo mount -o loop,codepage=850,iocharset=iso8859-1,utf8,uid=${MOUNT_UID},gid=${MOUNT_GID} ${FS_IMG} ${MOUNT_POINT} cat ${DIRECTORIES} | while read dir; do mkdir -p "${MOUNT_POINT}/$$dir"; done cat ${FILES} | while read file; do touch "${MOUNT_POINT}/$$file"; done until sudo umount ${MOUNT_POINT}; do sleep 1; done rmdir ${MOUNT_POINT} # alter file system as necessary for the test alterfs: populatefs # ++++++++++ Altering file system ++++++++++ # empty here rm -fr ${TMPFILE} execute: alterfs # ++++++++++ Executing tests ++++++++++ ${FATSORT} -i ${FS_IMG} > ${STDOUT} 2> ${STDERR} diff ${STDOUT} ${STDOUT_EXP} diff ${STDERR} ${STDERR_EXP} # check result fsck: execute # ++++++++++ Checking file system ++++++++++ fsck.vfat -n ${FS_IMG} .PHONY: fsck execute populatefs mkfs clean fatsort-1.3.365/tests/tc_pos_print_fs_info_fat12/badblocks.txt0000664000175000017500000000002612321036667023721 0ustar feanorfeanor1234 1337 2324 4242 fatsort-1.3.365/tests/tc_pos_print_fs_info_fat12/stderr_expected.txt0000664000175000017500000000000012321036667025151 0ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_print_fs_info_fat12/stdout_expected.txt0000664000175000017500000000056212321036667025205 0ustar feanorfeanor - File system information - Device: /tmp/fatsort-tc_pos_print_fs_info_fat12-fs.img Type: FAT12 Sector size: 512 bytes FAT size: 16 sectors (8192 bytes) Number of FATs: 2 Cluster size: 8192 bytes Max. cluster chain length: 524287 clusters Data clusters (total / used / bad): 1214 / 8 / 4 FS size: 9.48 MiBytes FAT12 root directory Entries: 512 fatsort-1.3.365/tests/tc_pos_print_fs_info_fat12/directories.txt0000664000175000017500000000004212321036667024307 0ustar feanorfeanorDirectory1 directory2 dir3/subDir fatsort-1.3.365/tests/tc_pos_sort_dir4_fat12/0000775000175000017500000000000012321036667020310 5ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_sort_dir4_fat12/files.txt0000664000175000017500000000064412321036667022157 0ustar feanorfeanorz g u n w e o a c v dir1/z dir1/g dir1/u dir1/n dir1/w dir1/e dir1/o dir1/a dir1/c dir1/v dir2/z dir2/g dir2/u dir2/n dir2/w dir2/e dir2/o dir2/a dir2/c dir2/v dir3/z dir3/g dir3/u dir3/n dir3/w dir3/e dir3/o dir3/a dir3/c dir3/v dir4/z dir4/g dir4/u dir4/n dir4/w dir4/e dir4/o dir4/a dir4/c dir4/v dir4/dir5/z dir4/dir5/g dir4/dir5/u dir4/dir5/n dir4/dir5/w dir4/dir5/e dir4/dir5/o dir4/dir5/a dir4/dir5/c dir4/dir5/v fatsort-1.3.365/tests/tc_pos_sort_dir4_fat12/Makefile0000775000175000017500000000346012321036667021756 0ustar feanorfeanorinclude ../testconfig.mk FS_FATType=12 # MiBytes FS_SIZE=10 FS_FATs=1 FS_VOL_NAME=test FS_ROOT_ENTRIES=512 FS_RSVD_SEC=32 FS_SEC_PER_CLUS=16 FS_SEC_SIZE=512 DIRECTORIES=directories.txt FILES=files.txt TESTLOG=test.log STDOUT=stdout.log STDOUT_EXP=stdout_expected.txt STDERR=stderr.log STDERR_EXP=stderr_expected.txt all: fsck if [ ${DEL_FS_ON_PASS} -eq 1 ]; then rm -f ${FS_IMG}; fi clean: rm -fr *.log *.tmp ${FS_IMG} ${TMPFILE} ${TMPDIR} if [ -d ${MOUNT_POINT} ]; then \ until sudo umount ${MOUNT_POINT}; do sleep 1; done; \ rmdir ${MOUNT_POINT}; \ fi # create file system mkfs: # ++++++++++ Creating file ${FATType} system ++++++++++ rm -f ${FS_IMG} truncate -s ${FS_SIZE}MB ${FS_IMG} mkfs.vfat -F ${FS_FATType} -f ${FS_FATs} -n ${FS_VOL_NAME} -r ${FS_ROOT_ENTRIES} -R ${FS_RSVD_SEC} -s ${FS_SEC_PER_CLUS} -S ${FS_SEC_SIZE} ${FS_IMG} # populate fs populatefs: mkfs # ++++++++++ Populating file system with directories and files ++++++++++ mkdir -p ${MOUNT_POINT} sudo mount -o loop,codepage=850,iocharset=iso8859-1,utf8,uid=${MOUNT_UID},gid=${MOUNT_GID} ${FS_IMG} ${MOUNT_POINT} cat ${DIRECTORIES} | while read dir; do mkdir -p "${MOUNT_POINT}/$$dir"; done cat ${FILES} | while read file; do touch "${MOUNT_POINT}/$$file"; done # delete some files until sudo umount ${MOUNT_POINT}; do sleep 1; done rmdir ${MOUNT_POINT} # alter file system as necessary for the test alterfs: populatefs # ++++++++++ Altering file system ++++++++++ # empty here rm -fr ${TMPFILE} execute: alterfs # ++++++++++ Executing tests ++++++++++ ${FATSORT} -X /dir4 ${FS_IMG} ${FATSORT} -l ${FS_IMG} > ${STDOUT} 2> ${STDERR} diff ${STDOUT} ${STDOUT_EXP} diff ${STDERR} ${STDERR_EXP} # check result fsck: execute # ++++++++++ Checking file system ++++++++++ fsck.vfat -n ${FS_IMG} .PHONY: fsck execute populatefs mkfs clean fatsort-1.3.365/tests/tc_pos_sort_dir4_fat12/stderr_expected.txt0000664000175000017500000000000012321036667024223 0ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_sort_dir4_fat12/stdout_expected.txt0000664000175000017500000000032612321036667024255 0ustar feanorfeanorFile system: FAT12. / dir1 dir2 dir3 dir4 a c e g n o u v w z /dir1/ a c e g n o u v w z /dir2/ a c e g n o u v w z /dir3/ a c e g n o u v w z /dir4/ dir5 z g u n w e o a c v /dir4/dir5/ z g u n w e o a c v fatsort-1.3.365/tests/tc_pos_sort_dir4_fat12/directories.txt0000664000175000017500000000003112321036667023357 0ustar feanorfeanordir1 dir2 dir3 dir4/dir5 fatsort-1.3.365/tests/tc_pos_sort_case_fat12/0000775000175000017500000000000012321036667020361 5ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_sort_case_fat12/files.txt0000664000175000017500000000043112321036667022222 0ustar feanorfeanora b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z Ä Ö Ü file3.bin file2.bin file1.bin Long file name with lots of words and characters just to test long file name entries in FAT file systems 1 2 3 4 5 6 7 8 9 10 01b 1a 001c fatsort-1.3.365/tests/tc_pos_sort_case_fat12/Makefile0000775000175000017500000000342512321036667022030 0ustar feanorfeanorinclude ../testconfig.mk FS_FATType=12 # MiBytes FS_SIZE=10 FS_FATs=1 FS_VOL_NAME=test FS_ROOT_ENTRIES=512 FS_RSVD_SEC=32 FS_SEC_PER_CLUS=16 FS_SEC_SIZE=512 DIRECTORIES=directories.txt FILES=files.txt TESTLOG=test.log STDOUT=stdout.log STDOUT_EXP=stdout_expected.txt STDERR=stderr.log STDERR_EXP=stderr_expected.txt all: fsck if [ ${DEL_FS_ON_PASS} -eq 1 ]; then rm -f ${FS_IMG}; fi clean: rm -fr *.log *.tmp ${FS_IMG} ${TMPFILE} ${TMPDIR} if [ -d ${MOUNT_POINT} ]; then \ until sudo umount ${MOUNT_POINT}; do sleep 1; done; \ rmdir ${MOUNT_POINT}; \ fi # create file system mkfs: # ++++++++++ Creating file ${FATType} system ++++++++++ rm -f ${FS_IMG} truncate -s ${FS_SIZE}MB ${FS_IMG} mkfs.vfat -F ${FS_FATType} -f ${FS_FATs} -n ${FS_VOL_NAME} -r ${FS_ROOT_ENTRIES} -R ${FS_RSVD_SEC} -s ${FS_SEC_PER_CLUS} -S ${FS_SEC_SIZE} ${FS_IMG} # populate fs populatefs: mkfs # ++++++++++ Populating file system with directories and files ++++++++++ mkdir -p ${MOUNT_POINT} sudo mount -o loop,codepage=850,iocharset=iso8859-1,utf8,uid=${MOUNT_UID},gid=${MOUNT_GID} ${FS_IMG} ${MOUNT_POINT} cat ${DIRECTORIES} | while read dir; do mkdir -p "${MOUNT_POINT}/$$dir"; done cat ${FILES} | while read file; do touch "${MOUNT_POINT}/$$file"; done until sudo umount ${MOUNT_POINT}; do sleep 1; done rmdir ${MOUNT_POINT} # alter file system as necessary for the test alterfs: populatefs # ++++++++++ Altering file system ++++++++++ # empty here rm -fr ${TMPFILE} execute: alterfs # ++++++++++ Executing tests ++++++++++ ${FATSORT} -c ${FS_IMG} ${FATSORT} -l ${FS_IMG} > ${STDOUT} 2> ${STDERR} diff ${STDOUT} ${STDOUT_EXP} diff ${STDERR} ${STDERR_EXP} # check result fsck: execute # ++++++++++ Checking file system ++++++++++ fsck.vfat -n ${FS_IMG} .PHONY: fsck execute populatefs mkfs clean fatsort-1.3.365/tests/tc_pos_sort_case_fat12/stderr_expected.txt0000664000175000017500000000000012321036667024274 0ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_sort_case_fat12/stdout_expected.txt0000664000175000017500000000052212321036667024324 0ustar feanorfeanorFile system: FAT12. / dir3 Directory1 directory2 001c 01b 1 10 1a 2 3 4 5 6 7 8 9 a Ä b c d e f file1.bin file2.bin file3.bin g h i j k l Long file name with lots of words and characters just to test long file name entries in FAT file systems m n o Ö p q r s t u Ü v w x y z /dir3/ subDir /dir3/subDir/ /Directory1/ /directory2/ fatsort-1.3.365/tests/tc_pos_sort_case_fat12/directories.txt0000664000175000017500000000004212321036667023432 0ustar feanorfeanorDirectory1 directory2 dir3/subDir fatsort-1.3.365/tests/tc_neg_faulty_ord_in_lne_in_root_dir_fat32/0000775000175000017500000000000012321036667024434 5ustar feanorfeanorfatsort-1.3.365/tests/tc_neg_faulty_ord_in_lne_in_root_dir_fat32/files.txt0000664000175000017500000000012412321036667026274 0ustar feanorfeanorlong_filename___________________________1 long_filename___________________________2 fatsort-1.3.365/tests/tc_neg_faulty_ord_in_lne_in_root_dir_fat32/Makefile0000775000175000017500000000375212321036667026106 0ustar feanorfeanorinclude ../testconfig.mk FS_FATType=32 # 100 MiBytes FS_SIZE=100 FS_FATs=2 FS_VOL_NAME=test FS_ROOT_ENTRIES=512 FS_RSVD_SEC=32 FS_SEC_PER_CLUS=1 FS_SEC_SIZE=512 DIRECTORIES=directories.txt FILES=files.txt TESTLOG=test.log STDOUT=stdout.log STDOUT_EXP=stdout_expected.txt STDERR=stderr.log STDERR_EXP=stderr_expected.txt # no fsck in negative tests all: execute if [ ${DEL_FS_ON_PASS} -eq 1 ]; then rm -f ${FS_IMG}; fi clean: rm -fr *.log *.tmp ${FS_IMG} ${TMPFILE} ${TMPDIR} if [ -d ${MOUNT_POINT} ]; then \ until sudo umount ${MOUNT_POINT}; do sleep 1; done; \ rmdir ${MOUNT_POINT}; \ fi # create file system mkfs: # ++++++++++ Creating file ${FATType} system ++++++++++ rm -f ${FS_IMG} truncate -s ${FS_SIZE}MB ${FS_IMG} mkfs.vfat -F ${FS_FATType} -f ${FS_FATs} -n ${FS_VOL_NAME} -r ${FS_ROOT_ENTRIES} -R ${FS_RSVD_SEC} -s ${FS_SEC_PER_CLUS} -S ${FS_SEC_SIZE} ${FS_IMG} # populate fs populatefs: mkfs # ++++++++++ Populating file system with directories and files ++++++++++ mkdir -p ${MOUNT_POINT} sudo mount -o loop,codepage=850,iocharset=iso8859-1,utf8,uid=${MOUNT_UID},gid=${MOUNT_GID} ${FS_IMG} ${MOUNT_POINT} cat ${DIRECTORIES} | while read dir; do mkdir -p "${MOUNT_POINT}/$$dir"; done cat ${FILES} | while read file; do touch "${MOUNT_POINT}/$$file"; done rm -f "${MOUNT_POINT}/a" #remove some files rm -f "${MOUNT_POINT}/n" rm -f "${MOUNT_POINT}/z" until sudo umount ${MOUNT_POINT}; do sleep 1; done rmdir ${MOUNT_POINT} # alter file system as necessary for the test alterfs: populatefs # ++++++++++ Altering file system ++++++++++ # change ord in lne ${BBE} -b x17bc40:1 -e "r 0 \x05" ${FS_IMG} > ${TMPFILE} cp -f ${TMPFILE} ${FS_IMG} rm -fr ${TMPFILE} execute: alterfs # ++++++++++ Executing tests ++++++++++ ${FATSORT} ${FS_IMG} > ${STDOUT} 2> ${STDERR}; [ $$? -ne 0 ] diff ${STDOUT} ${STDOUT_EXP} diff ${STDERR} ${STDERR_EXP} # check result fsck: execute # ++++++++++ Checking file system ++++++++++ fsck.vfat -n ${FS_IMG} .PHONY: fsck execute populatefs mkfs clean fatsort-1.3.365/tests/tc_neg_faulty_ord_in_lne_in_root_dir_fat32/stderr_expected.txt0000664000175000017500000000043012321036667030356 0ustar feanorfeanorcheckLongDirEntries: LongDirEntry number is 0x5 (0x5) but should be 0x3! parseClusterChain: checkDirEntry failed in cluster 00000002 at entry 5! sortClusterChain: Failed to parse cluster chain! sortFileSystem: Failed to sort first cluster chain! main: Failed to sort file system! fatsort-1.3.365/tests/tc_neg_faulty_ord_in_lne_in_root_dir_fat32/stdout_expected.txt0000664000175000017500000000005112321036667030374 0ustar feanorfeanorFile system: FAT32. Sorting directory / fatsort-1.3.365/tests/tc_neg_faulty_ord_in_lne_in_root_dir_fat32/directories.txt0000664000175000017500000000000012321036667027477 0ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_sort_dir1_fat12/0000775000175000017500000000000012321036667020305 5ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_sort_dir1_fat12/files.txt0000664000175000017500000000064412321036667022154 0ustar feanorfeanorz g u n w e o a c v dir1/z dir1/g dir1/u dir1/n dir1/w dir1/e dir1/o dir1/a dir1/c dir1/v dir2/z dir2/g dir2/u dir2/n dir2/w dir2/e dir2/o dir2/a dir2/c dir2/v dir3/z dir3/g dir3/u dir3/n dir3/w dir3/e dir3/o dir3/a dir3/c dir3/v dir4/z dir4/g dir4/u dir4/n dir4/w dir4/e dir4/o dir4/a dir4/c dir4/v dir4/dir5/z dir4/dir5/g dir4/dir5/u dir4/dir5/n dir4/dir5/w dir4/dir5/e dir4/dir5/o dir4/dir5/a dir4/dir5/c dir4/dir5/v fatsort-1.3.365/tests/tc_pos_sort_dir1_fat12/Makefile0000775000175000017500000000347112321036667021755 0ustar feanorfeanorinclude ../testconfig.mk FS_FATType=12 # MiBytes FS_SIZE=10 FS_FATs=1 FS_VOL_NAME=test FS_ROOT_ENTRIES=512 FS_RSVD_SEC=32 FS_SEC_PER_CLUS=16 FS_SEC_SIZE=512 DIRECTORIES=directories.txt FILES=files.txt TESTLOG=test.log STDOUT=stdout.log STDOUT_EXP=stdout_expected.txt STDERR=stderr.log STDERR_EXP=stderr_expected.txt all: fsck if [ ${DEL_FS_ON_PASS} -eq 1 ]; then rm -f ${FS_IMG}; fi clean: rm -fr *.log *.tmp ${FS_IMG} ${TMPFILE} ${TMPDIR} if [ -d ${MOUNT_POINT} ]; then \ until sudo umount ${MOUNT_POINT}; do sleep 1; done; \ rmdir ${MOUNT_POINT}; \ fi # create file system mkfs: # ++++++++++ Creating file ${FATType} system ++++++++++ rm -f ${FS_IMG} truncate -s ${FS_SIZE}MB ${FS_IMG} mkfs.vfat -F ${FS_FATType} -f ${FS_FATs} -n ${FS_VOL_NAME} -r ${FS_ROOT_ENTRIES} -R ${FS_RSVD_SEC} -s ${FS_SEC_PER_CLUS} -S ${FS_SEC_SIZE} ${FS_IMG} # populate fs populatefs: mkfs # ++++++++++ Populating file system with directories and files ++++++++++ mkdir -p ${MOUNT_POINT} sudo mount -o loop,codepage=850,iocharset=iso8859-1,utf8,uid=${MOUNT_UID},gid=${MOUNT_GID} ${FS_IMG} ${MOUNT_POINT} cat ${DIRECTORIES} | while read dir; do mkdir -p "${MOUNT_POINT}/$$dir"; done cat ${FILES} | while read file; do touch "${MOUNT_POINT}/$$file"; done # delete some files until sudo umount ${MOUNT_POINT}; do sleep 1; done rmdir ${MOUNT_POINT} # alter file system as necessary for the test alterfs: populatefs # ++++++++++ Altering file system ++++++++++ # empty here rm -fr ${TMPFILE} execute: alterfs # ++++++++++ Executing tests ++++++++++ ${FATSORT} -d /dir1 -d /dir3 ${FS_IMG} ${FATSORT} -l ${FS_IMG} > ${STDOUT} 2> ${STDERR} diff ${STDOUT} ${STDOUT_EXP} diff ${STDERR} ${STDERR_EXP} # check result fsck: execute # ++++++++++ Checking file system ++++++++++ fsck.vfat -n ${FS_IMG} .PHONY: fsck execute populatefs mkfs clean fatsort-1.3.365/tests/tc_pos_sort_dir1_fat12/stderr_expected.txt0000664000175000017500000000000012321036667024220 0ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_sort_dir1_fat12/stdout_expected.txt0000664000175000017500000000032612321036667024252 0ustar feanorfeanorFile system: FAT12. / dir1 dir2 dir3 dir4 z g u n w e o a c v /dir1/ a c e g n o u v w z /dir2/ z g u n w e o a c v /dir3/ a c e g n o u v w z /dir4/ dir5 z g u n w e o a c v /dir4/dir5/ z g u n w e o a c v fatsort-1.3.365/tests/tc_pos_sort_dir1_fat12/directories.txt0000664000175000017500000000003112321036667023354 0ustar feanorfeanordir1 dir2 dir3 dir4/dir5 fatsort-1.3.365/tests/tc_pos_sort_default_fat16/0000775000175000017500000000000012321036667021076 5ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_sort_default_fat16/files.txt0000664000175000017500000000205512321036667022743 0ustar feanorfeanora b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z Ä Ö Ü file3.bin file2.bin file1.bin Long file name with lots of words and characters just to test long file name entries in FAT file systems1 Long file name with lots of words and characters just to test long file name entries in FAT file systems2 Long file name with lots of words and characters just to test long file name entries in FAT file systems3 Long file name with lots of words and characters just to test long file name entries in FAT file systems4 1 2 3 4 5 6 7 8 9 10 01b 1a 001c Directory1/Long file name with lots of words and characters just to test long file name entries in FAT file systems1 Directory1/Long file name with lots of words and characters just to test long file name entries in FAT file systems2 Directory1/Long file name with lots of words and characters just to test long file name entries in FAT file systems3 Directory1/Long file name with lots of words and characters just to test long file name entries in FAT file systems4 fatsort-1.3.365/tests/tc_pos_sort_default_fat16/Makefile0000775000175000017500000000355312321036667022547 0ustar feanorfeanorinclude ../testconfig.mk FS_FATType=16 # MiBytes FS_SIZE=10 FS_FATs=2 FS_VOL_NAME=test FS_ROOT_ENTRIES=512 FS_RSVD_SEC=32 FS_SEC_PER_CLUS=1 FS_SEC_SIZE=512 DIRECTORIES=directories.txt FILES=files.txt TESTLOG=test.log STDOUT=stdout.log STDOUT_EXP=stdout_expected.txt STDERR=stderr.log STDERR_EXP=stderr_expected.txt all: fsck if [ ${DEL_FS_ON_PASS} -eq 1 ]; then rm -f ${FS_IMG}; fi clean: rm -fr *.log *.tmp ${FS_IMG} ${TMPFILE} ${TMPDIR} if [ -d ${MOUNT_POINT} ]; then \ until sudo umount ${MOUNT_POINT}; do sleep 1; done; \ rmdir ${MOUNT_POINT}; \ fi # create file system mkfs: # ++++++++++ Creating file ${FATType} system ++++++++++ rm -f ${FS_IMG} truncate -s ${FS_SIZE}MB ${FS_IMG} mkfs.vfat -F ${FS_FATType} -f ${FS_FATs} -n ${FS_VOL_NAME} -r ${FS_ROOT_ENTRIES} -R ${FS_RSVD_SEC} -s ${FS_SEC_PER_CLUS} -S ${FS_SEC_SIZE} ${FS_IMG} # populate fs populatefs: mkfs # ++++++++++ Populating file system with directories and files ++++++++++ mkdir -p ${MOUNT_POINT} sudo mount -o loop,codepage=850,iocharset=iso8859-1,utf8,uid=${MOUNT_UID},gid=${MOUNT_GID} ${FS_IMG} ${MOUNT_POINT} cat ${DIRECTORIES} | while read dir; do mkdir -p "${MOUNT_POINT}/$$dir"; done cat ${FILES} | while read file; do touch "${MOUNT_POINT}/$$file"; done # delete some files rm "${MOUNT_POINT}/a" rm "${MOUNT_POINT}/n" rm "${MOUNT_POINT}/z" until sudo umount ${MOUNT_POINT}; do sleep 1; done rmdir ${MOUNT_POINT} # alter file system as necessary for the test alterfs: populatefs # ++++++++++ Altering file system ++++++++++ # empty here rm -fr ${TMPFILE} execute: alterfs # ++++++++++ Executing tests ++++++++++ ${FATSORT} ${FS_IMG} ${FATSORT} -l ${FS_IMG} > ${STDOUT} 2> ${STDERR} diff ${STDOUT} ${STDOUT_EXP} diff ${STDERR} ${STDERR_EXP} # check result fsck: execute # ++++++++++ Checking file system ++++++++++ fsck.vfat -n ${FS_IMG} .PHONY: fsck execute populatefs mkfs clean fatsort-1.3.365/tests/tc_pos_sort_default_fat16/stderr_expected.txt0000664000175000017500000000000012321036667025011 0ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_sort_default_fat16/stdout_expected.txt0000664000175000017500000000206312321036667025043 0ustar feanorfeanorFile system: FAT16. / dir3 Directory1 directory2 001c 01b 1 10 1a 2 3 4 5 6 7 8 9 Ä b c d e f file1.bin file2.bin file3.bin g h i j k l Long file name with lots of words and characters just to test long file name entries in FAT file systems1 Long file name with lots of words and characters just to test long file name entries in FAT file systems2 Long file name with lots of words and characters just to test long file name entries in FAT file systems3 Long file name with lots of words and characters just to test long file name entries in FAT file systems4 m o Ö p q r s t u Ü v w x y /dir3/ subDir /dir3/subDir/ /Directory1/ Long file name with lots of words and characters just to test long file name entries in FAT file systems1 Long file name with lots of words and characters just to test long file name entries in FAT file systems2 Long file name with lots of words and characters just to test long file name entries in FAT file systems3 Long file name with lots of words and characters just to test long file name entries in FAT file systems4 /directory2/ fatsort-1.3.365/tests/tc_pos_sort_default_fat16/directories.txt0000664000175000017500000000004212321036667024147 0ustar feanorfeanorDirectory1 directory2 dir3/subDir fatsort-1.3.365/tests/tc_neg_broken_cluster_chain/0000775000175000017500000000000012321036667021535 5ustar feanorfeanorfatsort-1.3.365/tests/tc_neg_broken_cluster_chain/files.txt0000664000175000017500000000001112321036667023370 0ustar feanorfeanordir/test fatsort-1.3.365/tests/tc_neg_broken_cluster_chain/Makefile0000775000175000017500000000405412321036667023203 0ustar feanorfeanorinclude ../testconfig.mk FS_FATType=32 # 100 MiBytes FS_SIZE=100 FS_FATs=2 FS_VOL_NAME=test FS_ROOT_ENTRIES=512 FS_RSVD_SEC=32 FS_SEC_PER_CLUS=1 FS_SEC_SIZE=512 DIRECTORIES=directories.txt FILES=files.txt TESTLOG=test.log STDOUT=stdout.log STDOUT_EXP=stdout_expected.txt STDERR=stderr.log STDERR_EXP=stderr_expected.txt # no fsck in negative tests all: execute if [ ${DEL_FS_ON_PASS} -eq 1 ]; then rm -f ${FS_IMG}; fi clean: rm -fr *.log *.tmp ${FS_IMG} ${TMPFILE} ${TMPDIR} if [ -d ${MOUNT_POINT} ]; then \ until sudo umount ${MOUNT_POINT}; do sleep 1; done; \ rmdir ${MOUNT_POINT}; \ fi # create file system mkfs: # ++++++++++ Creating file ${FATType} system ++++++++++ rm -f ${FS_IMG} truncate -s ${FS_SIZE}MB ${FS_IMG} mkfs.vfat -F ${FS_FATType} -f ${FS_FATs} -n ${FS_VOL_NAME} -r ${FS_ROOT_ENTRIES} -R ${FS_RSVD_SEC} -s ${FS_SEC_PER_CLUS} -S ${FS_SEC_SIZE} ${FS_IMG} # populate fs populatefs: mkfs # ++++++++++ Populating file system with directories and files ++++++++++ mkdir -p ${MOUNT_POINT} sudo mount -o loop,codepage=850,iocharset=iso8859-1,utf8,uid=${MOUNT_UID},gid=${MOUNT_GID} ${FS_IMG} ${MOUNT_POINT} cat ${DIRECTORIES} | while read dir; do mkdir -p "${MOUNT_POINT}/$$dir"; done cat ${FILES} | while read file; do touch "${MOUNT_POINT}/$$file"; done rm -f "${MOUNT_POINT}/a" #remove some files rm -f "${MOUNT_POINT}/n" rm -f "${MOUNT_POINT}/z" until sudo umount ${MOUNT_POINT}; do sleep 1; done rmdir ${MOUNT_POINT} # alter file system as necessary for the test alterfs: populatefs # ++++++++++ Altering file system ++++++++++ # alter fs to break cluster chain ${BBE} -b x4008:4 -e "r 0 \x00\x00\x00\x00" ${FS_IMG} > ${TMPFILE} ${BBE} -b x0bfe08:4 -e "r 0 \x00\x00\x00\x00" ${TMPFILE} > ${FS_IMG} rm -fr ${TMPFILE} execute: alterfs # ++++++++++ Executing tests ++++++++++ ${FATSORT} ${FS_IMG} > ${STDOUT} 2> ${STDERR}; [ $$? -ne 0 ] diff ${STDOUT} ${STDOUT_EXP} diff ${STDERR} ${STDERR_EXP} # check result fsck: execute # ++++++++++ Checking file system ++++++++++ fsck.vfat -n ${FS_IMG} .PHONY: fsck execute populatefs mkfs clean fatsort-1.3.365/tests/tc_neg_broken_cluster_chain/stderr_expected.txt0000664000175000017500000000027412321036667025465 0ustar feanorfeanorgetClusterChain: Cluster 00000002 is marked as unused! sortClusterChain: Failed to get cluster chain! sortFileSystem: Failed to sort first cluster chain! main: Failed to sort file system! fatsort-1.3.365/tests/tc_neg_broken_cluster_chain/stdout_expected.txt0000664000175000017500000000002512321036667025476 0ustar feanorfeanorFile system: FAT32. fatsort-1.3.365/tests/tc_neg_broken_cluster_chain/directories.txt0000664000175000017500000000000412321036667024604 0ustar feanorfeanordir fatsort-1.3.365/tests/tc_pos_one_fat_fat32/0000775000175000017500000000000012321036666020013 5ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_one_fat_fat32/files.txt0000664000175000017500000000043112321036666021654 0ustar feanorfeanora b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z Ä Ö Ü file3.bin file2.bin file1.bin Long file name with lots of words and characters just to test long file name entries in FAT file systems 1 2 3 4 5 6 7 8 9 10 01b 1a 001c fatsort-1.3.365/tests/tc_pos_one_fat_fat32/Makefile0000775000175000017500000000342212321036666021457 0ustar feanorfeanorinclude ../testconfig.mk FS_FATType=32 # MiBytes FS_SIZE=100 FS_FATs=1 FS_VOL_NAME=test FS_ROOT_ENTRIES=512 FS_RSVD_SEC=32 FS_SEC_PER_CLUS=1 FS_SEC_SIZE=512 DIRECTORIES=directories.txt FILES=files.txt TESTLOG=test.log STDOUT=stdout.log STDOUT_EXP=stdout_expected.txt STDERR=stderr.log STDERR_EXP=stderr_expected.txt all: fsck if [ ${DEL_FS_ON_PASS} -eq 1 ]; then rm -f ${FS_IMG}; fi clean: rm -fr *.log *.tmp ${FS_IMG} ${TMPFILE} ${TMPDIR} if [ -d ${MOUNT_POINT} ]; then \ until sudo umount ${MOUNT_POINT}; do sleep 1; done; \ rmdir ${MOUNT_POINT}; \ fi # create file system mkfs: # ++++++++++ Creating file ${FATType} system ++++++++++ rm -f ${FS_IMG} truncate -s ${FS_SIZE}MB ${FS_IMG} mkfs.vfat -F ${FS_FATType} -f ${FS_FATs} -n ${FS_VOL_NAME} -r ${FS_ROOT_ENTRIES} -R ${FS_RSVD_SEC} -s ${FS_SEC_PER_CLUS} -S ${FS_SEC_SIZE} ${FS_IMG} # populate fs populatefs: mkfs # ++++++++++ Populating file system with directories and files ++++++++++ mkdir -p ${MOUNT_POINT} sudo mount -o loop,codepage=850,iocharset=iso8859-1,utf8,uid=${MOUNT_UID},gid=${MOUNT_GID} ${FS_IMG} ${MOUNT_POINT} cat ${DIRECTORIES} | while read dir; do mkdir -p "${MOUNT_POINT}/$$dir"; done cat ${FILES} | while read file; do touch "${MOUNT_POINT}/$$file"; done until sudo umount ${MOUNT_POINT}; do sleep 1; done rmdir ${MOUNT_POINT} # alter file system as necessary for the test alterfs: populatefs # ++++++++++ Altering file system ++++++++++ # empty here rm -fr ${TMPFILE} execute: alterfs # ++++++++++ Executing tests ++++++++++ ${FATSORT} ${FS_IMG} ${FATSORT} -l ${FS_IMG} > ${STDOUT} 2> ${STDERR} diff ${STDOUT} ${STDOUT_EXP} diff ${STDERR} ${STDERR_EXP} # check result fsck: execute # ++++++++++ Checking file system ++++++++++ fsck.vfat -n ${FS_IMG} .PHONY: fsck execute populatefs mkfs clean fatsort-1.3.365/tests/tc_pos_one_fat_fat32/stderr_expected.txt0000664000175000017500000000000012321036666023726 0ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_one_fat_fat32/stdout_expected.txt0000664000175000017500000000052212321036666023756 0ustar feanorfeanorFile system: FAT32. / dir3 Directory1 directory2 001c 01b 1 10 1a 2 3 4 5 6 7 8 9 a Ä b c d e f file1.bin file2.bin file3.bin g h i j k l Long file name with lots of words and characters just to test long file name entries in FAT file systems m n o Ö p q r s t u Ü v w x y z /dir3/ subDir /dir3/subDir/ /Directory1/ /directory2/ fatsort-1.3.365/tests/tc_pos_one_fat_fat32/directories.txt0000664000175000017500000000004212321036666023064 0ustar feanorfeanorDirectory1 directory2 dir3/subDir fatsort-1.3.365/tests/tc_pos_sort_prefixes_fat32/0000775000175000017500000000000012321036667021275 5ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_sort_prefixes_fat32/files.txt0000664000175000017500000000012212321036667023133 0ustar feanorfeanorTest/The Beatles Test/Beat me Test/The Unknown Test/UFO Test/ABC Test/Teletubbie fatsort-1.3.365/tests/tc_pos_sort_prefixes_fat32/Makefile0000775000175000017500000000346112321036667022744 0ustar feanorfeanorinclude ../testconfig.mk FS_FATType=32 # MiBytes FS_SIZE=100 FS_FATs=1 FS_VOL_NAME=test FS_ROOT_ENTRIES=512 FS_RSVD_SEC=32 FS_SEC_PER_CLUS=1 FS_SEC_SIZE=512 DIRECTORIES=directories.txt FILES=files.txt TESTLOG=test.log STDOUT=stdout.log STDOUT_EXP=stdout_expected.txt STDERR=stderr.log STDERR_EXP=stderr_expected.txt all: fsck if [ ${DEL_FS_ON_PASS} -eq 1 ]; then rm -f ${FS_IMG}; fi clean: rm -fr *.log *.tmp ${FS_IMG} ${TMPFILE} ${TMPDIR} if [ -d ${MOUNT_POINT} ]; then \ until sudo umount ${MOUNT_POINT}; do sleep 1; done; \ rmdir ${MOUNT_POINT}; \ fi # create file system mkfs: # ++++++++++ Creating file ${FATType} system ++++++++++ rm -f ${FS_IMG} truncate -s ${FS_SIZE}MB ${FS_IMG} mkfs.vfat -F ${FS_FATType} -f ${FS_FATs} -n ${FS_VOL_NAME} -r ${FS_ROOT_ENTRIES} -R ${FS_RSVD_SEC} -s ${FS_SEC_PER_CLUS} -S ${FS_SEC_SIZE} ${FS_IMG} # populate fs populatefs: mkfs # ++++++++++ Populating file system with directories and files ++++++++++ mkdir -p ${MOUNT_POINT} sudo mount -o loop,codepage=850,iocharset=iso8859-1,utf8,uid=${MOUNT_UID},gid=${MOUNT_GID} ${FS_IMG} ${MOUNT_POINT} cat ${DIRECTORIES} | while read dir; do mkdir -p "${MOUNT_POINT}/$$dir"; done cat ${FILES} | while read file; do touch "${MOUNT_POINT}/$$file"; done # delete some files until sudo umount ${MOUNT_POINT}; do sleep 1; done rmdir ${MOUNT_POINT} # alter file system as necessary for the test alterfs: populatefs # ++++++++++ Altering file system ++++++++++ # empty here rm -fr ${TMPFILE} execute: alterfs # ++++++++++ Executing tests ++++++++++ ${FATSORT} -I "The " ${FS_IMG} ${FATSORT} -l ${FS_IMG} > ${STDOUT} 2> ${STDERR} diff ${STDOUT} ${STDOUT_EXP} diff ${STDERR} ${STDERR_EXP} # check result fsck: execute # ++++++++++ Checking file system ++++++++++ fsck.vfat -n ${FS_IMG} .PHONY: fsck execute populatefs mkfs clean fatsort-1.3.365/tests/tc_pos_sort_prefixes_fat32/stderr_expected.txt0000664000175000017500000000000012321036667025210 0ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_sort_prefixes_fat32/stdout_expected.txt0000664000175000017500000000032012321036667025234 0ustar feanorfeanorFile system: FAT32. / ABC The Beatles Beat me Teletubbie Test UFO The Unknown /ABC/ /The Beatles/ /Beat me/ /Teletubbie/ /Test/ ABC The Beatles Beat me Teletubbie UFO The Unknown /UFO/ /The Unknown/ fatsort-1.3.365/tests/tc_pos_sort_prefixes_fat32/directories.txt0000664000175000017500000000007112321036667024350 0ustar feanorfeanorThe Beatles Beat me The Unknown UFO ABC Teletubbie Test fatsort-1.3.365/tests/tc_pos_sort_ascii_fat32/0000775000175000017500000000000012321036667020540 5ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_sort_ascii_fat32/files.txt0000664000175000017500000000001712321036667022401 0ustar feanorfeanorABC1 Abc2 abc3 fatsort-1.3.365/tests/tc_pos_sort_ascii_fat32/Makefile0000775000175000017500000000342512321036667022207 0ustar feanorfeanorinclude ../testconfig.mk FS_FATType=32 # MiBytes FS_SIZE=100 FS_FATs=2 FS_VOL_NAME=test FS_ROOT_ENTRIES=512 FS_RSVD_SEC=32 FS_SEC_PER_CLUS=1 FS_SEC_SIZE=512 DIRECTORIES=directories.txt FILES=files.txt TESTLOG=test.log STDOUT=stdout.log STDOUT_EXP=stdout_expected.txt STDERR=stderr.log STDERR_EXP=stderr_expected.txt all: fsck if [ ${DEL_FS_ON_PASS} -eq 1 ]; then rm -f ${FS_IMG}; fi clean: rm -fr *.log *.tmp ${FS_IMG} ${TMPFILE} ${TMPDIR} if [ -d ${MOUNT_POINT} ]; then \ until sudo umount ${MOUNT_POINT}; do sleep 1; done; \ rmdir ${MOUNT_POINT}; \ fi # create file system mkfs: # ++++++++++ Creating file ${FATType} system ++++++++++ rm -f ${FS_IMG} truncate -s ${FS_SIZE}MB ${FS_IMG} mkfs.vfat -F ${FS_FATType} -f ${FS_FATs} -n ${FS_VOL_NAME} -r ${FS_ROOT_ENTRIES} -R ${FS_RSVD_SEC} -s ${FS_SEC_PER_CLUS} -S ${FS_SEC_SIZE} ${FS_IMG} # populate fs populatefs: mkfs # ++++++++++ Populating file system with directories and files ++++++++++ mkdir -p ${MOUNT_POINT} sudo mount -o loop,codepage=850,iocharset=iso8859-1,utf8,uid=${MOUNT_UID},gid=${MOUNT_GID} ${FS_IMG} ${MOUNT_POINT} cat ${DIRECTORIES} | while read dir; do mkdir -p "${MOUNT_POINT}/$$dir"; done cat ${FILES} | while read file; do touch "${MOUNT_POINT}/$$file"; done until sudo umount ${MOUNT_POINT}; do sleep 1; done rmdir ${MOUNT_POINT} # alter file system as necessary for the test alterfs: populatefs # ++++++++++ Altering file system ++++++++++ # empty here rm -fr ${TMPFILE} execute: alterfs # ++++++++++ Executing tests ++++++++++ ${FATSORT} -a ${FS_IMG} ${FATSORT} -l ${FS_IMG} > ${STDOUT} 2> ${STDERR} diff ${STDOUT} ${STDOUT_EXP} diff ${STDERR} ${STDERR_EXP} # check result fsck: execute # ++++++++++ Checking file system ++++++++++ fsck.vfat -n ${FS_IMG} .PHONY: fsck execute populatefs mkfs clean fatsort-1.3.365/tests/tc_pos_sort_ascii_fat32/stderr_expected.txt0000664000175000017500000000000012321036667024453 0ustar feanorfeanorfatsort-1.3.365/tests/tc_pos_sort_ascii_fat32/stdout_expected.txt0000664000175000017500000000014612321036667024505 0ustar feanorfeanorFile system: FAT32. / dir_ABC2 dir_Abc1 dir_abc3 ABC1 Abc2 abc3 /dir_ABC2/ /dir_Abc1/ /dir_abc3/ fatsort-1.3.365/tests/tc_pos_sort_ascii_fat32/directories.txt0000664000175000017500000000003312321036667023611 0ustar feanorfeanordir_Abc1 dir_ABC2 dir_abc3 fatsort-1.3.365/tests/tc_neg_bad_sector_size/0000775000175000017500000000000012321036667020511 5ustar feanorfeanorfatsort-1.3.365/tests/tc_neg_bad_sector_size/files.txt0000664000175000017500000000001112321036667022344 0ustar feanorfeanordir/test fatsort-1.3.365/tests/tc_neg_bad_sector_size/Makefile0000775000175000017500000000361312321036667022157 0ustar feanorfeanorinclude ../testconfig.mk FS_FATType=32 # 100 MiBytes FS_SIZE=100 FS_FATs=2 FS_VOL_NAME=test FS_ROOT_ENTRIES=512 FS_RSVD_SEC=32 FS_SEC_PER_CLUS=1 FS_SEC_SIZE=512 DIRECTORIES=directories.txt FILES=files.txt TESTLOG=test.log STDOUT=stdout.log STDOUT_EXP=stdout_expected.txt STDERR=stderr.log STDERR_EXP=stderr_expected.txt # no fsck in negative tests all: execute if [ ${DEL_FS_ON_PASS} -eq 1 ]; then rm -f ${FS_IMG}; fi clean: rm -fr *.log *.tmp ${FS_IMG} ${TMPFILE} ${TMPDIR} if [ -d ${MOUNT_POINT} ]; then \ until sudo umount ${MOUNT_POINT}; do sleep 1; done; \ rmdir ${MOUNT_POINT}; \ fi # create file system mkfs: # ++++++++++ Creating file ${FATType} system ++++++++++ rm -f ${FS_IMG} truncate -s ${FS_SIZE}MB ${FS_IMG} mkfs.vfat -F ${FS_FATType} -f ${FS_FATs} -n ${FS_VOL_NAME} -r ${FS_ROOT_ENTRIES} -R ${FS_RSVD_SEC} -s ${FS_SEC_PER_CLUS} -S ${FS_SEC_SIZE} ${FS_IMG} # populate fs populatefs: mkfs # ++++++++++ Populating file system with directories and files ++++++++++ mkdir -p ${MOUNT_POINT} sudo mount -o loop,codepage=850,iocharset=iso8859-1,utf8,uid=${MOUNT_UID},gid=${MOUNT_GID} ${FS_IMG} ${MOUNT_POINT} cat ${DIRECTORIES} | while read dir; do mkdir -p "${MOUNT_POINT}/$$dir"; done cat ${FILES} | while read file; do touch "${MOUNT_POINT}/$$file"; done until sudo umount ${MOUNT_POINT}; do sleep 1; done rmdir ${MOUNT_POINT} # alter file system as necessary for the test alterfs: populatefs # ++++++++++ Altering file system ++++++++++ # alter sector size to 511 ${BBE} -b xb:2 -e "r 0 \xff\x01" ${FS_IMG} > ${TMPFILE} cp ${TMPFILE} ${FS_IMG} rm -fr ${TMPFILE} execute: alterfs # ++++++++++ Executing tests ++++++++++ ${FATSORT} ${FS_IMG} > ${STDOUT} 2> ${STDERR}; [ $$? -ne 0 ] diff ${STDOUT} ${STDOUT_EXP} diff ${STDERR} ${STDERR_EXP} # check result fsck: execute # ++++++++++ Checking file system ++++++++++ fsck.vfat -n ${FS_IMG} .PHONY: fsck execute populatefs mkfs clean fatsort-1.3.365/tests/tc_neg_bad_sector_size/stderr_expected.txt0000664000175000017500000000037512321036667024443 0ustar feanorfeanorcheck_bootsector: Sector size is not a multiple of 512 (511)! read_bootsector: This is not a FAT boot sector or sector is damaged! openFileSystem: Failed to read boot sector! sortFileSystem: Failed to open file system! main: Failed to sort file system! fatsort-1.3.365/tests/tc_neg_bad_sector_size/stdout_expected.txt0000664000175000017500000000000012321036667024443 0ustar feanorfeanorfatsort-1.3.365/tests/tc_neg_bad_sector_size/directories.txt0000664000175000017500000000000412321036667023560 0ustar feanorfeanordir