更新时间:2023-02-26 10:28:17
截断前面的文件似乎不难在系统级实现。
但有问题。
我们需要更复杂的访问(确实需要)我们以随机模式打开文件并添加一些内部结构信息。这些信息也可以在几个文件之间共享。这导致我们看到的最后一个问题,可能是最重要的。
我没有看到技术上的原因,为什么我们不能做所有的事情,目前在操作系统中使用数据库作为数据存储层。我甚至听说NTFS与内部数据库有许多共同点。一个操作系统可以(也可能会有一些不是那么远的功能)使用另一个范例而不是文件。总而言之,我认为这并不是一个技术上的问题,只是一个范式的改变,而删除开始绝对不是现在的文件范式,但不是一个大而有用的改变,迫使改变任何东西。
A problem I was working on recently got me to wishing that I could lop off the front of a file. Kind of like a "truncate at front," if you will. Truncating a file at the back end is a common operation–something we do without even thinking much about it. But lopping off the front of a file? Sounds ridiculous at first, but only because we’ve been trained to think that it’s impossible. But a lop operation could be useful in some situations.
A simple example (certainly not the only or necessarily the best example) is a FIFO queue. You’re adding new items to the end of the file and pulling items out of the file from the front. The file grows over time and there’s a huge empty space at the front. With current file systems, there are several ways around this problem:
But if there was a lop operation, removing an item from the queue would be as easy as updating the beginning-of-file marker. As easy, in fact, as truncating a file. Why, then, is there no such operation?
I understand a bit about file systems implementation, and don't see any particular reason this would be difficult. It looks to me like all it would require is another word (dword, perhaps?) per allocation entry to say where the file starts within the block. With 1 terabyte drives under $100 US, it seems like a pretty small price to pay for such functionality.
What other tasks would be made easier if you could lop off the front of a file as efficiently as you can truncate at the end?
Can you think of any technical reason this function couldn't be added to a modern file system? Other, non-technical reasons?
Truncate files at front seems not to hard to implement at system level.
But there is issues.
In other words truncating the beginning would change the only reference point and that is bad.
We we want more complex accesses (and there is indeed need) we open files in random mode and add some internal structure information. This information can also be shared between several files. This lead us to the last issue I see, probably the most important.
I see no technical reason why we couldn't do everything is currently done in an operating system with files using a database as data storage layer. I even heard that NTFS has many common points with databases in it's internals. An operating system can (and probably will in some not so far feature) use another paradigm than files one.
Summarily i believe that's no technical problemat all, just a change of paradigm and that removing the beginning is definitely not in the current file paradigm, but not a big and useful enough change to compel changing anything at all.