[linux] Ako na BLBOST: zapisanie do file s read only pravami...

Matus Horvath horvathm na decef.elf.stuba.sk
Úterý Listopad 12 22:01:36 CET 2002


Sunday, November 10, 2002, 9:37:49 PM, you wrote:

pF> Vazeny linux expeti!

pF> Stretol som sa s podivuhodnym problem...
pF> Pri programovani aplikacii pre ludi zvyknutych na norton comander (prechod z DOS na LINUX) som vytvoril kod, ktory ma znemoznit zapis do suboru -meno sa voli...
pF> Zaujimave je, ze to nerobi... hoci pocas spustenia mcedit som na textovej konzole zistil pomocou ls -la prava toho suboru vlastik -len citanie, skupina vlastnka-len citanie a ostatny-len
pF> citanie... Po zapise z tohto editora sa vsak obsah suboru zmenil!!!!!!!!!!!!!!
pF> Zeby bol problem, v tom, ze program musi bezat s prioritou -20?

pF> Nevie niekto poradit,prosim? Som z toho na vetvy.... mcedit ani len nepyskuje, ze subor je read only....
pF> Skusim este pico, hoci to bude pre tych uzivatelov dost neprehladne... vi asi neprichadza do uvahy...
--snip--

Hi

Kratky vyskum problemu:

$ mcedit --help
... bla bla ...
-v, --view fname   Start up into the viewer mode.
... bla bla ...
$ mcedit -v file.txt

Vysledok: subor sa otvori tak ako ked das v mc F3.

Dalsi vyskum:
$ man mcedit

# Z nasledujuceho manualu IMHO vyplyva ze:
# Ak mas zapnuty save mod (1), vytvori sa pri ukladani uplne novy
# subor, do neho sa ulozi obsah a potom sa novy subor premenuje.
# Podla mna teda nepomoze nastavenie akychkolvek prav na povodny
# subor, musel by si nastavit prava na adresar, aby sa nemohol
# pri ukladani vyrobit novy subor. Samozrejme ak je default
# save mod (1).

... bla bla ...
       editor_option_save_mode
              (0,  1  or  2.) The save mode (see the options menu
              also) allows you to change the method of  saving  a
              file. Quick save (0) saves the file by immediately,
              truncating the disk file to zero length (i.e. eras-
              ing  it) and the writing the editor contents to the
              file. This method is fast, but dangerous,  since  a
              system error during a file save will leave the file
              only partially written, possibly rendering the data
              irretrievable.  When  saving,  the  safe  save  (1)
              option enables creation of a  temporary  file  into
              which  the  file contents are first written. In the
              event  of  an  problem,  the   original   file   is
              untouched.  When the temporary file is successfully
              written, it is renamed to the name of the  original
              file,  thus replacing it. The safest method is cre-
              ate backups (2). Where a  backup  file  is  created
              before  any  changes are made. You can specify your
              own backup file extension in the dialog. Note  that
              saving  twice  will  replace your backup as well as
              your original file.
... bla bla ...

zdar

Matus Horvath

/\/\ /-\ "|" \_/ $    ]-[ () |^ \/ /-\ "|" ]-[
ICQ: 33936477
mailto:horvathm na decef.elf.stuba.sk
http://www.elf.stuba.sk/~horvathm





Další informace o konferenci linux