Skip to content

Instantly share code, notes, and snippets.

@tuklusan
Created December 24, 2020 19:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tuklusan/51672bc64c5217b5e0c4f52739513b8f to your computer and use it in GitHub Desktop.
Save tuklusan/51672bc64c5217b5e0c4f52739513b8f to your computer and use it in GitHub Desktop.
Zerofree (fill unused hard disk space with zeroes) for OS/2 Warp, see https://supratim-sanyal.blogspot.com/2016/12/zero-out-free-disk-space-on-virtual.html
/* zerofree-os2.c
(c) 2020 Supratim Sanyal
A minimal program to zero out unused disk space for OS/2 Warp and derivates
(eComstation, ArcaOS etc.). Nothing OS/2 specific here, it should work for all
operating systems with a C compiler once the OS/2-style (MS-DOS style) pathnames
for drive letter and directory for the zero.zero file are adjusted.
Compiled using Borland C++ 2.0 for OS/2. Executable is downloadable free from:
https://supratim-sanyal.blogspot.com/2016/12/zero-out-free-disk-space-on-virtual.html
Licensed under Beerware License 42: Absolutely no assurances, all risk is
yours. If it does something useful and we meet some day buy me a beer.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char *argv[])
{
FILE *fp=NULL;
char fname[32]="\0";
int i=0;
int done=0;
if (2!=argc)
{
fprintf(stderr,"usage: %s <drive-letter>\n",argv[0]);
return(1);
}
if (1!=strlen(argv[1]))
{
fprintf(stderr,"usage: %s <drive-letter>\n",argv[0]);
return(1);
}
sprintf(fname,"%s:\\zero.zero",argv[1]);
printf("Creating file %s filled with zeroes ...\n",fname);
if (NULL==(fp=fopen(fname,"w"))) {perror(fname);return 1;}
while(!done)
{
for(i=0;i<(100*148576);i++) /* mark every 100 MB */
{
if(EOF==fputc('\0',fp))
{
done=1;
break;
}
}
putchar('*');
fflush(NULL);
}
putchar('\n');
fflush(NULL);
fclose(fp);
fflush(NULL);
printf("Deleting file %s ...\n",fname);
if(0!=unlink(fname)) {perror(fname);return 1;}
printf("Have a great life!\n");
return(0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment