diffstat of debian/ for dosfstools_2.10-1 dosfstools_2.11-0osso9 README.Atari | 60 - changelog | 299 ------ compat | 1 control | 4 patches/00-dosfstools_2.11-2.3.diff | 310 ++++++ patches/01-add-tag-to-makefile.patch | 12 patches/02-correct-mandir.patch | 12 patches/03-print-hash-marks.patch | 46 patches/04-print-dosfsck-progress.patch | 56 + patches/05-fix-logical-sector-calc.patch | 20 patches/06-always-select-backup-fat-table.patch | 27 patches/07-use-osso-mem.patch | 1134 ++++++++++++++++++++++++ patches/08-limit-cluster-msg.patch | 30 patches/09-silence-printf-warnings.patch | 22 patches/10-dosfsck-memsaves.patch | 214 ++++ patches/11-ignore-fs_close-return-value.patch | 13 rules | 97 -- 17 files changed, 1962 insertions(+), 395 deletions(-) diff -Nru dosfstools-2.10/debian/README.Atari dosfstools-2.11/debian/README.Atari --- dosfstools-2.10/debian/README.Atari 2019-04-09 00:25:54.000000000 +0000 +++ dosfstools-2.11/debian/README.Atari 1970-01-01 00:00:00.000000000 +0000 @@ -1,60 +0,0 @@ - -Atari format support -==================== - -Both mkdosfs and dosfsck now can also handle the Atari variation of -the MS-DOS filesystem format. The Atari format has some minor -differences, some caused by the different machine architecture (m68k), -some being "historic" (Atari didn't change some things that M$ -changed). - -Both tools automatically select Atari format if they run on an Atari. -Additionally the -A switch toggles between Atari and MS-DOS format. -I.e., on an Atari it selects plain DOS format, on any other machine it -switches to Atari format. - -The differences are in detail: - - - Atari TOS doesn't like cluster sizes != 2, so the usual solution - for bigger partitions was to increase the logical sector size. So - mkdosfs can handle sector sizes != 512 now, you can also manually - select it with the -S option. On filesystems larger than approx. 32 - MB, the sector size is automatically increased (stead of the - cluster size) to make the filesystem fit. mkdosfs will always use 2 - sectors per cluster (also with the floppy standard configurations), - except when directed otherwise on the command line. - - - From the docs, all values between 0xfff8 and 0xffff in the FAT mark - an end-of-file. However, DOS usually uses 0xfff8 and Atari 0xffff. - This seems to be only an consmetic difference. At least TOS doesn't - complain about 0xffff EOF marks. Don't know what DOS thinks of - 0xfff8 :-) Anyway, both tools use the EOF mark common to the - system (DOS/Atari). - - - Something similar of the bad cluster marks: On Atari the FAT values - 0xfff0 to 0xfff7 are used for this, under DOS only 0xfff7 (the - others can be normal cluster numbers, allowing 7 more clusters :-) - However, both systems usually mark with 0xfff7. Just dosfsck has to - interpret 0xfff0...0xfff7 differently. - - - Some fields in the boot sector are interpreted differently. For - example, Atari has a disk serial number (used to aid disk change - detection) where DOS stores the system name; the 'hidden' field is - 32 bit for DOS, but 16 bit for Atari, and there's no 'total_sect' - field; the 12/16 bit FAT decision is different: it's not based on - the number of clusters, but always FAT12 on floppies and FAT16 on - hard disks. mkdosfs nows about these differences and constructs the - boot sector accordingly. - - - In dosfsck, the boot sector differences also have to known, to not - warn about things that are no error on Atari. In addition, most - Atari formatting tools fill the 'tracks' and 'heads' fields with 0 - for hard disks, because they're meaningless on SCSI disks (Atari - has/had no IDE). Due to this, the check that they should be - non-zero is switched off. - - - Under Atari TOS, some other characters are illegal in filenames: - '<', '>', '|', '"', and ':' are allowed, but all non-ASCII chars - (codes >= 128) are forbidden. - -- Roman diff -Nru dosfstools-2.10/debian/changelog dosfstools-2.11/debian/changelog --- dosfstools-2.10/debian/changelog 2019-04-09 00:25:54.000000000 +0000 +++ dosfstools-2.11/debian/changelog 2008-04-01 11:57:17.000000000 +0000 @@ -1,292 +1,59 @@ -dosfstools (2.10-1) unstable; urgency=low +dosfstools (2.11-0osso9) unstable; urgency=low - * New upstream version: - - dosfsck: various 64-bit fixes and removed some warnings by Michal - Cihar - - mkdosfs: better error message if called without parameters (also - suggested by Michal) - * recompilation removed errno@GLIBC_2.0 symbol; Closes: #168540 - (probably already 2.9-1 did) - - -- Roman Hodek Mon, 22 Sep 2003 22:15:32 +0200 - -dosfstools (2.9-1) unstable; urgency=low - - * New upstream version: - (Closes: #156266, #139198, #152769, #152868, #181196) - - dosfsck: if EOF from stdin, exit with error code - - dosfsck: Fix potential for "Internal error: next_cluster on bad cluster". - - dosfsck: When clearing long file names, don't overwrite the dir - entries with all zeros, but put 0xe5 into the first byte. - Otherwise, some OSes stop reading the directory at that point... - - dosfsck: in statistics printed by -v, fix 32bit overflow in number - of data bytes. - - dosfsck: fix an potential overflow in "too many clusters" check - - dosfsck: fix 64bit problem in fat.c (Debian bug #152769) - - dosfsck: allow FAT size > 32MB. - - dosfsck: allow for only one FAT - - dosfsck: with -v, also check that last sector of the filesystem can - be read (in case a partition is smaller than the fs thinks) - - mkdosfs: add note in manpage that creating bootable filesystems is - not supported. - - mkdosfs: better error message with pointer to -I if target is a - full-disk device. - * debian/control: Added build dependency on debhelper (Closes: #168388) - * debian/control: spelling fix (Closes: #124564) - * debian/control: metion names of tools in description (Closes: #186047) - - -- Roman Hodek Thu, 15 May 2003 20:54:04 +0200 - -dosfstools (2.8-1) unstable; urgency=low - - * New upstream version fixing an endless loop. - (Closes: #87205, #86373, #87590) - - -- Roman Hodek Wed, 28 Feb 2001 17:23:16 +0100 - -dosfstools (2.7-1) unstable; urgency=low - - * New upstream version with various bug fixes. (Closes: #83883) - * Changed maintainer e-mail addr. - - -- Roman Hodek Wed, 14 Feb 2001 12:49:00 +0100 - -dosfstools (2.6-1) unstable; urgency=low - - * New upstream version with various bug fixes. - - -- Roman Hodek Tue, 28 Nov 2000 17:27:35 +0100 - -dosfstools (2.5-1) unstable; urgency=low + * Return 0 despite what fs_close returns. - * New upstream version fixing llseek() on alpha (Closes: #54145) + -- Kimmo Hämäläinen Mon, 31 Mar 2008 16:33:43 +0300 - -- Roman Hodek Fri, 7 Jan 2000 09:26:51 +0100 +dosfstools (2.11-0osso8) unstable; urgency=low -dosfstools (2.4-1) unstable; urgency=low + * Silence printf warnings. Patch from Eero. + * RAM saving patch from Eero. Fixes: NB#80214 - * New upstream version fixing compilation problem on alpha (Closes: #48331) + -- Kimmo Hämäläinen Mon, 10 Mar 2008 10:27:57 +0200 - -- Roman Hodek Tue, 26 Oct 1999 09:38:39 +0200 +dosfstools (2.11-0osso7) unstable; urgency=low -dosfstools (2.3-1) unstable; urgency=low + * Added patches from Debian (2.11-2.3). Fixes: NB#79621 - * New upstream version: - - Manpage fixes. - - Fixed usage message of mkdosfs. - - Fixed compilation on alpha (llseek). - - Fixed unaligned accesses on alpha (Closes: #47714) - - Fixed renaming of files in dosfsck (extension wasn't really - written). Closes: #45774 - * Remove bashisms from debian/rules. - * FHS transition. - * On alpha, omit -O2 and add -fno-strict-aliasing to OPTFLAGS, as - otherwise the programs fail with unaligned traps. - * FHS transition (Standards-Version 3.0.1). + -- Kimmo Hämäläinen Wed, 23 Jan 2008 14:37:27 +0200 - -- Roman Hodek Fri, 22 Oct 1999 13:30:59 +0200 +dosfstools (2.11-0osso6) unstable; urgency=low -dosfstools (2.2-1) unstable; urgency=low + * Trying to fix compilation. - * New upstream version. Closes: #40533 - * Updated copyright file for new location /usr/share/common-licenses/GPL. - * Updated Standards-Version to 3.0.0. + -- Kimmo Hämäläinen Fri, 5 Oct 2007 12:33:43 +0300 - -- Roman Hodek Tue, 6 Jul 1999 16:07:22 +0200 +dosfstools (2.11-0osso5) unstable; urgency=low -dosfstools (2.1-1) unstable; urgency=low + * Added osso_mem* magic, preventing eating all system memory. Fixes: NB#71826 + * Added a limit for the 'Cluster N out of range...' messages. + Fixes: NB#71620 - * New upstream version. - * Also installs symlinks mkfs.vfat and fsck.vfat,so that also - filesystems listed with type "vfat" in /etc/fstab can be automatically - checked. + -- Kimmo Hämäläinen Thu, 04 Oct 2007 10:59:53 +0300 - -- Roman Hodek Fri, 28 May 1999 11:25:17 +0200 +dosfstools (2.11-0osso4) unstable; urgency=low -dosfstools (2.0-1) unstable; urgency=low + * Select backup FAT table in case of selection. + * Added license text to debian/rules. Fixes: NB#70864 - * I'm now upstream maintainer, too. - * Adapted debian/rules for new central Makefile and rewritten to - debhelper. - * Fixed harmless warnings in mkdosfs.c and fat.c. - * mkdosfs.c: Return type of getopt() must be stored in an int, not in a - char. (Showed up on powerpc, where chars are default unsigned.) - - -- Roman Hodek Fri, 30 Apr 1999 14:37:37 +0200 + -- Kimmo Hämäläinen Tue, 25 Sep 2007 11:22:38 +0300 -dosfstools (1.0-16) unstable; urgency=low +dosfstools (2.11-0osso3) unstable; urgency=low - * Both tools are not maintained upstreams anymore, so I take over - general maintainership now... - * Both mkdosfs and dosfsck now support the FAT32 format. dosfsck - automatically detects it. For mkdosfs, 32 is now a valid argument to - -F, but FAT32 format isn't selected automatically (yet). With FAT32, - you can also set the number of reserved sectors (-R) and location of - the boot sector backup (-b) if you like (defaults are reasonable). - * dosfsck can handle and check VFAT-style long filenames now. It uses - the long names in listing etc. when available. There are also some - checks on the structures of LFNs and some fixes for possible problems. - * Implemented Atari format in both, dosfsck and mkdosfs. Under Atari TOS - basically the same FAT format is used as under DOS, however, there are - some little differences. Both tools now automatically select Atari - format if they run on an Atari. You can switch between standard MS-DOS - and Atari format with the -A option. - * Applied patch by Giuliano Procida to add loop - device support to mkdosfs: Usual floppy sizes are detected and - parameters (media byte,...) are set up accordingly. - My own additions to this: Don't die on loop devices that don't have - such a floppy size, but use some default hd params. Added endianess - conversions to Giulianos patch. - * More/better data in boot sector dump of dosfsck -v. - * Fixed lots of gcc warnings in the source. Removed -Wno-parentheses flag. - * Made dosfsck -v a bit more verbose. - * Extended README's for FAT32/LFN. - * Written a README for Atari format differences. - * Some minor cleanups in debian/rules. - * Install README files as README.{mkdosfs,dosfsck,Atari}.gz. - * AFAIK the tools still have alignment problems on Alpha machines. - Someone wanted to send me a patch, but I haven't heard from him for - months... - * Set Standards-Version to 2.5.0.0 (no changes). - - -- Roman Hodek Wed, 28 Apr 1999 11:06:15 +0200 - -dosfstools (1.0-15) frozen unstable; urgency=low - - * Applied patch by Juan Cespedes to make mkdosfs - work with newer 2.1 kernels again. (Fixes: #20320) - * Remove CC=gcc in debian/rules to make cross-compiling possible. - - -- Roman Hodek Thu, 30 Apr 1998 17:09:08 +0200 - -dosfstools (1.0-14) frozen unstable; urgency=medium - - * New maintainer - * Ignore long name directory slots of VFAT, instead of trying to correct - that "file names". Fixes: #20711 - * Don't consider file names with chars >= 128 to be bad, they're allowed. - - -- Roman Hodek Thu, 30 Apr 1998 10:00:16 +0200 - -dosfstools (1.0-13) stable; urgency=low, closes=17389 - - * Fixed nasty bug that caused every file with a name like xxxxxxxx.xxx - to be treated as bad name that needed to be fixed. (closes: Bug#17389) + * Patch for correct logical sector size calculation. + Thanks to Tilman Vogel for reporting the problem. Fixes: MB#1537 - -- Martin Schulze Thu, 26 Feb 1998 01:14:40 +0100 + -- Kimmo Hämäläinen Fri, 15 Jun 2007 12:46:30 +0300 -dosfstools (1.0-12) stable; urgency=low, closes=15037 +dosfstools (2.11-0osso2) unstable; urgency=low - * Moved executables and their links into /sbin (Bug#15037) - * Corrected Standards-Version to 2.3.0.1 + * Added patch for dosfsck to print progress indication. - -- Martin Schulze Fri, 9 Jan 1998 21:49:48 +0100 - -dosfstools (1.0-11) stable; urgency=low, closes=16493 16494 16490 16491 - - * Applied patches to source files from Juan Cespedes which got lost in - the last upload (Bug#16493, Bug#16494, Bug#16490) - * build-stamp is now removed first in clean target (Bug#16491) - - -- Martin Schulze Sat, 3 Jan 1998 15:06:27 +0100 - -dosfstools (1.0-10) stable; urgency=low - - * Added links for mkfs.msdos and fsck.msdos (Bug#15037) - * Added links for mkfs.msdos.8 and fsck.msdos.8 - * Corrected source location - * Rewrote bad_name() (Bug#9871, part 2) - * s/int/time_t in check.c to omit a compiler warning (Bug#9871, part 3.1) - * Modified defaults, interactive is the default now - * Fixed renaming of files, they are saved now (Bug#9871, part 1) - * Fixed return type of date_dos2unix (Bug#9871, part 3.2) - - -- Martin Schulze Wed, 31 Dec 1997 18:59:53 +0100 - -dosfstools (1.0-9.1) unstable; urgency=low - - * Non-maintainer release - * .diff file was wrong in 1.0-9; fixed (Bug#13102) - * Fixed endianess patches (fixes Bug#11648) - * Built with libc6 - - -- Juan Cespedes Thu, 23 Oct 1997 23:19:34 +0200 - -dosfstools (1.0-9) stable; urgency=low - - * Added endianess patches from Frank Neumann - (Bug#9959) - * Updated Werner Almesbergers address - * Added -I switch to mkdosfs to allow full disk devices (Bug#10789) - - -- Martin Schulze Sun, 20 Jul 1997 14:51:33 +0200 - -dosfstools (1.0-8) stable; urgency=low + -- Kimmo Hämäläinen Tue, 08 May 2007 19:46:13 +0300 - * Fixed typo in mkdosfs.c (Bug#7396) +dosfstools (2.11-0osso1) unstable; urgency=low - * New maintainer address - - -- Martin Schulze Mon, 28 Apr 1997 12:51:13 +0200 - -dosfstools (1.0-7) stable; urgency=low - - * Minor fixes + * OSSO-packaged dosfstools (used debian scripts from 2.11-2 for guidance). + * Added patch to mkdosfs to print hash marks for progress indication. - * Converted to Standards-Version 2.1.1.2 - - -- Martin Schulze Sat, 8 Feb 1997 15:03:52 +0100 - -Mon Jan 20 22:45:23 1997 Martin Schulze - - * debian.control: Corrected otherfs to otherosfs :-) - -Sun Jan 19 23:57:09 1997 Martin Schulze - - * mkdosfs.c: Removed one line printing out debug information. - -Wed Jan 15 00:25:02 1997 Martin Schulze - - * mkdosfs.c: Modified code to work properly under AXP. Thanks to - Matt Gundry for contacting me and - providing patched sources. - -Mon Jan 13 13:00:14 1997 Martin Schulze - - * mkdosfs.c: Added patch from Sven Rudolph - to support creation on disk images as well. - -Tue Jan 7 12:04:21 1997 Martin Schulze - - * Moved into section 'otherfs' - --- Released 1.0-4 - -Sun Dec 22 11:28:03 1996 Martin Schulze - - * debian.rules: Installed ChangeLog - -Wed Aug 7 19:07:15 1996 Martin Schulze - - * Corrected debian.rules to provide $(package)_$(revision).diff.gz - -Mon Aug 5 11:13:34 1996 Martin Schulze - - * Added Conflicts: and Provides: entries in control file to really - replace mkdosfs. Thanks to Michael Meskes for reporting this bug. - -Thu Jul 18 22:01:34 1996 Martin Schulze - - * added dosfscheck to the package - -Wed Jul 3 00:57:23 1996 Martin Schulze - - * Added debian specific files - - * mkdosfs.c: inserted some brackets to stop gcc from moaning - - * mkdosfs.8: corrected some bold/inverse text phrases - - * mkdosfs.c: initialized a variable to stop gcc from moaning - - + -- Kimmo Hämäläinen Mon, 20 Nov 2006 18:07:30 +0200 diff -Nru dosfstools-2.10/debian/compat dosfstools-2.11/debian/compat --- dosfstools-2.10/debian/compat 1970-01-01 00:00:00.000000000 +0000 +++ dosfstools-2.11/debian/compat 2007-03-22 16:03:22.000000000 +0000 @@ -0,0 +1 @@ +4 diff -Nru dosfstools-2.10/debian/control dosfstools-2.11/debian/control --- dosfstools-2.10/debian/control 2019-04-09 00:25:54.000000000 +0000 +++ dosfstools-2.11/debian/control 2007-03-22 16:03:22.000000000 +0000 @@ -1,8 +1,8 @@ Source: dosfstools Section: otherosfs Priority: optional -Maintainer: Roman Hodek -Build-Depends: debhelper +Maintainer: Kimmo Hämäläinen +Build-Depends: debhelper, cdbs Standards-Version: 3.0.1 Package: dosfstools diff -Nru dosfstools-2.10/debian/patches/00-dosfstools_2.11-2.3.diff dosfstools-2.11/debian/patches/00-dosfstools_2.11-2.3.diff --- dosfstools-2.10/debian/patches/00-dosfstools_2.11-2.3.diff 1970-01-01 00:00:00.000000000 +0000 +++ dosfstools-2.11/debian/patches/00-dosfstools_2.11-2.3.diff 2008-01-23 12:57:48.000000000 +0000 @@ -0,0 +1,310 @@ +--- dosfstools-2.11.orig/dosfsck/check.c ++++ dosfstools-2.11/dosfsck/check.c +@@ -305,14 +305,14 @@ + static void auto_rename(DOS_FILE *file) + { + DOS_FILE *first,*walk; +- int number; ++ unsigned long int number; + + if (!file->offset) return; /* cannot rename FAT32 root dir */ + first = file->parent ? file->parent->first : root; + number = 0; + while (1) { +- sprintf(file->dir_ent.name,"FSCK%04d",number); +- strncpy(file->dir_ent.ext,"REN",3); ++ sprintf(file->dir_ent.name, "FSCK%04d", number / 1000); ++ sprintf(file->dir_ent.name, "%03d", number % 1000); + for (walk = first; walk; walk = walk->next) + if (walk != file && !strncmp(walk->dir_ent.name,file->dir_ent. + name,MSDOS_NAME)) break; +@@ -321,6 +321,9 @@ + return; + } + number++; ++ if (number > 9999999) { ++ die("Too many files need repair."); ++ } + } + die("Can't generate a unique name."); + } +@@ -450,10 +453,10 @@ + break; + } + if (!(file->dir_ent.attr & ATTR_DIR) && CF_LE_L(file->dir_ent.size) <= +- clusters*fs->cluster_size) { +- printf("%s\n File size is %u bytes, cluster chain length is > %lu " ++ (unsigned long long)clusters*fs->cluster_size) { ++ printf("%s\n File size is %u bytes, cluster chain length is > %llu " + "bytes.\n Truncating file to %u bytes.\n",path_name(file), +- CF_LE_L(file->dir_ent.size),clusters*fs->cluster_size, ++ CF_LE_L(file->dir_ent.size),(unsigned long long)clusters*fs->cluster_size, + CF_LE_L(file->dir_ent.size)); + truncate_file(fs,file,clusters); + break; +@@ -469,20 +472,20 @@ + else clusters2++; + restart = file->dir_ent.attr & ATTR_DIR; + if (!owner->offset) { +- printf( " Truncating second to %lu bytes because first " +- "is FAT32 root dir.\n", clusters2*fs->cluster_size ); ++ printf( " Truncating second to %llu bytes because first " ++ "is FAT32 root dir.\n", (unsigned long long)clusters2*fs->cluster_size ); + do_trunc = 2; + } + else if (!file->offset) { +- printf( " Truncating first to %lu bytes because second " +- "is FAT32 root dir.\n", clusters*fs->cluster_size ); ++ printf( " Truncating first to %llu bytes because second " ++ "is FAT32 root dir.\n", (unsigned long long)clusters*fs->cluster_size ); + do_trunc = 1; + } + else if (interactive) +- printf("1) Truncate first to %lu bytes%s\n" +- "2) Truncate second to %lu bytes\n",clusters*fs->cluster_size, +- restart ? " and restart" : "",clusters2*fs->cluster_size); +- else printf(" Truncating second to %lu bytes.\n",clusters2* ++ printf("1) Truncate first to %llu bytes%s\n" ++ "2) Truncate second to %llu bytes\n",(unsigned long long)clusters*fs->cluster_size, ++ restart ? " and restart" : "",(unsigned long long)clusters2*fs->cluster_size); ++ else printf(" Truncating second to %llu bytes.\n",(unsigned long long)clusters2* + fs->cluster_size); + if (do_trunc != 2 && + (do_trunc == 1 || +@@ -494,12 +497,13 @@ + if (this == curr) { + if (prev) set_fat(fs,prev,-1); + else MODIFY_START(owner,0,fs); +- MODIFY(owner,size,CT_LE_L(clusters*fs->cluster_size)); ++ MODIFY(owner,size,CT_LE_L((unsigned long long)clusters*fs->cluster_size)); + if (restart) return 1; + while (this > 0 && this != -1) { + set_owner(fs,this,NULL); + this = next_cluster(fs,this); + } ++ this = curr; + break; + } + clusters++; +@@ -520,11 +524,11 @@ + prev = curr; + } + if (!(file->dir_ent.attr & ATTR_DIR) && CF_LE_L(file->dir_ent.size) > +- clusters*fs->cluster_size) { +- printf("%s\n File size is %u bytes, cluster chain length is %lu bytes." ++ (unsigned long long)clusters*fs->cluster_size) { ++ printf("%s\n File size is %u bytes, cluster chain length is %llu bytes." + "\n Truncating file to %lu bytes.\n",path_name(file),CF_LE_L(file-> +- dir_ent.size),clusters*fs->cluster_size,clusters*fs->cluster_size); +- MODIFY(file,size,CT_LE_L(clusters*fs->cluster_size)); ++ dir_ent.size),(unsigned long long)clusters*fs->cluster_size,(unsigned long long)clusters*fs->cluster_size); ++ MODIFY(file,size,CT_LE_L((unsigned long long)clusters*fs->cluster_size)); + } + return 0; + } +--- dosfstools-2.11.orig/dosfsck/fat.c ++++ dosfstools-2.11/dosfsck/fat.c +@@ -54,7 +54,7 @@ + void *first,*second,*use; + int first_ok,second_ok; + +- eff_size = ((fs->clusters+2)*fs->fat_bits+7)/8; ++ eff_size = ((fs->clusters+2ULL)*fs->fat_bits+7)/8ULL; + first = alloc(eff_size); + fs_read(fs->fat_start,eff_size,first); + use = first; +@@ -97,7 +97,7 @@ + exit(1); + } + } +- fs->fat = qalloc(&mem_queue,sizeof(FAT_ENTRY)*(fs->clusters+2)); ++ fs->fat = qalloc(&mem_queue,sizeof(FAT_ENTRY)*(fs->clusters+2ULL)); + for (i = 2; i < fs->clusters+2; i++) get_fat(&fs->fat[i],use,i,fs); + for (i = 2; i < fs->clusters+2; i++) + if (fs->fat[i].value >= fs->clusters+2 && +@@ -177,7 +177,7 @@ + + loff_t cluster_start(DOS_FS *fs,unsigned long cluster) + { +- return fs->data_start+((loff_t)cluster-2)*fs->cluster_size; ++ return fs->data_start+((loff_t)cluster-2)*(unsigned long long)fs->cluster_size; + } + + +@@ -225,8 +225,8 @@ + reclaimed++; + } + if (reclaimed) +- printf("Reclaimed %d unused cluster%s (%d bytes).\n",reclaimed, +- reclaimed == 1 ? "" : "s",reclaimed*fs->cluster_size); ++ printf("Reclaimed %d unused cluster%s (%llu bytes).\n",reclaimed, ++ reclaimed == 1 ? "" : "s",(unsigned long long)reclaimed*fs->cluster_size); + } + + +@@ -305,8 +305,8 @@ + fs_write(offset,sizeof(DIR_ENT),&de); + } + if (reclaimed) +- printf("Reclaimed %d unused cluster%s (%d bytes) in %d chain%s.\n", +- reclaimed,reclaimed == 1 ? "" : "s",reclaimed*fs->cluster_size,files, ++ printf("Reclaimed %d unused cluster%s (%llu bytes) in %d chain%s.\n", ++ reclaimed,reclaimed == 1 ? "" : "s",(unsigned long long)reclaimed*fs->cluster_size,files, + files == 1 ? "" : "s"); + } + +--- dosfstools-2.11.orig/mkdosfs/mkdosfs.8 ++++ dosfstools-2.11/mkdosfs/mkdosfs.8 +@@ -79,19 +79,19 @@ + .I block-count + is the number of blocks on the device. If omitted, + .B mkdosfs +-automatically determiness the file system size. ++automatically determines the file system size. + .SH OPTIONS + .TP + .B \-A +-Use Atari variation of the MS-DOS filesystem. This is default if ++Use Atari variation of the MS-DOS file system. This is default if + \fBmkdosfs\fP is run on an Atari, then this option turns off Atari + format. There are some differences when using Atari format: If not + directed otherwise by the user, \fBmkdosfs\fP will always use 2 + sectors per cluster, since GEMDOS doesn't like other values very much. + It will also obey the maximum number of sectors GEMDOS can handle. +-Larger filesystems are managed by raising the logical sector size. ++Larger file systems are managed by raising the logical sector size. + Under Atari format, an Atari-compatible serial number for the +-filesystem is generated, and a 12 bit FAT is used only for filesystems ++file system is generated, and a 12 bit FAT is used only for file systems + that have one of the usual floppy sizes (720k, 1.2M, 1.44M, 2.88M), a + 16 bit FAT otherwise. This can be overridden with the \fB\-F\fP + option. Some PC-specific boot sector fields aren't written, and a boot +@@ -126,7 +126,7 @@ + .BI \-F " FAT-size" + Specifies the type of file allocation tables used (12, 16 or 32 bit). + If nothing is specified, \fBmkdosfs\fR will automatically select +-between 12 and 16 bit, whatever fits better for the filesystem size. ++between 12 and 16 bit, whatever fits better for the file system size. + 32 bit FAT (FAT32 format) must (still) be selected explicitly if you + want it. + .TP +@@ -137,17 +137,17 @@ + \'0\' if no value is given on the command line. + .TP + .I \-i " volume-id" +-Sets the volume ID of the newly created filesystem; ++Sets the volume ID of the newly created file system; + .I volume-id + is a 32-bit hexadecimal number (for example, 2e24ec82). The default +-is a number which depends on the filesystem creation time. ++is a number which depends on the file system creation time. + .TP + .B \-I + Normally you are not allowed to use any 'full' fixed disk devices. + .B mkdosfs + will complain and tell you that it refuses to work. This is different +-when usind MO disks. One doesn't always need partitions on MO disks. +-The filesytem can go directly to the whole disk. Under other OSes ++when using MO disks. One doesn't always need partitions on MO disks. ++The file system can go directly to the whole disk. Under other OSes + this is known as the 'superfloppy' format. + + This switch will force +@@ -159,14 +159,14 @@ + .IR filename . + .TP + .BI \-m " message-file" +-Sets the message the user receives on attempts to boot this filesystem ++Sets the message the user receives on attempts to boot this file system + without having properly installed an operating system. The message + file must not exceed 418 bytes once line feeds have been converted to + carriage return-line feed combinations, and tabs have been expanded. + If the filename is a hyphen (-), the text is taken from standard input. + .TP + .BI \-n " volume-name" +-Sets the volume name (label) of the filesystem. The volume name can ++Sets the volume name (label) of the file system. The volume name can + be up to 11 characters long. The default is no label. + .TP + .BI \-r " root-dir-entries" +@@ -174,7 +174,7 @@ + default is 112 or 224 for floppies and 512 for hard disks. + .TP + .BI \-R " number-of-reserved-sectors " +-Select the number of reserved sectos. With FAT32 format at least 2 ++Select the number of reserved sectors. With FAT32 format at least 2 + reserved sectors are needed, the default is 32. Otherwise the default + is 1 (only the boot sector). + .TP +@@ -191,7 +191,7 @@ + Verbose execution. + .SH BUGS + .B mkdosfs +-can not create bootable filesystems. This isn't as easy as you might ++can not create boot-able file systems. This isn't as easy as you might + think at first glance for various reasons and has been discussed a lot + already. + .B mkdosfs +--- dosfstools-2.11.orig/debian/README.Atari ++++ dosfstools-2.11/debian/README.Atari +@@ -0,0 +1,60 @@ ++ ++Atari format support ++==================== ++ ++Both mkdosfs and dosfsck now can also handle the Atari variation of ++the MS-DOS filesystem format. The Atari format has some minor ++differences, some caused by the different machine architecture (m68k), ++some being "historic" (Atari didn't change some things that M$ ++changed). ++ ++Both tools automatically select Atari format if they run on an Atari. ++Additionally the -A switch toggles between Atari and MS-DOS format. ++I.e., on an Atari it selects plain DOS format, on any other machine it ++switches to Atari format. ++ ++The differences are in detail: ++ ++ - Atari TOS doesn't like cluster sizes != 2, so the usual solution ++ for bigger partitions was to increase the logical sector size. So ++ mkdosfs can handle sector sizes != 512 now, you can also manually ++ select it with the -S option. On filesystems larger than approx. 32 ++ MB, the sector size is automatically increased (stead of the ++ cluster size) to make the filesystem fit. mkdosfs will always use 2 ++ sectors per cluster (also with the floppy standard configurations), ++ except when directed otherwise on the command line. ++ ++ - From the docs, all values between 0xfff8 and 0xffff in the FAT mark ++ an end-of-file. However, DOS usually uses 0xfff8 and Atari 0xffff. ++ This seems to be only an consmetic difference. At least TOS doesn't ++ complain about 0xffff EOF marks. Don't know what DOS thinks of ++ 0xfff8 :-) Anyway, both tools use the EOF mark common to the ++ system (DOS/Atari). ++ ++ - Something similar of the bad cluster marks: On Atari the FAT values ++ 0xfff0 to 0xfff7 are used for this, under DOS only 0xfff7 (the ++ others can be normal cluster numbers, allowing 7 more clusters :-) ++ However, both systems usually mark with 0xfff7. Just dosfsck has to ++ interpret 0xfff0...0xfff7 differently. ++ ++ - Some fields in the boot sector are interpreted differently. For ++ example, Atari has a disk serial number (used to aid disk change ++ detection) where DOS stores the system name; the 'hidden' field is ++ 32 bit for DOS, but 16 bit for Atari, and there's no 'total_sect' ++ field; the 12/16 bit FAT decision is different: it's not based on ++ the number of clusters, but always FAT12 on floppies and FAT16 on ++ hard disks. mkdosfs nows about these differences and constructs the ++ boot sector accordingly. ++ ++ - In dosfsck, the boot sector differences also have to known, to not ++ warn about things that are no error on Atari. In addition, most ++ Atari formatting tools fill the 'tracks' and 'heads' fields with 0 ++ for hard disks, because they're meaningless on SCSI disks (Atari ++ has/had no IDE). Due to this, the check that they should be ++ non-zero is switched off. ++ ++ - Under Atari TOS, some other characters are illegal in filenames: ++ '<', '>', '|', '"', and ':' are allowed, but all non-ASCII chars ++ (codes >= 128) are forbidden. ++ ++- Roman diff -Nru dosfstools-2.10/debian/patches/01-add-tag-to-makefile.patch dosfstools-2.11/debian/patches/01-add-tag-to-makefile.patch --- dosfstools-2.10/debian/patches/01-add-tag-to-makefile.patch 1970-01-01 00:00:00.000000000 +0000 +++ dosfstools-2.11/debian/patches/01-add-tag-to-makefile.patch 2007-03-22 16:03:22.000000000 +0000 @@ -0,0 +1,12 @@ +diff -pur dosfstools-2.11/Makefile dosfstools-2.11.new/Makefile +--- dosfstools-2.11/Makefile 2005-03-12 16:07:01.000000000 +0200 ++++ dosfstools-2.11.new/Makefile 2006-11-20 17:00:05.259942384 +0200 +@@ -10,7 +10,7 @@ DEBUGFLAGS = + CFLAGS = $(OPTFLAGS) $(WARNFLAGS) $(DEBUGFLAGS) + LDFLAGS = + +-PREFIX = ++PREFIX = REPLACE_WITH_PREFIX + SBINDIR = $(PREFIX)/sbin + MANDIR = $(PREFIX)/usr/man/man8 + diff -Nru dosfstools-2.10/debian/patches/02-correct-mandir.patch dosfstools-2.11/debian/patches/02-correct-mandir.patch --- dosfstools-2.10/debian/patches/02-correct-mandir.patch 1970-01-01 00:00:00.000000000 +0000 +++ dosfstools-2.11/debian/patches/02-correct-mandir.patch 2007-03-22 16:03:22.000000000 +0000 @@ -0,0 +1,12 @@ +diff -pur dosfstools-2.11/Makefile dosfstools-2.11.new/Makefile +--- dosfstools-2.11/Makefile 2005-03-12 16:07:01.000000000 +0200 ++++ dosfstools-2.11.new/Makefile 2006-11-20 17:43:39.644495520 +0200 +@@ -12,7 +12,7 @@ LDFLAGS = + + PREFIX = + SBINDIR = $(PREFIX)/sbin +-MANDIR = $(PREFIX)/usr/man/man8 ++MANDIR = $(PREFIX)/usr/share/man/man8 + + .PHONY: clean distclean install depend + .EXPORT_ALL_VARIABLES: diff -Nru dosfstools-2.10/debian/patches/03-print-hash-marks.patch dosfstools-2.11/debian/patches/03-print-hash-marks.patch --- dosfstools-2.10/debian/patches/03-print-hash-marks.patch 1970-01-01 00:00:00.000000000 +0000 +++ dosfstools-2.11/debian/patches/03-print-hash-marks.patch 2007-03-22 16:03:22.000000000 +0000 @@ -0,0 +1,46 @@ +diff -pur dosfstools-2.11/mkdosfs/mkdosfs.c dosfstools-2.11.new/mkdosfs/mkdosfs.c +--- dosfstools-2.11/mkdosfs/mkdosfs.c 2005-03-12 18:12:16.000000000 +0200 ++++ dosfstools-2.11.new/mkdosfs/mkdosfs.c 2006-11-20 17:52:19.995390160 +0200 +@@ -1336,12 +1336,22 @@ write_tables (void) + CF_LE_L(bs.fat32.fat32_length) : CF_LE_W(bs.fat_length); + + seekto( 0, "start of device" ); ++ { ++ /* tell the number of printed hash marks */ ++ char buf[20]; ++ snprintf(buf, 19, "%d\n", reserved_sectors + nr_fats + 3); ++ buf[19] = '\0'; ++ write(STDERR_FILENO, buf, strlen(buf)); ++ } + /* clear all reserved sectors */ +- for( x = 0; x < reserved_sectors; ++x ) ++ for( x = 0; x < reserved_sectors; ++x ) { + writebuf( blank_sector, sector_size, "reserved sector" ); ++ write(STDERR_FILENO, "#", 1); ++ } + /* seek back to sector 0 and write the boot sector */ + seekto( 0, "boot sector" ); + writebuf( (char *) &bs, sizeof (struct msdos_boot_sector), "boot sector" ); ++ write(STDERR_FILENO, "#", 1); + /* on FAT32, write the info sector and backup boot sector */ + if (size_fat == 32) + { +@@ -1354,13 +1364,17 @@ write_tables (void) + "backup boot sector" ); + } + } ++ write(STDERR_FILENO, "#", 1); + /* seek to start of FATS and write them all */ + seekto( reserved_sectors*sector_size, "first FAT" ); +- for (x = 1; x <= nr_fats; x++) ++ for (x = 1; x <= nr_fats; x++) { + writebuf( fat, fat_length * sector_size, "FAT" ); ++ write(STDERR_FILENO, "#", 1); ++ } + /* Write the root directory directly after the last FAT. This is the root + * dir area on FAT12/16, and the first cluster on FAT32. */ + writebuf( (char *) root_dir, size_root_dir, "root directory" ); ++ write(STDERR_FILENO, "#", 1); + + if (blank_sector) free( blank_sector ); + if (info_sector) free( info_sector ); diff -Nru dosfstools-2.10/debian/patches/04-print-dosfsck-progress.patch dosfstools-2.11/debian/patches/04-print-dosfsck-progress.patch --- dosfstools-2.10/debian/patches/04-print-dosfsck-progress.patch 1970-01-01 00:00:00.000000000 +0000 +++ dosfstools-2.11/debian/patches/04-print-dosfsck-progress.patch 2007-04-23 13:02:02.000000000 +0000 @@ -0,0 +1,56 @@ +diff -pur dosfstools-2.11/dosfsck/check.c dosfstools-2.11.new/dosfsck/check.c +--- dosfstools-2.11/dosfsck/check.c 2005-03-12 17:08:43.000000000 +0200 ++++ dosfstools-2.11.new/dosfsck/check.c 2007-04-18 17:36:27.000000000 +0300 +@@ -21,6 +21,10 @@ + #include "check.h" + + ++extern unsigned long checked_clusters; ++extern unsigned long cluster_step; ++extern unsigned long last_print_cluster; ++ + static DOS_FILE *root; + + /* get start field of a dir entry */ +@@ -440,6 +444,11 @@ static int check_file(DOS_FS *fs,DOS_FIL + clusters = prev = 0; + for (curr = FSTART(file,fs) ? FSTART(file,fs) : + -1; curr != -1; curr = next_cluster(fs,curr)) { ++ ++checked_clusters; ++ if (checked_clusters > last_print_cluster + cluster_step) { ++ last_print_cluster = checked_clusters; ++ fprintf(stderr, "%lu\n", checked_clusters); ++ } + if (!fs->fat[curr].value || bad_cluster(fs,curr)) { + printf("%s\n Contains a %s cluster (%lu). Assuming EOF.\n", + path_name(file),fs->fat[curr].value ? "bad" : "free",curr); +diff -pur dosfstools-2.11/dosfsck/dosfsck.c dosfstools-2.11.new/dosfsck/dosfsck.c +--- dosfstools-2.11/dosfsck/dosfsck.c 2004-02-25 21:28:57.000000000 +0200 ++++ dosfstools-2.11.new/dosfsck/dosfsck.c 2007-04-23 16:00:34.395427320 +0300 +@@ -28,6 +28,9 @@ int interactive = 0,list = 0,test = 0,ve + int atari_format = 0; + unsigned n_files = 0; + void *mem_queue = NULL; ++unsigned long checked_clusters = 0; ++unsigned long cluster_step = 0; ++unsigned long last_print_cluster = 0; + + + static void usage(char *name) +@@ -146,6 +149,8 @@ int main(int argc,char **argv) + printf( "dosfsck " VERSION ", " VERSION_DATE ", FAT32, LFN\n" ); + fs_open(argv[optind],rw); + read_boot(&fs); ++ fprintf(stderr, "alleged total clusters: %lu\n", fs.clusters); ++ cluster_step = fs.clusters / 100; + if (verify) printf("Starting check/repair pass.\n"); + while (read_fat(&fs), scan_root(&fs)) qfree(&mem_queue); + if (test) fix_bad(&fs); +@@ -161,6 +166,7 @@ int main(int argc,char **argv) + reclaim_free(&fs); + qfree(&mem_queue); + } ++ printf("checked clusters: %lu\n", checked_clusters); + + if (fs_changed()) { + if (rw) { diff -Nru dosfstools-2.10/debian/patches/05-fix-logical-sector-calc.patch dosfstools-2.11/debian/patches/05-fix-logical-sector-calc.patch --- dosfstools-2.10/debian/patches/05-fix-logical-sector-calc.patch 1970-01-01 00:00:00.000000000 +0000 +++ dosfstools-2.11/debian/patches/05-fix-logical-sector-calc.patch 2007-06-15 09:59:55.000000000 +0000 @@ -0,0 +1,20 @@ +diff -pur dosfstools-2.11/dosfsck/boot.c dosfstools-2.11.new/dosfsck/boot.c +--- dosfstools-2.11/dosfsck/boot.c 2005-03-12 16:16:22.000000000 +0200 ++++ dosfstools-2.11.new/dosfsck/boot.c 2007-06-15 12:59:21.897962824 +0300 +@@ -34,13 +34,13 @@ static struct { + { 0xff, "5.25\" 320k floppy 2s/40tr/8sec" }, + }; + +-#if defined __alpha || defined __ia64__ || defined __s390x__ || defined __x86_64__ || defined __ppc64__ ++#if defined __alpha || defined __ia64__ || defined __s390x__ || defined __x86_64__ || defined __ppc64__ || __arm__ + /* Unaligned fields must first be copied byte-wise */ + #define GET_UNALIGNED_W(f) \ + ({ \ + unsigned short __v; \ + memcpy( &__v, &f, sizeof(__v) ); \ +- CF_LE_W( *(unsigned short *)&f ); \ ++ CF_LE_W( *(unsigned short *)&__v ); \ + }) + #else + #define GET_UNALIGNED_W(f) CF_LE_W( *(unsigned short *)&f ) +Only in dosfstools-2.11.new/dosfsck: boot.c~ diff -Nru dosfstools-2.10/debian/patches/06-always-select-backup-fat-table.patch dosfstools-2.11/debian/patches/06-always-select-backup-fat-table.patch --- dosfstools-2.10/debian/patches/06-always-select-backup-fat-table.patch 1970-01-01 00:00:00.000000000 +0000 +++ dosfstools-2.11/debian/patches/06-always-select-backup-fat-table.patch 2007-09-25 08:24:33.000000000 +0000 @@ -0,0 +1,27 @@ +diff -pur dosfstools-2.11/dosfsck/boot.c dosfstools-2.11.new/dosfsck/boot.c +--- dosfstools-2.11/dosfsck/boot.c 2005-03-12 16:16:22.000000000 +0200 ++++ dosfstools-2.11.new/dosfsck/boot.c 2007-09-25 11:20:27.400448840 +0300 +@@ -171,21 +171,8 @@ static void check_backup_boot(DOS_FS *fs + } + printf( "\n" ); + +- if (interactive) +- printf( "1) Copy original to backup\n" +- "2) Copy backup to original\n" +- "3) No action\n" ); +- else printf( " Not automatically fixing this.\n" ); +- switch (interactive ? get_key("123","?") : '3') { +- case '1': +- fs_write(fs->backupboot_start,sizeof(*b),b); +- break; +- case '2': +- fs_write(0,sizeof(b2),&b2); +- break; +- default: +- break; +- } ++ printf("Copying backup to original\n"); ++ fs_write(0,sizeof(b2),&b2); + } + } + diff -Nru dosfstools-2.10/debian/patches/07-use-osso-mem.patch dosfstools-2.11/debian/patches/07-use-osso-mem.patch --- dosfstools-2.10/debian/patches/07-use-osso-mem.patch 1970-01-01 00:00:00.000000000 +0000 +++ dosfstools-2.11/debian/patches/07-use-osso-mem.patch 2007-10-05 09:31:30.000000000 +0000 @@ -0,0 +1,1134 @@ +diff -purN dosfstools-2.11/dosfsck/Makefile dosfstools-2.11.new/dosfsck/Makefile +--- dosfstools-2.11/dosfsck/Makefile 1999-07-06 17:23:11.000000000 +0300 ++++ dosfstools-2.11.new/dosfsck/Makefile 2007-10-05 12:28:43.104932184 +0300 +@@ -1,5 +1,5 @@ + +-OBJECTS = boot.o check.o common.o dosfsck.o fat.o file.o io.o lfn.o ++OBJECTS = boot.o check.o common.o dosfsck.o fat.o file.o io.o lfn.o osso-mem.o + + all: dosfsck + +@@ -42,3 +42,4 @@ fat.o: fat.c common.h dosfsck.h io.h che + file.o: file.c common.h file.h + io.o: io.c dosfsck.h common.h io.h + lfn.o: lfn.c common.h io.h dosfsck.h lfn.h file.h ++osso-mem.o: osso-mem.c osso-mem.h osso-log.h +diff -purN dosfstools-2.11/dosfsck/dosfsck.c dosfstools-2.11.new/dosfsck/dosfsck.c +--- dosfstools-2.11/dosfsck/dosfsck.c 2004-02-25 21:28:57.000000000 +0200 ++++ dosfstools-2.11.new/dosfsck/dosfsck.c 2007-10-05 12:28:43.104932184 +0300 +@@ -22,6 +22,7 @@ + #include "fat.h" + #include "file.h" + #include "check.h" ++#include "osso-mem.h" + + + int interactive = 0,list = 0,test = 0,verbose = 0,write_immed = 0; +@@ -47,6 +48,7 @@ static void usage(char *name) + fprintf(stderr," -V perform a verification pass\n"); + fprintf(stderr," -w write changes to disk immediately\n"); + fprintf(stderr," -y same as -a, for compat with other *fsck\n"); ++ fprintf(stderr," -m Maemo addition: MBs to spare in the system (default 30)\n"); + exit(2); + } + +@@ -85,12 +87,13 @@ int main(int argc,char **argv) + DOS_FS fs; + int rw,salvage_files,verify,c; + unsigned long free_clusters; +- ++ int megs_to_spare = 30; ++ + rw = salvage_files = verify = 0; + interactive = 1; + check_atari(); + +- while ((c = getopt(argc,argv,"Aad:flnrtu:vVwy")) != EOF) ++ while ((c = getopt(argc,argv,"Aad:flnrtu:vVwym:")) != EOF) + switch (c) { + case 'A': /* toggle Atari format */ + atari_format = !atari_format; +@@ -110,6 +113,9 @@ int main(int argc,char **argv) + case 'l': + list = 1; + break; ++ case 'm': ++ megs_to_spare = atoi(optarg); ++ break; + case 'n': + rw = 0; + interactive = 0; +@@ -143,6 +149,11 @@ int main(int argc,char **argv) + } + if (optind != argc-1) usage(argv[0]); + ++ if (osso_mem_saw_enable(1024 * 1024 * megs_to_spare, 0, NULL, NULL)) { ++ printf("osso_mem_saw_enable failed\n"); ++ return 1; ++ } ++ + printf( "dosfsck " VERSION ", " VERSION_DATE ", FAT32, LFN\n" ); + fs_open(argv[optind],rw); + read_boot(&fs); +diff -purN dosfstools-2.11/dosfsck/osso-log.h dosfstools-2.11.new/dosfsck/osso-log.h +--- dosfstools-2.11/dosfsck/osso-log.h 1970-01-01 02:00:00.000000000 +0200 ++++ dosfstools-2.11.new/dosfsck/osso-log.h 2007-10-05 12:28:43.105932032 +0300 +@@ -0,0 +1,290 @@ ++/** ++ @file osso-log.h ++ The OSSO logging macros. Version: 20 Mar 2005. ++

++ Macro definitions that have an effect to the logging macros: ++ ++ DEBUG, OSSOLOG_COMPILE Whether to compile the macros ++ (prefer OSSOLOG_COMPILE over DEBUG) ++ OSSOLOG_STDOUT All logging to stdout(* ++ OSSOLOG_STDERR All logging to stderr(* ++ ++ *) No timestamp nor file name. ++ ++ To see the logging output of D-Bus-activated programs, define ++ DBUS_DEBUG_OUTPUT environment variable for the D-Bus daemon and ++ define the OSSOLOG_STDERR macro at compile time. ++ ++ Note that these macros are provided because Glib logging does not ++ currently allow stripping the logging function calls away at ++ compile time. ++ ++ --- ++ ++ This file is part of libosso. ++ ++ Copyright (C) 2004-2005 Nokia Corporation. All rights reserved. ++ ++ Contact: Kimmo Hämäläinen ++ ++ This library is free software; you can redistribute it and/or ++ modify it under the terms of the GNU Lesser General Public License ++ version 2.1 as published by the Free Software Foundation. ++ ++ This library 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 ++ Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with this library; if not, write to the Free Software ++ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA ++ 02110-1301 USA ++*/ ++ ++#ifndef OSSO_LOG_H ++#define OSSO_LOG_H ++ ++#ifdef DEBUG ++#define OSSOLOG_COMPILE ++#endif ++ ++#ifdef OSSOLOG_COMPILE ++#if defined OSSOLOG_STDOUT || defined OSSOLOG_STDERR ++#include /* printf(), fprintf() */ ++#else ++#include /* syslog(), openlog(), closelog() */ ++#endif ++#endif ++ ++/*** the macros ***/ ++ ++#ifdef OSSOLOG_COMPILE ++ ++/* the binary has logging compiled in */ ++ ++#if !defined OSSOLOG_STDOUT && !defined OSSOLOG_STDERR ++ ++/* log to the syslog */ ++ ++#define ULOG_CRIT(...) syslog(LOG_CRIT | LOG_USER, __VA_ARGS__) ++#define ULOG_ERR(...) syslog(LOG_ERR | LOG_USER, __VA_ARGS__) ++#define ULOG_WARN(...) syslog(LOG_WARNING | LOG_USER, __VA_ARGS__) ++#define ULOG_INFO(...) syslog(LOG_INFO | LOG_USER, __VA_ARGS__) ++#define ULOG_DEBUG(...) syslog(LOG_DEBUG | LOG_USER, __VA_ARGS__) ++#define ULOG_CRIT_L(FMT, ARG...) syslog(LOG_CRIT | LOG_USER, \ ++ "%s:%d: " FMT, __FILE__, __LINE__, ## ARG) ++#define ULOG_ERR_L(FMT, ARG...) syslog(LOG_ERR | LOG_USER, \ ++ "%s:%d: " FMT, __FILE__, __LINE__, ## ARG) ++#define ULOG_WARN_L(FMT, ARG...) syslog(LOG_WARNING | LOG_USER, \ ++ "%s:%d: " FMT, __FILE__, __LINE__, ## ARG) ++#define ULOG_INFO_L(FMT, ARG...) syslog(LOG_INFO | LOG_USER, \ ++ "%s:%d: " FMT, __FILE__, __LINE__, ## ARG) ++#define ULOG_DEBUG_L(FMT, ARG...) syslog(LOG_DEBUG | LOG_USER, \ ++ "%s:%d: " FMT, __FILE__, __LINE__, ## ARG) ++#define ULOG_CRIT_F(FMT, ARG...) syslog(LOG_CRIT | LOG_USER, \ ++ "%s:%d: " FMT, __FUNCTION__, __LINE__, ## ARG) ++#define ULOG_ERR_F(FMT, ARG...) syslog(LOG_ERR | LOG_USER, \ ++ "%s:%d: " FMT, __FUNCTION__, __LINE__, ## ARG) ++#define ULOG_WARN_F(FMT, ARG...) syslog(LOG_WARNING | LOG_USER, \ ++ "%s:%d: " FMT, __FUNCTION__, __LINE__, ## ARG) ++#define ULOG_INFO_F(FMT, ARG...) syslog(LOG_INFO | LOG_USER, \ ++ "%s:%d: " FMT, __FUNCTION__, __LINE__, ## ARG) ++#define ULOG_DEBUG_F(FMT, ARG...) syslog(LOG_DEBUG | LOG_USER, \ ++ "%s:%d: " FMT, __FUNCTION__, __LINE__, ## ARG) ++ ++#define DLOG_CRIT(...) syslog(LOG_CRIT | LOG_DAEMON, __VA_ARGS__) ++#define DLOG_ERR(...) syslog(LOG_ERR | LOG_DAEMON, __VA_ARGS__) ++#define DLOG_WARN(...) syslog(LOG_WARNING | LOG_DAEMON, __VA_ARGS__) ++#define DLOG_INFO(...) syslog(LOG_INFO | LOG_DAEMON, __VA_ARGS__) ++#define DLOG_DEBUG(...) syslog(LOG_DEBUG | LOG_DAEMON, __VA_ARGS__) ++#define DLOG_CRIT_L(FMT, ARG...) syslog(LOG_CRIT | LOG_DAEMON, \ ++ "%s:%d: " FMT, __FILE__, __LINE__, ## ARG) ++#define DLOG_ERR_L(FMT, ARG...) syslog(LOG_ERR | LOG_DAEMON, \ ++ "%s:%d: " FMT, __FILE__, __LINE__, ## ARG) ++#define DLOG_WARN_L(FMT, ARG...) syslog(LOG_WARNING | LOG_DAEMON, \ ++ "%s:%d: " FMT, __FILE__, __LINE__, ## ARG) ++#define DLOG_INFO_L(FMT, ARG...) syslog(LOG_INFO | LOG_DAEMON, \ ++ "%s:%d: " FMT, __FILE__, __LINE__, ## ARG) ++#define DLOG_DEBUG_L(FMT, ARG...) syslog(LOG_DEBUG | LOG_DAEMON, \ ++ "%s:%d: " FMT, __FILE__, __LINE__, ## ARG) ++#define DLOG_CRIT_F(FMT, ARG...) syslog(LOG_CRIT | LOG_DAEMON, \ ++ "%s:%d: " FMT, __FUNCTION__, __LINE__, ## ARG) ++#define DLOG_ERR_F(FMT, ARG...) syslog(LOG_ERR | LOG_DAEMON, \ ++ "%s:%d: " FMT, __FUNCTION__, __LINE__, ## ARG) ++#define DLOG_WARN_F(FMT, ARG...) syslog(LOG_WARNING | LOG_DAEMON, \ ++ "%s:%d: " FMT, __FUNCTION__, __LINE__, ## ARG) ++#define DLOG_INFO_F(FMT, ARG...) syslog(LOG_INFO | LOG_DAEMON, \ ++ "%s:%d: " FMT, __FUNCTION__, __LINE__, ## ARG) ++#define DLOG_DEBUG_F(FMT, ARG...) syslog(LOG_DEBUG | LOG_DAEMON, \ ++ "%s:%d: " FMT, __FUNCTION__, __LINE__, ## ARG) ++ ++#define ULOG_OPEN(X) openlog(X, LOG_PID | LOG_NDELAY, LOG_USER) ++#define DLOG_OPEN(X) openlog(X, LOG_PID | LOG_NDELAY, LOG_DAEMON) ++#define LOG_CLOSE() closelog() ++ ++#elif defined OSSOLOG_STDOUT ++ ++/* log to the stdout */ ++ ++#define ULOG_CRIT(...) (printf(__VA_ARGS__),printf("\n")) ++#define ULOG_ERR(...) (printf(__VA_ARGS__),printf("\n")) ++#define ULOG_WARN(...) (printf(__VA_ARGS__),printf("\n")) ++#define ULOG_INFO(...) (printf(__VA_ARGS__),printf("\n")) ++#define ULOG_DEBUG(...) (printf(__VA_ARGS__),printf("\n")) ++#define ULOG_CRIT_L(FMT, ARG...) printf(\ ++ "%s:%d: " FMT "\n", __FILE__, __LINE__, ## ARG) ++#define ULOG_ERR_L(FMT, ARG...) printf(\ ++ "%s:%d: " FMT "\n", __FILE__, __LINE__, ## ARG) ++#define ULOG_WARN_L(FMT, ARG...) printf(\ ++ "%s:%d: " FMT "\n", __FILE__, __LINE__, ## ARG) ++#define ULOG_INFO_L(FMT, ARG...) printf(\ ++ "%s:%d: " FMT "\n", __FILE__, __LINE__, ## ARG) ++#define ULOG_DEBUG_L(FMT, ARG...) printf(\ ++ "%s:%d: " FMT "\n", __FILE__, __LINE__, ## ARG) ++#define ULOG_CRIT_F(FMT, ARG...) printf(\ ++ "%s:%d: " FMT "\n", __FUNCTION__, __LINE__, ## ARG) ++#define ULOG_ERR_F(FMT, ARG...) printf(\ ++ "%s:%d: " FMT "\n", __FUNCTION__, __LINE__, ## ARG) ++#define ULOG_WARN_F(FMT, ARG...) printf(\ ++ "%s:%d: " FMT "\n", __FUNCTION__, __LINE__, ## ARG) ++#define ULOG_INFO_F(FMT, ARG...) printf(\ ++ "%s:%d: " FMT "\n", __FUNCTION__, __LINE__, ## ARG) ++#define ULOG_DEBUG_F(FMT, ARG...) printf(\ ++ "%s:%d: " FMT "\n", __FUNCTION__, __LINE__, ## ARG) ++ ++#define DLOG_CRIT(...) (printf(__VA_ARGS__),printf("\n")) ++#define DLOG_ERR(...) (printf(__VA_ARGS__),printf("\n")) ++#define DLOG_WARN(...) (printf(__VA_ARGS__),printf("\n")) ++#define DLOG_INFO(...) (printf(__VA_ARGS__),printf("\n")) ++#define DLOG_DEBUG(...) (printf(__VA_ARGS__),printf("\n")) ++#define DLOG_CRIT_L(FMT, ARG...) printf(\ ++ "%s:%d: " FMT "\n", __FILE__, __LINE__, ## ARG) ++#define DLOG_ERR_L(FMT, ARG...) printf(\ ++ "%s:%d: " FMT "\n", __FILE__, __LINE__, ## ARG) ++#define DLOG_WARN_L(FMT, ARG...) printf(\ ++ "%s:%d: " FMT "\n", __FILE__, __LINE__, ## ARG) ++#define DLOG_INFO_L(FMT, ARG...) printf(\ ++ "%s:%d: " FMT "\n", __FILE__, __LINE__, ## ARG) ++#define DLOG_DEBUG_L(FMT, ARG...) printf(\ ++ "%s:%d: " FMT "\n", __FILE__, __LINE__, ## ARG) ++#define DLOG_CRIT_F(FMT, ARG...) printf(\ ++ "%s:%d: " FMT "\n", __FUNCTION__, __LINE__, ## ARG) ++#define DLOG_ERR_F(FMT, ARG...) printf(\ ++ "%s:%d: " FMT "\n", __FUNCTION__, __LINE__, ## ARG) ++#define DLOG_WARN_F(FMT, ARG...) printf(\ ++ "%s:%d: " FMT "\n", __FUNCTION__, __LINE__, ## ARG) ++#define DLOG_INFO_F(FMT, ARG...) printf(\ ++ "%s:%d: " FMT "\n", __FUNCTION__, __LINE__, ## ARG) ++#define DLOG_DEBUG_F(FMT, ARG...) printf(\ ++ "%s:%d: " FMT "\n", __FUNCTION__, __LINE__, ## ARG) ++ ++#define ULOG_OPEN(X) do {} while (0) ++#define DLOG_OPEN(X) do {} while (0) ++#define LOG_CLOSE() do {} while (0) ++ ++#else ++ ++/* log to the stderr */ ++ ++#define ULOG_CRIT(...) (fprintf(stderr, __VA_ARGS__),fprintf(stderr, "\n")) ++#define ULOG_ERR(...) (fprintf(stderr, __VA_ARGS__),fprintf(stderr, "\n")) ++#define ULOG_WARN(...) (fprintf(stderr, __VA_ARGS__),fprintf(stderr, "\n")) ++#define ULOG_INFO(...) (fprintf(stderr, __VA_ARGS__),fprintf(stderr, "\n")) ++#define ULOG_DEBUG(...) (fprintf(stderr, __VA_ARGS__),fprintf(stderr, "\n")) ++#define ULOG_CRIT_L(FMT, ARG...) fprintf(stderr, \ ++ "%s:%d: " FMT "\n", __FILE__, __LINE__, ## ARG) ++#define ULOG_ERR_L(FMT, ARG...) fprintf(stderr, \ ++ "%s:%d: " FMT "\n", __FILE__, __LINE__, ## ARG) ++#define ULOG_WARN_L(FMT, ARG...) fprintf(stderr, \ ++ "%s:%d: " FMT "\n", __FILE__, __LINE__, ## ARG) ++#define ULOG_INFO_L(FMT, ARG...) fprintf(stderr, \ ++ "%s:%d: " FMT "\n", __FILE__, __LINE__, ## ARG) ++#define ULOG_DEBUG_L(FMT, ARG...) fprintf(stderr, \ ++ "%s:%d: " FMT "\n", __FILE__, __LINE__, ## ARG) ++#define ULOG_CRIT_F(FMT, ARG...) fprintf(stderr, \ ++ "%s:%d: " FMT "\n", __FUNCTION__, __LINE__, ## ARG) ++#define ULOG_ERR_F(FMT, ARG...) fprintf(stderr, \ ++ "%s:%d: " FMT "\n", __FUNCTION__, __LINE__, ## ARG) ++#define ULOG_WARN_F(FMT, ARG...) fprintf(stderr, \ ++ "%s:%d: " FMT "\n", __FUNCTION__, __LINE__, ## ARG) ++#define ULOG_INFO_F(FMT, ARG...) fprintf(stderr, \ ++ "%s:%d: " FMT "\n", __FUNCTION__, __LINE__, ## ARG) ++#define ULOG_DEBUG_F(FMT, ARG...) fprintf(stderr, \ ++ "%s:%d: " FMT "\n", __FUNCTION__, __LINE__, ## ARG) ++ ++#define DLOG_CRIT(...) (fprintf(stderr, __VA_ARGS__),fprintf(stderr, "\n")) ++#define DLOG_ERR(...) (fprintf(stderr, __VA_ARGS__),fprintf(stderr, "\n")) ++#define DLOG_WARN(...) (fprintf(stderr, __VA_ARGS__),fprintf(stderr, "\n")) ++#define DLOG_INFO(...) (fprintf(stderr, __VA_ARGS__),fprintf(stderr, "\n")) ++#define DLOG_DEBUG(...) (fprintf(stderr, __VA_ARGS__),fprintf(stderr, "\n")) ++#define DLOG_CRIT_L(FMT, ARG...) fprintf(stderr, \ ++ "%s:%d: " FMT "\n", __FILE__, __LINE__, ## ARG) ++#define DLOG_ERR_L(FMT, ARG...) fprintf(stderr, \ ++ "%s:%d: " FMT "\n", __FILE__, __LINE__, ## ARG) ++#define DLOG_WARN_L(FMT, ARG...) fprintf(stderr, \ ++ "%s:%d: " FMT "\n", __FILE__, __LINE__, ## ARG) ++#define DLOG_INFO_L(FMT, ARG...) fprintf(stderr, \ ++ "%s:%d: " FMT "\n", __FILE__, __LINE__, ## ARG) ++#define DLOG_DEBUG_L(FMT, ARG...) fprintf(stderr, \ ++ "%s:%d: " FMT "\n", __FILE__, __LINE__, ## ARG) ++#define DLOG_CRIT_F(FMT, ARG...) fprintf(stderr, \ ++ "%s:%d: " FMT "\n", __FUNCTION__, __LINE__, ## ARG) ++#define DLOG_ERR_F(FMT, ARG...) fprintf(stderr, \ ++ "%s:%d: " FMT "\n", __FUNCTION__, __LINE__, ## ARG) ++#define DLOG_WARN_F(FMT, ARG...) fprintf(stderr, \ ++ "%s:%d: " FMT "\n", __FUNCTION__, __LINE__, ## ARG) ++#define DLOG_INFO_F(FMT, ARG...) fprintf(stderr, \ ++ "%s:%d: " FMT "\n", __FUNCTION__, __LINE__, ## ARG) ++#define DLOG_DEBUG_F(FMT, ARG...) fprintf(stderr, \ ++ "%s:%d: " FMT "\n", __FUNCTION__, __LINE__, ## ARG) ++ ++#define ULOG_OPEN(X) do {} while (0) ++#define DLOG_OPEN(X) do {} while (0) ++#define LOG_CLOSE() do {} while (0) ++ ++#endif /* !defined OSSOLOG_STDOUT && !defined OSSOLOG_STDERR */ ++ ++#else ++ ++/* no logging is compiled to the binary */ ++ ++#define ULOG_CRIT(...) do {} while (0) ++#define ULOG_ERR(...) do {} while (0) ++#define ULOG_WARN(...) do {} while (0) ++#define ULOG_INFO(...) do {} while (0) ++#define ULOG_DEBUG(...) do {} while (0) ++#define ULOG_CRIT_L(...) do {} while (0) ++#define ULOG_ERR_L(...) do {} while (0) ++#define ULOG_WARN_L(...) do {} while (0) ++#define ULOG_INFO_L(...) do {} while (0) ++#define ULOG_DEBUG_L(...) do {} while (0) ++#define ULOG_CRIT_F(...) do {} while (0) ++#define ULOG_ERR_F(...) do {} while (0) ++#define ULOG_WARN_F(...) do {} while (0) ++#define ULOG_INFO_F(...) do {} while (0) ++#define ULOG_DEBUG_F(...) do {} while (0) ++ ++#define DLOG_CRIT(...) do {} while (0) ++#define DLOG_ERR(...) do {} while (0) ++#define DLOG_WARN(...) do {} while (0) ++#define DLOG_INFO(...) do {} while (0) ++#define DLOG_DEBUG(...) do {} while (0) ++#define DLOG_CRIT_L(...) do {} while (0) ++#define DLOG_ERR_L(...) do {} while (0) ++#define DLOG_WARN_L(...) do {} while (0) ++#define DLOG_INFO_L(...) do {} while (0) ++#define DLOG_DEBUG_L(...) do {} while (0) ++#define DLOG_CRIT_F(...) do {} while (0) ++#define DLOG_ERR_F(...) do {} while (0) ++#define DLOG_WARN_F(...) do {} while (0) ++#define DLOG_INFO_F(...) do {} while (0) ++#define DLOG_DEBUG_F(...) do {} while (0) ++ ++#define ULOG_OPEN(X) do {} while (0) ++#define DLOG_OPEN(X) do {} while (0) ++#define LOG_CLOSE() do {} while (0) ++ ++#endif /* OSSOLOG_COMPILE */ ++ ++#endif /* OSSO_LOG_H */ +diff -purN dosfstools-2.11/dosfsck/osso-mem.c dosfstools-2.11.new/dosfsck/osso-mem.c +--- dosfstools-2.11/dosfsck/osso-mem.c 1970-01-01 02:00:00.000000000 +0200 ++++ dosfstools-2.11.new/dosfsck/osso-mem.c 2007-10-05 12:29:13.578299528 +0300 +@@ -0,0 +1,609 @@ ++/* ========================================================================= * ++ * File: osso-mem.c ++ * ++ * This file is part of libosso ++ * ++ * Copyright (C) 2005-2006 Nokia Corporation. All rights reserved. ++ * ++ * Contact: Leonid Moiseichuk ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public License ++ * version 2.1 as published by the Free Software Foundation. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA ++ * 02110-1301 USA ++ */ ++ ++/* ========================================================================= * ++ * Includes ++ * ========================================================================= */ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#include "osso-log.h" ++#include "osso-mem.h" ++ ++ ++/* ========================================================================= * ++ * Definitions. ++ * ========================================================================= */ ++ ++/* Compile-time array capacity calculation */ ++#define CAPACITY(a) (sizeof(a) / sizeof(*a)) ++ ++/* Correct division of 2 unsigned values */ ++#define DIVIDE(a,b) (((a) + ((b) >> 1)) / (b)) ++ ++#define NSIZE ((size_t)(-1)) ++ ++typedef void* (*malloc_hook_t)(size_t, const void*); ++ ++ ++/* ========================================================================= * ++ * Meminfo related strings. ++ * WARNING: be careful, micro-optimizations here made code a bit fuzzy. ++ * ========================================================================= */ ++ ++/* Defining the labels we could read from the /proc/meminfo */ ++/* Done in a little tricky way to have strlen's calculated @ compile time */ ++#define MEMINFO_LABELS \ ++ IV_PAIR(ID_MEMTOTAL, "MemTotal:" ) \ ++ IV_PAIR(ID_SWAPTOTAL, "SwapTotal:") \ ++ IV_PAIR(ID_MEMFREE, "MemFree:" ) \ ++ IV_PAIR(ID_BUFFERS, "Buffers:" ) \ ++ IV_PAIR(ID_CACHED, "Cached:" ) \ ++ IV_PAIR(ID_SWAPFREE, "SwapFree:" ) ++ ++/* Definition of specially labeled string */ ++/* WARNING: re-defined below !!! */ ++#define IV_PAIR(ID,STRING) \ ++ static const char _localstring_##ID[]=STRING; ++ ++/* Introduce labeled strings */ ++MEMINFO_LABELS ++ ++/* Re-defining pair as a */ ++#undef IV_PAIR ++#define IV_PAIR(ID,STRING) \ ++ { _localstring_##ID, CAPACITY(_localstring_##ID) -1 }, ++ ++/* Introduce array of strings and sizes */ ++static const struct ++{ ++ const char* name; ++ unsigned length; ++} meminfo_labels[] = ++{ ++ MEMINFO_LABELS ++}; ++ ++/* Re-defining one more time to have IDs for conveinience */ ++#undef IV_PAIR ++#define IV_PAIR(ID,STRING) ID, ++ ++enum ++{ ++ MEMINFO_LABELS ++ MAX_MEMINFO_LABELS ++}; ++ ++#undef IV_PAIR ++ ++/* Initializer for values array (load_meminfo)*/ ++#define IV_PAIR(ID,STRING) 0, ++#define MEMINFO_INIT MEMINFO_LABELS ++ ++ ++/* ========================================================================= * ++ * Local data. ++ * ========================================================================= */ ++ ++/* For lowmem_ functions system limits */ ++static size_t sys_avail_memory = NSIZE; ++static size_t sys_deny_limit = NSIZE; ++static size_t sys_lowmem_limit = NSIZE; ++ ++/* SAW-related */ ++static pthread_mutex_t saw_lock = PTHREAD_MUTEX_INITIALIZER; ++ ++#define THREAD_LOCK() pthread_mutex_lock(&saw_lock) ++#define THREAD_UNLOCK() pthread_mutex_unlock(&saw_lock) ++ ++/* Parameters of the latest SAW setup call */ ++static size_t saw_max_block_size; /* If allocation is greater - make a test */ ++static size_t saw_max_heap_size; /* If heap is greater that specified - call OOM */ ++ ++/* This function shall be called when OOM occurs or close */ ++static osso_mem_saw_oom_func_t saw_user_oom_func = NULL; ++static void* saw_user_context; /* Extra data for user OOM function */ ++ ++/* Original malloc hook which may be NULL */ ++static malloc_hook_t saw_old_malloc_hook = NULL; ++ ++ ++/* ========================================================================= * ++ * Local methods. ++ * ========================================================================= */ ++ ++/* ------------------------------------------------------------------------- * ++ * get_file_value - gets the value (size or %) from specified /proc file. ++ * Returns NSIZE if file is not available or value is invalid. ++ * ------------------------------------------------------------------------- */ ++ ++static size_t get_file_value(const char* filename) ++{ ++ FILE* fp = fopen(filename, "rt"); ++ ++ if (fp) ++ { ++ /* File opened successfuly, trying to load value */ ++ char buffer[32]; ++ ++ /* Get the value as a string */ ++ if (NULL == fgets(buffer, CAPACITY(buffer) - 1, fp)) ++ *buffer = 0; ++ fclose(fp); ++ ++ /* Convert it, much faster than fscanf */ ++ if ( *buffer ) ++ { ++ const long value = strtol(buffer, NULL, 0); ++ ++ if (value > 0) ++ return (size_t)value; ++ } ++ } ++ ++ /* Any kind of error */ ++ return NSIZE; ++} /* get_file_value */ ++ ++/* ------------------------------------------------------------------------- * ++ * load_meminfo -- open meminfo file and load values. ++ * parameters: ++ * vals - array of values to be handled. ++ * size - size of vals array. ++ * returns: number of sucessfully loaded values. ++ * ------------------------------------------------------------------------- */ ++static unsigned load_meminfo(size_t *vals, unsigned size) ++{ ++ FILE* meminfo = fopen("/proc/meminfo", "rt"); ++ ++ if ( meminfo ) ++ { ++ unsigned counter = 0; ++ char line[256]; ++ ++ /* Load all lines in file until we need setup values */ ++ while (counter < size && fgets(line, CAPACITY(line), meminfo)) ++ { ++ unsigned idx; ++ ++ for (idx = 0; idx < size; idx++) ++ { ++ /* Skip all indicies that already set */ ++ if ( vals[idx] ) ++ continue; ++ ++ /* Skip values that have different labels */ ++ if ( strncmp(line, meminfo_labels[idx].name, meminfo_labels[idx].length) ) ++ continue; ++ ++ /* Match, save the value */ ++ vals[idx] = (size_t)strtoul(line + meminfo_labels[idx].length + 1, NULL, 0); ++ counter++; ++ ++ /* Exit from scanning loop */ ++ break; ++ } /* for */ ++ } /* for all values and meminfo lines */ ++ ++ fclose(meminfo); ++ return counter; ++ } ++ ++ return 0; ++} /* load_meminfo */ ++ ++/* ------------------------------------------------------------------------- * ++ * setup_sys_values - loads the values from /proc files or obtain its from ++ * system andand setup sys_XXX variables. ++ * WARNING: we expect than sys_XXX variables are not changed during runtime. ++ * ------------------------------------------------------------------------- */ ++static void setup_sys_values(void) ++{ ++ /* Setup the page size */ ++ const size_t pagesize = sysconf(_SC_PAGESIZE); ++ /* Load amount of allowed pages */ ++ const size_t allowed_pages = get_file_value("/proc/sys/vm/lowmem_allowed_pages"); ++ ++ /* Check the availability of values */ ++ if (NSIZE == allowed_pages) ++ { ++ /* Unfortunately, lowmem_ is not available yet (scratchbox?) */ ++ size_t total = 0; /* ID_MEMTOTAL goes first */ ++ const int counter = load_meminfo(&total, 1); ++ ++ /* Setup available amount of RAM, if no meminfo available set 64MB */ ++ sys_avail_memory = (counter && total ? total : (64 << 10)); ++ } ++ else ++ { ++ sys_avail_memory = allowed_pages * (pagesize >> 10); ++ sys_deny_limit = get_file_value("/proc/sys/vm/lowmem_deny_watermark"); ++ sys_lowmem_limit = get_file_value("/proc/sys/vm/lowmem_notify_high"); ++ } ++ ++ /* Normalize the sys_deny_limit and sys_lowmem_limit according to loaded values */ ++ if (NSIZE == sys_deny_limit) ++ sys_deny_limit = sys_avail_memory - (sys_avail_memory >> 5); ++ else ++ sys_deny_limit = DIVIDE(sys_avail_memory * sys_deny_limit, 100); ++ ++ if (NSIZE == sys_lowmem_limit) ++ sys_lowmem_limit = sys_deny_limit; ++ else ++ sys_lowmem_limit = DIVIDE(sys_avail_memory * sys_lowmem_limit, 100); ++ ++ /* Moving from KB to bytes */ ++ sys_avail_memory <<= 10; ++ sys_deny_limit <<= 10; ++ sys_lowmem_limit <<= 10; ++} /* setup_sys_values */ ++ ++ ++/* ------------------------------------------------------------------------- * ++ * saw_malloc_hook - Malloc hook. Executed when osso_mem_saw_active is in ++ * place. Thread-safe (= slow in some cases). ++ * ------------------------------------------------------------------------- */ ++static void* saw_malloc_hook(size_t size, const void* caller) ++{ ++ static unsigned count = 0; /* Validation count per number of allocations */ ++ void* ptr; /* Allocated pointer, NULL means OOM situation happened */ ++ ++ THREAD_LOCK(); ++ ++ /* Restore the real malloc hook */ ++ __malloc_hook = saw_old_malloc_hook; ++ ++ /* Check for OOM-potential situation by size or allocated blocks counter */ ++ if (size >= saw_max_block_size || !count) ++ { ++ /* We must test amount of memory to predict future */ ++ const struct mallinfo mi = mallinfo(); ++ ptr = (mi.arena + mi.hblkhd + size >= saw_max_heap_size || osso_mem_in_lowmem_state() ? NULL : malloc(size)); ++ count = 1024; ++ } ++ else ++ { ++ ptr = malloc(size); ++ count--; ++ } ++ ++ /* Restore malloc hook to self */ ++ __malloc_hook = saw_malloc_hook; ++ ++ /* Test allocation, call OOM function if necessary */ ++ /* Note: SAW may be removed but that is safe for us */ ++ if ( !ptr ) ++ { ++ count = 0; /* force the next validation */ ++ if (saw_user_oom_func) ++ saw_user_oom_func(saw_max_heap_size + size, saw_max_heap_size, saw_user_context); ++ } ++ ++ THREAD_UNLOCK(); ++ ++#ifdef LIBOSSO_DEBUG ++ /* Printing from the critical section is a bad idea, try to do it now */ ++ if ( !ptr ) ++ ULOG_INFO_F("SAW: OOM for %u allocation", size); ++#endif ++ ++ return ptr; ++} /* saw_malloc_hook */ ++ ++ ++/* ========================================================================= * ++ * Public methods. ++ * ========================================================================= */ ++ ++/* ------------------------------------------------------------------------- * ++ * osso_mem_get_usage -- returns memory usage for current system in ++ * osso_mem_usage_t structure. ++ * parameters: ++ * usage - parameters to be updated. ++ * returns: ++ * 0 if values loaded successfuly OR negative error code. ++ * ------------------------------------------------------------------------- */ ++int osso_mem_get_usage(osso_mem_usage_t* usage) ++{ ++ /* Local variables */ ++ size_t vals[MAX_MEMINFO_LABELS]; ++ ++ /* Check the pointer validity first */ ++ if ( !usage ) ++ return -1; ++ ++ /* Load values from /proc/meminfo file */ ++ memset(usage, 0, sizeof(*usage)); ++ memset(vals, 0, sizeof(vals)); ++ if ( !load_meminfo(vals, CAPACITY(vals)) ) ++ return -1; ++ ++ /* Initialize values for /proc/sys/vm/lowmem_* */ ++ if (NSIZE == sys_avail_memory) ++ setup_sys_values(); ++ ++ ++ /* Discover memory information using loaded numbers */ ++ usage->total = vals[ID_MEMTOTAL] + vals[ID_SWAPTOTAL]; ++ ++ usage->free = vals[ID_MEMFREE] + vals[ID_BUFFERS] + ++ vals[ID_CACHED] + vals[ID_SWAPFREE]; ++ ++ usage->used = usage->total - usage->free; ++ usage->util = DIVIDE(100 * usage->used, usage->total); ++ ++ /* Translate everything from kilobytes to bytes */ ++ usage->total <<= 10; ++ usage->free <<= 10; ++ usage->used <<= 10; ++ ++ usage->deny = sys_deny_limit; ++ usage->low = sys_lowmem_limit; ++ ++ /* ++ * From the usage->free we deduct the delta based on deny limit ++ * or 87.5% if low limit is disabled ++ */ ++ usage->usable = (usage->low ? sys_avail_memory - usage->low : (sys_avail_memory >> 3)); ++ usage->usable = (usage->usable < usage->free ? usage->free - usage->usable : 0); ++ ++ /* We have succeed */ ++ return 0; ++} /* osso_mem_get_usage */ ++ ++/* ------------------------------------------------------------------------- * ++ * Returns the total allocated RAM in system according to ++ * /proc/sys/vm/lowmem_* files. ++ * ++ * WARNING: Assumes 97% of memory can be allocated if no limits set (kernel) ++ * hardcoded threshold. ++ * ------------------------------------------------------------------------- */ ++size_t osso_mem_get_avail_ram(void) ++{ ++ if(NSIZE == sys_avail_memory) ++ setup_sys_values(); ++ return sys_avail_memory; ++} /* osso_mem_get_avail_ram */ ++ ++/* ------------------------------------------------------------------------- * ++ * Returns deny limit (in bytes, the total allocated RAM in system) ++ * according to /proc/sys/vm/lowmem_* settings. ++ * ++ * WARNING: Assumes 97% of memory can be allocated if no limits set (kernel) ++ * hardcoded threshold. ++ * ------------------------------------------------------------------------- */ ++size_t osso_mem_get_deny_limit(void) ++{ ++ if(NSIZE == sys_deny_limit) ++ setup_sys_values(); ++ return sys_deny_limit; ++} /* osso_mem_get_deny_limit */ ++ ++/* ------------------------------------------------------------------------- * ++ * Returns low memory (lowmem_high_limit, the total allocated RAM in system) ++ * according to /proc/sys/vm/lowmem_* settings. ++ * ++ * WARNING: Assumes 97% of memory can be allocated if no limits set (kernel) ++ * hardcoded threshold. ++ * ------------------------------------------------------------------------- */ ++size_t osso_mem_get_lowmem_limit(void) ++{ ++ if(NSIZE == sys_lowmem_limit) ++ setup_sys_values(); ++ return sys_lowmem_limit; ++} /* osso_mem_get_lowmem_limit */ ++ ++/* ------------------------------------------------------------------------- * ++ * Returns flag about low memory conditions is reached according to ++ * /sys/kernel/high_watermark is set to 1. ++ * ++ * WARNING: under scratchbox always return 0. ++ * ------------------------------------------------------------------------- */ ++int osso_mem_in_lowmem_state(void) ++{ ++ return (1 == get_file_value("/sys/kernel/high_watermark")); ++} /* osso_mem_in_lowmem_state */ ++ ++/* ------------------------------------------------------------------------- * ++ * osso_mem_saw_enable - enables Simple Allocation Watchdog. ++ * 1. Calculates the possible growth of process' heap based on the ++ * current heap stats, adjusted to the threshold ++ * 2. sets up the hook on malloc function; if the particular allocatuion ++ * whose size is bigger than watchblock could violate the limit, ++ * oom_func with user-specified context is called and malloc returns 0 ++ * ++ * Parameters: ++ * - threshold - amount of memory that shall be free in system. ++ * If you pass 0 than maximum available should be set (according to lowmem_high_limit) ++ * - watchblock - if allocation size more than specified the amount of ++ * available memory must be tested. If 0 passed this parameter should be ++ * set to page size. ++ * - oom_func - this function shall be called if we reach high memory ++ * consumption (OOM level), specified by threshold or NULL malloc occurs. ++ * May be NULL. ++ * - context - additional parameter that shall be passed into oom_func. ++ * ++ * Returns: 0 on success, negative on error ++ * ++ * Note: can be safely called several times. ++ * ++ * WARNING: if SAW can not be installed the old one will be active. ++ * ------------------------------------------------------------------------- */ ++int osso_mem_saw_enable(size_t threshold, ++ size_t watchblock, ++ osso_mem_saw_oom_func_t oom_func, ++ void* context ++ ) ++{ ++ osso_mem_usage_t current; ++ ++ /* Validate passed parameters. */ ++ if ( !watchblock ) ++ watchblock = sysconf(_SC_PAGESIZE); ++ ++ /* Load the values about memory usage */ ++ if( osso_mem_get_usage(¤t) ) ++ { ++ ULOG_CRIT_F("Error:osso_mem_get_usage failed"); ++ return -EINVAL; ++ } ++ ++ /* If we're below the threshold, don't make things worse */ ++ if(current.usable > threshold) ++ { ++ const struct mallinfo mi = mallinfo(); ++ ++ THREAD_LOCK(); ++ ++ saw_user_oom_func = oom_func; ++ saw_max_heap_size = mi.arena + mi.hblkhd + current.usable - threshold; ++ saw_max_block_size = watchblock; ++ saw_user_context = context; ++ /* Always dumping memory information (workaround for thumbnailer) */ ++ syslog(LOG_CRIT, "osso_mem %zd = %u + %u + %zd - %zd", ++ saw_max_heap_size, mi.arena, mi.hblkhd, current.usable, ++ threshold); ++ ++ if(saw_malloc_hook != __malloc_hook) ++ { ++ /* SAW hook is not set */ ++ saw_old_malloc_hook = __malloc_hook; ++ __malloc_hook = saw_malloc_hook; ++ } ++ ++ THREAD_UNLOCK(); ++ ++ ULOG_INFO_F("SAW hook installed: block size %u, maxheap %u (threshold %u)", ++ saw_max_block_size, saw_max_heap_size, threshold); ++ ++ return 0; ++ } ++ else ++ { ++ ULOG_WARN_F("SAW: OOM:current.usable(%u) <= threshold(%u)", ++ current.usable, threshold); ++ return -EINVAL; ++ } ++} /* osso_mem_saw_enable */ ++ ++/* ------------------------------------------------------------------------- * ++ * osso_mem_saw_disable - disables Simple Allocation Watchdog and restore ++ * default malloc hook. ++ * ++ * Note: can be safely called several times. ++ * ------------------------------------------------------------------------- */ ++void osso_mem_saw_disable(void) ++{ ++ THREAD_LOCK(); ++ if(saw_malloc_hook == __malloc_hook) ++ __malloc_hook = saw_old_malloc_hook; ++ THREAD_UNLOCK(); ++ ++ ULOG_INFO_F("SAW hook removed!"); ++} /* osso_mem_saw_disable */ ++ ++ ++ ++/* ========================================================================= * ++ * main function, just for testing purposes. ++ * ========================================================================= */ ++#ifdef UNIT_TEST ++ ++static void test_oom_func(size_t current_sz, size_t max_sz, void* context) ++{ ++ printf("%s(%u, %u, 0x%08x) called\n", __FUNCTION__, current_sz, max_sz, (unsigned)context); ++} /* test_oom_func */ ++ ++ ++int main(const int argc, const char* argv[]) ++{ ++ osso_mem_usage_t usage; ++ const size_t insane = 60 << 20; ++ void* ptr; ++ ++ printf("\n1. UNIT_TEST MEMUSAGE \n"); ++ ++ /* Load all values from meminfo file */ ++ if (0 == osso_mem_get_usage(&usage)) ++ { ++ printf ("%u\t%u\t%u\t%u\t%u\t%u\n", usage.total, usage.free, usage.used, usage.util, usage.deny, usage.low); ++ } ++ else ++ { ++ printf ("unable to load values from /proc/meminfo file\n"); ++ return -1; ++ } ++ ++ printf("\n2. Testing lowmem\n"); ++ ++ printf("Lowmem limits: LOW=%u bytes, DENY=%u bytes\n", ++ osso_mem_get_lowmem_limit(), ++ osso_mem_get_deny_limit() ++ ); ++ ++ printf("\n3. Testing SAW\n"); ++ ptr = malloc( insane ); ++ printf("Without SAW, allocating %u bytes: %s\n",insane, ptr ? "Succeeded": "Failed" ); ++ ++ if(ptr) ++ free(ptr); ++ ++ if ( osso_mem_saw_enable(0, 0, NULL, NULL) ) ++ { ++ printf("Cannot activate saw\n"); ++ } ++ ++ ptr = malloc( insane ); ++ printf("With SAW, allocating %u bytes: %s\n", insane, ptr ? "Succeeded" : "Failed"); ++ if(ptr) ++ free(ptr); ++ ++ if ( osso_mem_saw_enable(0, 0, test_oom_func, NULL) ) ++ printf("Cannot activate saw with oom function\n"); ++ ++ ptr = malloc( insane ); ++ printf("With SAW, allocating %u bytes: %s\n", insane, ptr ? "Succeeded" : "Failed"); ++ ++ if ( osso_mem_in_lowmem_state() ) ++ printf("\n4. Low memory situation is reached\n"); ++ else ++ printf("\n4. Low memory situation is not reached\n"); ++ ++ if(ptr) ++ free(ptr); ++ ++ /* That is all */ ++ return 0; ++} /* main */ ++ ++#endif /* UNIT_TEST */ ++ +diff -purN dosfstools-2.11/dosfsck/osso-mem.h dosfstools-2.11.new/dosfsck/osso-mem.h +--- dosfstools-2.11/dosfsck/osso-mem.h 1970-01-01 02:00:00.000000000 +0200 ++++ dosfstools-2.11.new/dosfsck/osso-mem.h 2007-10-05 12:28:43.110931272 +0300 +@@ -0,0 +1,151 @@ ++/* ========================================================================= * ++ * File: osso-mem.h ++ * ++ * This file is part of libosso ++ * ++ * Copyright (C) 2005-2006 Nokia Corporation. All rights reserved. ++ * ++ * Contact: Leonid Moiseichuk ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public License ++ * version 2.1 as published by the Free Software Foundation. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA ++ * 02110-1301 USA ++ */ ++ ++#ifndef OSSO_MEM_H ++#define OSSO_MEM_H ++ ++#ifdef __cplusplus ++extern "C" { ++#endif ++ ++/* ========================================================================= * ++ * Includes ++ * ========================================================================= */ ++ ++#include ++ ++/* ========================================================================= * ++ * Definitions. ++ * ========================================================================= */ ++ ++/* Structure that used to report about memory consumption */ ++typedef struct ++{ ++ size_t total; /* Total amount of memory in system: RAM + swap */ ++ size_t free; /* Free memory in system, bytes */ ++ size_t used; /* Used memory in system, bytes */ ++ size_t util; /* Memory utilization in percents */ ++ size_t low; /* Low memory limit, bytes.0 if not set or >100%*/ ++ size_t deny; /* Deny limit, bytes.0 if not set or >100% */ ++ size_t usable; /* How much memory available for applications */ ++} osso_mem_usage_t; ++ ++/* ------------------------------------------------------------------------- * ++ * A OOM notification function used when SAW determines an OOM condition ++ * current_sz -- current heap size ++ * max_sz -- maximum heap size ++ * context -- user-specified context (see osso_mem_saw_enable) ++ * ------------------------------------------------------------------------- */ ++typedef void (*osso_mem_saw_oom_func_t)(size_t current_sz, size_t max_sz,void *context); ++ ++/* ========================================================================= * ++ * Methods. ++ * ========================================================================= */ ++ ++/* ------------------------------------------------------------------------- * ++ * osso_mem_get_usage -- returns memory usage for current system in ++ * osso_mem_usage_t structure. ++ * parameters: ++ * usage - parameters to be updated. ++ * returns: ++ * 0 if values loaded successfuly OR negative error code. ++ * ------------------------------------------------------------------------- */ ++int osso_mem_get_usage(osso_mem_usage_t* usage); ++ ++/* ------------------------------------------------------------------------- * ++ * Returns the total allocated RAM in system according to ++ * /proc/sys/vm/lowmem_* files. ++ * ++ * WARNING: Assumes 97% of memory can be allocated if no limits set (kernel) ++ * hardcoded threshold. ++ * ------------------------------------------------------------------------- */ ++size_t osso_mem_get_avail_ram(void); ++ ++/* ------------------------------------------------------------------------- * ++ * Returns deny limit (in bytes, the total allocated RAM in system) ++ * according to /proc/sys/vm/lowmem_* settings. ++ * ++ * WARNING: Assumes 97% of memory can be allocated if no limits set (kernel) ++ * hardcoded threshold. ++ * ------------------------------------------------------------------------- */ ++size_t osso_mem_get_deny_limit(void); ++ ++/* ------------------------------------------------------------------------- * ++ * Returns low memory (lowmem_high_limit, the total allocated RAM in system) ++ * according to /proc/sys/vm/lowmem_* settings. ++ * ++ * WARNING: Assumes 97% of memory can be allocated if no limits set (kernel) ++ * hardcoded threshold. ++ * ------------------------------------------------------------------------- */ ++size_t osso_mem_get_lowmem_limit(void); ++ ++/* ------------------------------------------------------------------------- * ++ * Returns 1 if the device is in the low-memory state. ++ * ++ * WARNING: under Scratchbox always returns 0. ++ * ------------------------------------------------------------------------- */ ++int osso_mem_in_lowmem_state(void); ++ ++/* ------------------------------------------------------------------------- * ++ * osso_mem_saw_enable - enables Simple Allocation Watchdog. ++ * 1. Calculates the possible growth of process' heap based on the ++ * current heap stats, adjusted to the threshold ++ * 2. sets up the hook on malloc function; if the particular allocatuion ++ * whose size is bigger than watchblock_sz could violate the limit, ++ * oom_func with user-specified context is called and malloc returns 0 ++ * ++ * Parameters: ++ * - threshold - amount of memory used in system. If you pass 0 than maximum ++ * available should be set (according to lowmem_high_limit) ++ * - watchblock - if allocation size more than specified the amount of ++ * available memory must be tested. If 0 passed this parameter should be ++ * set to page size. ++ * - oom_func - this function shall be called if we reach high memory ++ * consumption (OOM level), specified by threshold or NULL malloc occurs. ++ * May be NULL. ++ * - context - additional parameter that shall be passed into oom_func. ++ * ++ * Returns: 0 on success, negative on error ++ * ++ * Note: can be safely called several times. ++ * ++ * WARNING: if SAW can not be installed the old one will be active. ++ * ------------------------------------------------------------------------- */ ++int osso_mem_saw_enable(size_t threshold, ++ size_t watchblock, ++ osso_mem_saw_oom_func_t oom_func, ++ void *context ++ ); ++ ++/* ------------------------------------------------------------------------- * ++ * osso_mem_saw_disable - disables Simple Allocation Watchdog and restore ++ * default malloc hook. If no watchdog setup do nothing. ++ * ------------------------------------------------------------------------- */ ++void osso_mem_saw_disable(void); ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif /* OSSO_MEM_H */ diff -Nru dosfstools-2.10/debian/patches/08-limit-cluster-msg.patch dosfstools-2.11/debian/patches/08-limit-cluster-msg.patch --- dosfstools-2.10/debian/patches/08-limit-cluster-msg.patch 1970-01-01 00:00:00.000000000 +0000 +++ dosfstools-2.11/debian/patches/08-limit-cluster-msg.patch 2007-10-04 07:08:06.000000000 +0000 @@ -0,0 +1,30 @@ +diff -pur dosfstools-2.11/dosfsck/fat.c dosfstools-2.11.new/dosfsck/fat.c +--- dosfstools-2.11/dosfsck/fat.c 2003-06-14 23:03:20.000000000 +0300 ++++ dosfstools-2.11.new/dosfsck/fat.c 2007-10-04 10:05:32.673762744 +0300 +@@ -53,6 +53,7 @@ void read_fat(DOS_FS *fs) + unsigned long i; + void *first,*second,*use; + int first_ok,second_ok; ++ int msg_to_print = 100, total_msg = 0, msg_printed = 0; + + eff_size = ((fs->clusters+2)*fs->fat_bits+7)/8; + first = alloc(eff_size); +@@ -102,10 +103,18 @@ void read_fat(DOS_FS *fs) + for (i = 2; i < fs->clusters+2; i++) + if (fs->fat[i].value >= fs->clusters+2 && + (fs->fat[i].value < FAT_MIN_BAD(fs))) { ++ if (msg_to_print >= msg_printed) { + printf("Cluster %ld out of range (%ld > %ld). Setting to EOF.\n", + i-2,fs->fat[i].value,fs->clusters+2-1); ++ ++msg_printed; ++ } + set_fat(fs,i,-1); ++ ++total_msg; + } ++ if (total_msg - msg_printed > 0) { ++ printf("Skipped %d 'Cluster N out of range...' messages.\n", ++ total_msg - msg_printed); ++ } + free(first); + if (second) + free(second); diff -Nru dosfstools-2.10/debian/patches/09-silence-printf-warnings.patch dosfstools-2.11/debian/patches/09-silence-printf-warnings.patch --- dosfstools-2.10/debian/patches/09-silence-printf-warnings.patch 1970-01-01 00:00:00.000000000 +0000 +++ dosfstools-2.11/debian/patches/09-silence-printf-warnings.patch 2008-02-08 07:26:22.000000000 +0000 @@ -0,0 +1,22 @@ +--- dosfstools-2.11/dosfsck/check.c.orig 2008-02-07 16:11:26.000000000 +0200 ++++ dosfstools-2.11/dosfsck/check.c 2008-02-07 16:13:22.000000000 +0200 +@@ -315,8 +315,8 @@ + first = file->parent ? file->parent->first : root; + number = 0; + while (1) { +- sprintf(file->dir_ent.name, "FSCK%04d", number / 1000); +- sprintf(file->dir_ent.name, "%03d", number % 1000); ++ sprintf(file->dir_ent.name, "FSCK%04ld", number / 1000); ++ sprintf(file->dir_ent.name, "%03ld", number % 1000); + for (walk = first; walk; walk = walk->next) + if (walk != file && !strncmp(walk->dir_ent.name,file->dir_ent. + name,MSDOS_NAME)) break; +@@ -535,7 +535,7 @@ + if (!(file->dir_ent.attr & ATTR_DIR) && CF_LE_L(file->dir_ent.size) > + (unsigned long long)clusters*fs->cluster_size) { + printf("%s\n File size is %u bytes, cluster chain length is %llu bytes." +- "\n Truncating file to %lu bytes.\n",path_name(file),CF_LE_L(file-> ++ "\n Truncating file to %llu bytes.\n",path_name(file),CF_LE_L(file-> + dir_ent.size),(unsigned long long)clusters*fs->cluster_size,(unsigned long long)clusters*fs->cluster_size); + MODIFY(file,size,CT_LE_L((unsigned long long)clusters*fs->cluster_size)); + } diff -Nru dosfstools-2.10/debian/patches/10-dosfsck-memsaves.patch dosfstools-2.11/debian/patches/10-dosfsck-memsaves.patch --- dosfstools-2.10/debian/patches/10-dosfsck-memsaves.patch 1970-01-01 00:00:00.000000000 +0000 +++ dosfstools-2.11/debian/patches/10-dosfsck-memsaves.patch 2008-03-10 07:31:00.000000000 +0000 @@ -0,0 +1,214 @@ +--- dosfstools-2.11/dosfsck/common.h.orig 2004-02-25 11:07:01.000000000 +0200 ++++ dosfstools-2.11/dosfsck/common.h 2008-02-20 17:45:20.000000000 +0200 +@@ -21,12 +21,12 @@ + + /* Like die, but appends an error message according to the state of errno. */ + +-void *alloc(int size); ++void *alloc(size_t size); + + /* mallocs SIZE bytes and returns a pointer to the data. Terminates the program + if malloc fails. */ + +-void *qalloc(void **root,int size); ++void *qalloc(void **root,size_t size); + + /* Like alloc, but registers the data area in a list described by ROOT. */ + +--- dosfstools-2.11/dosfsck/common.c.orig 2003-05-15 21:39:16.000000000 +0300 ++++ dosfstools-2.11/dosfsck/common.c 2008-03-05 15:15:55.000000000 +0200 +@@ -5,6 +5,10 @@ + /* FAT32, VFAT, Atari format support, and various fixes additions May 1998 + * by Roman Hodek */ + ++/* A simple block allocator to speed up and cut down the huge memory ++ * overhead of dosfsck allocs (with full 8GB file system, cuts 120MB ++ * memory usage to 80MB) 2008-02-13 by Eero Tamminen ++ * */ + + #include + #include +@@ -14,6 +18,13 @@ + + #include "common.h" + ++/* pointers to current larger allocation block used for small allocations */ ++static void *block_head = NULL; ++static void *block_end = NULL; ++ ++#define BLOCK_ALLOC_SIZE (4096-8) /* assume this is one page with libc overhead */ ++#define MIN_ALLOC_FROM_BLOCK 127 /* use block alloc for anything smaller */ ++ + + typedef struct _link { + void *data; +@@ -45,7 +56,7 @@ + } + + +-void *alloc(int size) ++void *alloc(size_t size) + { + void *this; + +@@ -55,14 +66,52 @@ + } + + +-void *qalloc(void **root,int size) ++/* should be called only from qalloc(). ++ * get small allocs from a larger block and add those larger ++ * blocks to linked list of qalloc() ++ */ ++static void *qalloc_block(void **root, size_t size) ++{ ++ void *ret; ++ if (size > MIN_ALLOC_FROM_BLOCK) { ++ return NULL; ++ } ++ /* dosfsck doesn't use doubles, so it's safe to align just to 4 */ ++ size = (size+3) & ~3; ++ if (!block_head || block_head + size > block_end) { ++ LINK *link = alloc(sizeof(LINK)); ++ link->next = *root; ++ *root = link; ++ ++ block_head = alloc(BLOCK_ALLOC_SIZE); ++ block_end = block_head + BLOCK_ALLOC_SIZE; ++ link->data = block_head; ++ } ++ ret = block_head; ++ block_head += size; ++ return ret; ++} ++ ++static void qfree_blocks(void) ++{ ++ block_head = block_end = NULL; ++} ++ ++ ++void *qalloc(void **root, size_t size) + { + LINK *link; ++ void *block; + +- link = alloc(sizeof(LINK)); +- link->next = *root; +- *root = link; +- return link->data = alloc(size); ++ block = qalloc_block(root, size); ++ if (block) { ++ return block; ++ } else { ++ link = alloc(sizeof(LINK)); ++ link->next = *root; ++ *root = link; ++ return link->data = alloc(size); ++ } + } + + +@@ -76,6 +125,7 @@ + free(this->data); + free(this); + } ++ qfree_blocks(); + } + + +--- dosfstools-2.11/dosfsck/dosfsck.h.orig 2005-03-12 16:23:12.000000000 +0200 ++++ dosfstools-2.11/dosfsck/dosfsck.h 2008-02-07 15:51:19.000000000 +0200 +@@ -111,8 +111,8 @@ + } DOS_FILE; + + typedef struct { +- unsigned long value; +- unsigned long reserved; ++ unsigned int value : 28; /* 12 or 16 bits, 28 bits with FAT32 */ ++ unsigned int reserved : 4; /* 4 bits with FAT32, otherwise unused */ + DOS_FILE *owner; + int prev; /* number of previous clusters */ + } FAT_ENTRY; +--- dosfstools-2.11/dosfsck/fat.c.orig 2008-02-07 15:43:09.000000000 +0200 ++++ dosfstools-2.11/dosfsck/fat.c 2008-02-20 17:44:52.000000000 +0200 +@@ -51,14 +51,13 @@ + { + int eff_size; + unsigned long i; +- void *first,*second,*use; ++ void *first,*second; + int first_ok,second_ok; + int msg_to_print = 100, total_msg = 0, msg_printed = 0; + + eff_size = ((fs->clusters+2ULL)*fs->fat_bits+7)/8ULL; + first = alloc(eff_size); + fs_read(fs->fat_start,eff_size,first); +- use = first; + if (fs->nfats > 1) { + second = alloc(eff_size); + fs_read(fs->fat_start+fs->fat_size,eff_size,second); +@@ -73,24 +72,28 @@ + second_ok = (second_media.value & FAT_EXTD(fs)) == FAT_EXTD(fs); + if (first_ok && !second_ok) { + printf("FATs differ - using first FAT.\n"); +- fs_write(fs->fat_start+fs->fat_size,eff_size,use = first); ++ fs_write(fs->fat_start+fs->fat_size,eff_size,first); + } + if (!first_ok && second_ok) { + printf("FATs differ - using second FAT.\n"); +- fs_write(fs->fat_start,eff_size,use = second); ++ fs_write(fs->fat_start,eff_size,second); ++ memcpy(first,second,eff_size); + } + if (first_ok && second_ok) { + if (interactive) { + printf("FATs differ but appear to be intact. Use which FAT ?\n" + "1) Use first FAT\n2) Use second FAT\n"); +- if (get_key("12","?") == '1') +- fs_write(fs->fat_start+fs->fat_size,eff_size,use = first); +- else fs_write(fs->fat_start,eff_size,use = second); ++ if (get_key("12","?") == '1') { ++ fs_write(fs->fat_start+fs->fat_size,eff_size,first); ++ } else { ++ fs_write(fs->fat_start,eff_size,second); ++ memcpy(first,second,eff_size); ++ } + } + else { + printf("FATs differ but appear to be intact. Using first " + "FAT.\n"); +- fs_write(fs->fat_start+fs->fat_size,eff_size,use = first); ++ fs_write(fs->fat_start+fs->fat_size,eff_size,first); + } + } + if (!first_ok && !second_ok) { +@@ -98,13 +101,17 @@ + exit(1); + } + } ++ /* first contains now the valid FAT, so this can be freed */ ++ if (second) { ++ free(second); ++ } + fs->fat = qalloc(&mem_queue,sizeof(FAT_ENTRY)*(fs->clusters+2ULL)); +- for (i = 2; i < fs->clusters+2; i++) get_fat(&fs->fat[i],use,i,fs); ++ for (i = 2; i < fs->clusters+2; i++) get_fat(&fs->fat[i],first,i,fs); + for (i = 2; i < fs->clusters+2; i++) + if (fs->fat[i].value >= fs->clusters+2 && + (fs->fat[i].value < FAT_MIN_BAD(fs))) { + if (msg_to_print >= msg_printed) { +- printf("Cluster %ld out of range (%ld > %ld). Setting to EOF.\n", ++ printf("Cluster %ld out of range (%d > %ld). Setting to EOF.\n", + i-2,fs->fat[i].value,fs->clusters+2-1); + ++msg_printed; + } +@@ -116,8 +123,6 @@ + total_msg - msg_printed); + } + free(first); +- if (second) +- free(second); + } + + diff -Nru dosfstools-2.10/debian/patches/11-ignore-fs_close-return-value.patch dosfstools-2.11/debian/patches/11-ignore-fs_close-return-value.patch --- dosfstools-2.10/debian/patches/11-ignore-fs_close-return-value.patch 1970-01-01 00:00:00.000000000 +0000 +++ dosfstools-2.11/debian/patches/11-ignore-fs_close-return-value.patch 2008-03-31 13:51:51.000000000 +0000 @@ -0,0 +1,13 @@ +diff -pur dosfstools-2.11/dosfsck/dosfsck.c dosfstools-2.11.new/dosfsck/dosfsck.c +--- dosfstools-2.11/dosfsck/dosfsck.c 2004-02-25 21:28:57.000000000 +0200 ++++ dosfstools-2.11.new/dosfsck/dosfsck.c 2008-03-31 16:32:08.000000000 +0300 +@@ -175,7 +175,8 @@ int main(int argc,char **argv) + printf( "%s: %u files, %lu/%lu clusters\n", argv[optind], + n_files, fs.clusters - free_clusters, fs.clusters ); + +- return fs_close(rw) ? 1 : 0; ++ fs_close(rw); ++ return 0; + } + + /* Local Variables: */ diff -Nru dosfstools-2.10/debian/rules dosfstools-2.11/debian/rules --- dosfstools-2.10/debian/rules 2019-04-09 00:25:54.000000000 +0000 +++ dosfstools-2.11/debian/rules 2007-09-25 10:46:14.000000000 +0000 @@ -1,74 +1,37 @@ -#! /usr/bin/make -f - -# Copyright 1994-97 joey@infodrom.north.de (Martin Schulze) +#!/usr/bin/make -f +# Copyright © 2006 Nokia Corporation. All rights reserved. # -# 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; version 2 dated June, 1991. +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# version 2 as published by the Free Software Foundation. # -# 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. +# 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., 675 Mass Ave., Cambridge, MA 02139, USA. - -tmpdir=debian/tmp -docdir=$(tmpdir)/usr/share/doc/dosfstools -mandir=$(tmpdir)/usr/share/man -oldmandir=$(tmpdir)/usr/man -ARCH = $(shell dpkg --print-gnu-build-architecture) - -ifeq ($(ARCH),alpha) -OPTFLAGS="-fomit-frame-pointer -fno-strict-aliasing" -else -OPTFLAGS="-O2 -fomit-frame-pointer" +# 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 St, Fifth Floor, Boston, MA +# 02110-1301 USA + +include /usr/share/cdbs/1/rules/debhelper.mk +include /usr/share/cdbs/1/rules/simple-patchsys.mk +include /usr/share/cdbs/1/rules/utils.mk + +DEB_TAR_SRCDIR := dosfstools-2.11 +include /usr/share/cdbs/1/rules/tarball.mk + +# Use soft-float and thumb mode if it is enabled. +ifneq (,$(findstring thumb,$(DEB_BUILD_OPTIONS))) + CFLAGS += -mthumb endif -build: - make DEBUGFLAGS=-g OPTFLAGS=$(OPTFLAGS) - touch build - -clean: - make distclean - rm -f `find -name '*~' -o -name '.#*' -o -name '.new*'` - rm -rf build - rm -rf debian/tmp - rm -f debian/files debian/substvars - -binary: binary-indep binary-arch - -binary-indep: -# Nothing to be done here - -binary-arch: build - dh_testdir - dh_testroot - dh_clean - dh_installdirs - make install PREFIX=`pwd`/$(tmpdir) - install -d $(mandir)/man8 - mv $(oldmandir)/man8/* $(mandir)/man8 - rm -rf $(oldmandir) - dh_installdocs README.Atari TODO - # dh_installdocs can't install two "README" files (same name) - install -m 644 mkdosfs/README $(docdir)/README.mkdosfs - install -m 644 dosfsck/README $(docdir)/README.dosfsck - dh_installchangelogs CHANGES - dh_strip - dh_compress - dh_fixperms - dh_installdeb - dh_shlibdeps - dh_gencontrol - dh_builddeb - -source diff: - @echo >&2 'source and diff are obsolete - use dpkg-source -b' or dsc; false - -dist: binary dsc +configure/dosfstools:: + cd $(DEB_BUILDDIR); sed -ri "s#REPLACE_WITH_PREFIX#$(DEB_DESTDIR)#" Makefile -.PHONY: binary binary-arch binary-indep clean +build/dosfstools:: + cd $(DEB_BUILDDIR); $(MAKE) install +clean:: + rm -f *.cdbs-config_list