File - partially Read-Only and partially Write-Only

Hi,

In Linux, Is it possible to make 25% of a file contents to be 'Read Only' and the remaining 75% of the file contents to be 'Write Only' ?

Thx in advans, Karthik Balaguru

Reply to
karthikbalaguru
Loading thread data ...

For a normal file system, I think that would be no - the concept would be too alien to how file systems and file access works. Of course, you could always build a FUSE filesystem with properties like that if you really need one.

Reply to
David Brown

On Mar 16, 3:47=A0pm, David Brown

Unless I've misunderstood something, isn't this simply an extreme case of record locking?

Reply to
larwe

I suppose so - you could create the file, then have a process write-lock

75% of it. It would require a process holding onto the lock as long as you want to keep the write protection in place.

It's probably better for the OP to think about what effect he is trying to achieve, and whether there are other ways to get there.

Reply to
David Brown

I am thinking of a scheme to Avoid the 'write' in certain section of file, while the other section should be 'writeable'.

I understand that there are some schemes in Linker Scripts/ Linker Descriptor File / Linker Command File to make certain section (Flash or RAM) as R / W.

But, i am interested in having few Files that will behave in that manner. (Partly write-only and Partly read-only). I was willing to know if there is such file system concept already in existence in linux and hence posted my above query.

What could be the propable method to come up with such a 'file' (partly read-only and partly write-only) in linux ? Any ideas ?

Thx in advans, Karthik Balaguru

Reply to
karthikbalaguru

Umm, not quite. Generally the the directives are to place items in read only or read-write memory not to mark the flash as read only (its non-writeability is a hardware function not a software one). I don't think I've ever seen a write only directive. It might be a useful language feature for matching hardware though.

Why write only? Why do you want to prevent reads?

propable?

Robert

Reply to
Robert Adsett

uld

se

ck

as

g

It should be read and write only. Obviously, write only of that particular area is not going to be of great use unless we are able to read it . I stated to be 'write-only' just to make it an example to start with . If we are able to make a file partly read-only & write- only, then we will be having the complete control over that functionality. So, my query was oriented with that.

It should be probable.

Karthik Balaguru

Reply to
karthikbalaguru

If the CPU's MMU supports it, and you are willing to access the file using memory dereferencing instead of fread/fwrite, then shared memory works, but I guess you already knew that.

Create a file mapping, two views of the file, one read-only, one write- only, and be prepared to catch the page faults if specifications are violated.

-Le Chaud Lapin-

Reply to
Le Chaud Lapin

Generally if you combine read only and write only you get no access not read/write. I think you've ended up simplifying to the point where the result is different from what you actually want.

OK. That simplifies things a lot. Stop worrying about using a single file. Use one file for the read only portion and a second for the read/write portion. That's more or less morally equivalent to your Flash/RAM dichotomy but on a Harvard architecture. Straightforward unless you need a single index into both for some reason. And it has the advantage of being portable as well as probable (by which I think you actually mean available or useable).

Robert

Reply to
Robert Adsett

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.