Skip to main content
GameDev.net gamedev.net
🔒 Locked

Reference-counted files

Started by superpig Apr 18, 2003 at 5:46 PM 6 replies 500+ views
Original Post
superpig
superpig
This is something I was thinking about earlier, which I don''t think I''ve seen in any operating system or filesystem. I''ve seen OS-design discussion in here before, so... It will often happen that multiple applications will use the same file - a DLL, an ini file, whatever. So when uninstalling, an app has to assume that the file is still in use - the result is potentially a bunch of files that aren''t being used by anything, but nobody is really sure. So how about reference-counting files? It would be a feature of the filesystem; each file would have a list of ''application IDs'' (probably UUIDs) for the apps that use it. You instantly get two big features - you can see which app a file belongs to (because many files will only have one app listed), and you can ensure that a file doesn''t get deleted while other apps use it. It would, of course, require very strict policies on install/uninstall methods; an app which fails to remove itself from the list of referencers would result in a file that can''t be deleted. Here''s a radical suggestion - force every file that is created to be created with at least one referencer id. A few special IDs would be around for marking a user''s documents or other files which should be freely deletable, but on the whole every file would have at least one app id marking it. When the app is uninstalled, all files marked with the app id could be *automatically* dereferenced; and then, any files with no references could be deleted. Just some ideas. What would this break? What are the disadvantages (besides the storage space for the IDs)? Superpig - saving pigs from untimely fates, and when he''s not doing that, runs The Binary Refinery.
Richard "Superpig" Fine - saving pigs from untimely fates - Microsoft DirectX MVP 2006/2007/2008/2009
"Shaders are not meant to do everything. Of course you can try to use it for everything, but it's like playing football using cabbage." - MickeyMouse
TSwitch
TSwitch
Garbage collection? Oh god, I don't need memory GC and hard disk GC running while my Java program is trying to do FFTs. FFS.

But this *is* an interesting idea. It'd make certain aspects of your filesystem very easy to maintain.

So long as the user is limited to putting his own files in some separate area.

I guess ths system would also encourage (or force, even) defragmentation.

[edited by - TSwitch on April 18, 2003 8:23:12 PM]
Member of the Unban nes8bit or the White Rhino in my Basement Gets Sold to the Highest Bidder Association (UNWRBGSHBA - Not accepting new members.)Member of the I'm Glad Mithrandir Finally Found an Association that Accepts People with his Past History Association (IGMFFAAPPHA)
Plasmadog
Plasmadog
The Windows Installer system already uses reference counting for shared files.
From the InstallShield site:
quote:
During installation, files identified as shared are registered in the Windows registry. Each time the shared file is installed, the registry increments the registry value associated with it. This registry value is also known as the ref count or the shared reference count. So if two applications install the same shared file, the registry value (ref count) is 2. During uninstallation, a shared file''s registry value is decremented. When the registry value reaches 0, you will receive a message asking if you want to remove the shared file, which means there is no application using the shared file. In almost all cases, you can click Yes and remove the shared file. The shared file is permanently deleted, and the hard disk space freed. If you choose No, it will not harm your computer. If you are unsure whether or not to remove the shared file, click No.

You are not the one beautiful and unique snowflake who, unlike the rest of us, doesn't have to go through the tedious and difficult process of science in order to establish the truth. You're as foolable as anyone else. And since you have taken no precautions to avoid fooling yourself, the self-evident fact that countless millions of humans before you have also fooled themselves leads me to the parsimonious belief that you have too.--Daniel Rutter
superpig
superpig
TSwitch: I''m not talking about realtime HD collection. Besides, it''s not that hard to remove the file entry from the FAT tables, right?

Plasmadog: OK. The problem is, apps aren''t forced to use the windows installer; if we factor in my idea about forced IDs (we''re talking a fundamental change to the fopen() function type thing), how does that change things?

Superpig
- saving pigs from untimely fates, and when he''s not doing that, runs The Binary Refinery.
Richard "Superpig" Fine - saving pigs from untimely fates - Microsoft DirectX MVP 2006/2007/2008/2009
"Shaders are not meant to do everything. Of course you can try to use it for everything, but it's like playing football using cabbage." - MickeyMouse
Sneftel
Sneftel
quote:
Original post by superpig
if we factor in my idea about forced IDs (we''re talking a fundamental change to the fopen() function type thing), how does that change things?


It means everybody bitches about how MS is trying to take over the world.


How appropriate. You fight like a cow.
superpig
superpig
It does?

I''m in favour of forcing software to use a centralised install system - if not a common user interface, then a common API. It makes managing a system *so* much easier.
Richard "Superpig" Fine - saving pigs from untimely fates - Microsoft DirectX MVP 2006/2007/2008/2009
"Shaders are not meant to do everything. Of course you can try to use it for everything, but it's like playing football using cabbage." - MickeyMouse
Symphonic
Symphonic
One way to do it is to make your dynamic library loader register software automatically, then every once in a while, the hard-disk GC runs and checks that every registered executable for any given dynamic library still exists on the system, the only trouble you might run into is that if you move the only executable that references a particular dynamic library, then you have to run that executable immediately to generate a new reference to its new location.

This could all be avoided if all files were stored in one place and the directory tree was built using a reference tree instead of an actual data tree.

George D. Filiotis

I am a signature virus. Please add me to your signature so that I may multiply.
Geordi
George D. Filiotis
superpig
superpig
I''m not so interested in having files referenced by other *files* (i.e. logical .EXEs); rather, treating all the files from one software package as a whole. I guess this reference-counting idea is more about a solution to package overlap...

I''m not just talking about dynamic link libraries, either. I''m talking about *all* files; the result is that uninstalling a software package should remove *all* of it''s crap from around the place. Apps that leave .ini files in the Windows folder, for example...

Plus, from the file identification point of view, it doesn''t help much to be told that "file ''somefile.dat'' is owned by C:\WINDOWS\SYSTEM\RMBPSDC.EXE," if you get my meaning. Application IDs would be system-wide symbols, and would have an actual name associated with them - suffice it to say that any package failing to identify itself properly would not be allowed to install.

Superpig
- saving pigs from untimely fates, and when he''s not doing that, runs The Binary Refinery.
Richard "Superpig" Fine - saving pigs from untimely fates - Microsoft DirectX MVP 2006/2007/2008/2009
"Shaders are not meant to do everything. Of course you can try to use it for everything, but it's like playing football using cabbage." - MickeyMouse

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.