Writing to segments of files, Record Locks

Writing to segments of files, Record Locks

Post by Hooman Katira » Thu, 13 Feb 1997 04:00:00



Can one write to a segment of a file without overwriting the rest?
I want to have several processes write to a file. To prevent them from
overwriting each other's information I plan to use record locking to
lock segments of the file. If a line (record) is not locked I want to
overwrite that line without affecting the rest of the file. Is this
possible?

Hooman

 
 
 

Writing to segments of files, Record Locks

Post by » Fri, 14 Feb 1997 04:00:00


Quote:> Can one write to a segment of a file without overwriting the rest?

Yes. lseek or fseek to where you want to start and the write or fwrite (or
fprintf or fputc or ...).

--
His hands are cold and heart is hot     |   S M Ryan, Cupertino CA

The shadowed glooms are shapeless dooms.| or risk losing the mail.
He dreads the lessons demon-taught.     |  I don't use no smileys.

 
 
 

Writing to segments of files, Record Locks

Post by Shado » Mon, 17 Feb 1997 04:00:00



>Can one write to a segment of a file without overwriting the rest?
>I want to have several processes write to a file. To prevent them from
>overwriting each other's information I plan to use record locking to
>lock segments of the file. If a line (record) is not locked I want to
>overwrite that line without affecting the rest of the file. Is this
>possible?

Very possible, flock_t and fcntl's flag of F_SETLK it allows you to specify
how much of the file, and where in the file.
You can choose between mandatory kernel locks, and advisory locks.

------------------------------------------------------------------------------
Thamer Al-Herbish (ShadowS)     The views expressed here, have no relevance


              "illegitimi non carborundum"
-------------------------------------------------------------------------------

 
 
 

1. Exclusive Unix file system file write locks and Oracle and Veritas

Hi,

I've read that having smaller file sizes on OLTP systems is good for
performance b/c of locks. But what about the Veritas File system? Is
there are some system variables I can change?

Thanx
---------------
Andrey Dmitriev  eFax: (978) 383-5892  Daytime: (917) 373-5417
AOL: NetComrade  ICQ: 11340726 remove NSPAM to email

2. YellowDog - no ethernet

3. File locking and data written to the end of a file

4. diald and RedHat 5.0

5. file- or record-locking with linux?

6. serial cd-rom

7. Locking records/files by pcnfsd

8. Kmail Deleted Messages Still Around

9. Who has a record locked in a file

10. kernel file/record locking problem

11. Using shell script can I implement record locking on file ?

12. Help: out of record file locks

13. File and record locks