Locking Files with FILE pointers

Locking Files with FILE pointers

Post by fioru.. » Fri, 06 Aug 1993 23:55:36



Hello World !!

I need to lock files, but I use FILE struct instead of int.
the locking() & lockf() system calls use only fildes (open) and not
FILE (fopen).
Can anyone tell me what system call may I use or if I can
transform my FILE pointer into a fildes to use lockf or locking.

Thanks in advance

                                                JL

 
 
 

Locking Files with FILE pointers

Post by Hammond Eg » Sat, 07 Aug 1993 00:56:51



>I need to lock files, but I use FILE struct instead of int.
>the locking() & lockf() system calls use only fildes (open) and not
>FILE (fopen).
>Can anyone tell me what system call may I use or if I can
>transform my FILE pointer into a fildes to use lockf or locking.

locking(fileno(file), mode, size);

  will work, however, i prefer the fcntl() locking method, myself.
(man fcntl should give you all the*details)

  Matt

 
 
 

Locking Files with FILE pointers

Post by Spencer S » Sat, 07 Aug 1993 01:04:01



Quote:>I need to lock files, but I use FILE struct instead of int.

[...]

fileno() gives you the file descriptor associated with a FILE *.

____                         : It's the terror of knowing / What this world is
\  / sss / PU Class of '94   : about / Watching some good friends / Screaming
 \/ Dept of Computer Science : "Let me out!"  [Queen/Bowie, "Under Pressure"]

 
 
 

1. File Locking with FILE pointers

Hello World !!

I need to lock files, but I use FILE struct instead of int.
the locking() & lockf() system calls use only fildes (open) and not
FILE (fopen).
Can anyone tell me what system call may I use or if I can
transform my FILE pointer into a fildes to use lockf or locking.

Thanks in advance

                                                JL

2. Installing on a hd with a corrupted partion table

3. difference b/w file pointer and file descriptor

4. VNC Server on Linux but in Winvnc-Style remote control mode

5. file name from file pointer?

6. Bad Super Block

7. file descriptors or FILE pointers?

8. SSL docs

9. How to find pathname of a file given the file pointer/descripter

10. mkstemp, files pointers and file descriptors

11. Locking a file temporarily (till the file is transferred completely).

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

13. File locking text file in linux using C