1. This forum section is a read-only archive which contains old newsgroup posts. If you wish to post a query, please do so in one of our main forum sections (here). This way you will get a faster, better response from the members on Motherboard Point.

File - partially Read-Only and partially Write-Only

Discussion in 'Embedded' started by karthikbalaguru, Mar 16, 2008.

  1. 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
     
    karthikbalaguru, Mar 16, 2008
    #1
    1. Advertisements

  2. karthikbalaguru

    David Brown Guest

    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.
     
    David Brown, Mar 16, 2008
    #2
    1. Advertisements

  3. karthikbalaguru

    larwe Guest

    On Mar 16, 3:47 pm, David Brown
    Unless I've misunderstood something, isn't this simply an extreme case
    of record locking?
     
    larwe, Mar 16, 2008
    #3
  4. karthikbalaguru

    David Brown Guest

    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.
     
    David Brown, Mar 17, 2008
    #4
  5. 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
     
    karthikbalaguru, Mar 18, 2008
    #5
  6. 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
     
    Robert Adsett, Mar 18, 2008
    #6
  7. 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
     
    karthikbalaguru, Mar 18, 2008
    #7
  8. 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-
     
    Le Chaud Lapin, Mar 18, 2008
    #8
  9. 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
     
    Robert Adsett, Mar 18, 2008
    #9
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.