13.07.2015 Views

An Operating Systems Vade Mecum

An Operating Systems Vade Mecum

An Operating Systems Vade Mecum

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Naming structure of files 191the aliases of a file could be listed in a common place, perhaps along with the contentsof the file itself.A nice alternative is to allow the file to remain intact until the last alias isdeleted. A reference count can be stored with the file to indicate how many aliasesit has. Most files have just one alias, so they have reference count 1. Files thathave been placed in several directories (or several times in the same directory)have a higher reference count. Making a new alias raises the count. Deleting a fileremoves its entry in a directory, reduces its count, and preserves the file if thecount is not yet zero. If the count is zero, the file’s data can be discarded and itsdisk space reclaimed. A user who wants to delete a file completely must know allits aliases.Accounting: Many operating systems charge users in proportion to how much diskspace (in sectors, for example) each user’s files are occupying at the end of eachday. Who should pay for the disk space occupied by a file that has several aliases?We might charge the ‘‘owner’’ of the file, that is, the user who first created it.Ownership would be stored with the file, not with the directory entry, to avoid havingseveral owners of the same file. However, this policy can be unfair. A student,Patish Shamir, has built the file project.mod. The instructor has made an aliasfor it, called shamir.mod. Patish is paying for the disk space. Now Patishdeletes the file at the end of the semester. Since the instructor never gets around todeleting shamir.mod, it remains. Patish is still paying for the file but has noway to delete it, since the instructor’s files are protected from him. In fact, Patishmay graduate and lose his account on the machine. There is nobody left to bill forthis file.A different accounting policy would be to charge each user for the files inthat user’s directory in proportion to the percentage of the file that is in the directory.For example, a file with only one name is entirely in its directory. A file withtwo aliases is charged half to one directory and half to the other. Patish Shamir’sproject file is charged half to him and half to the instructor until Patish deletes it,after which it is charged entirely to the instructor. Even this policy is not completelyfair. Before Patish deletes the file, he might (maliciously) add an enormousamount of data to it. The instructor is left paying for the whole file and has no ideathat Patish was so unkind.If the file structures allow aliasing, moving a file from one directory to another canbe very inexpensive and independent of the length of the file. Instead of copying the fileto a new name, the new name can be made an alias for the file, and then the file can bedeleted under the old name. Since there is still at least one outstanding reference to it, thefile is not deleted. If aliasing is not allowed, inexpensive file movement can still be providedby a service call.Move(old name, new name). This call has the same effect as Alias, except thatit removes the old name. This call is provided only if Alias is not.BSD4.2 Unix permits another, looser form of aliasing. <strong>An</strong> indirect file is a filethat contains nothing but the name (either absolute or relative) of another file.Indirect(old name, new name). This call builds a new indirect file for the oldfile.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!