linux/fs.h, struct file_operations, (*lock) fuction ptr help

linux/fs.h, struct file_operations, (*lock) fuction ptr help

Post by Jim Fische » Thu, 30 Nov 2000 04:00:00



The kernel header file <linux/fs.h> declares a struct named
'file_operations' that contains a function pointer member named 'lock':

    struct file_operations {
        ...
        int (*lock) (struct file *, int, struct file_lock *);
        ...
    };

What's the lock function's 'int' argument used for -- i.e., what
value/information am I supposed to pass to the lock function via this 'int'
argument? Tks...

Jim

 
 
 

linux/fs.h, struct file_operations, (*lock) fuction ptr help

Post by Josef Moeller » Fri, 01 Dec 2000 16:41:18



> The kernel header file <linux/fs.h> declares a struct named
> 'file_operations' that contains a function pointer member named 'lock':

>     struct file_operations {
>         ...
>         int (*lock) (struct file *, int, struct file_lock *);
>         ...
>     };

> What's the lock function's 'int' argument used for -- i.e., what
> value/information am I supposed to pass to the lock function via this 'int'
> argument? Tks...

If you look into fs/locks.c, you'll find that this is something like
F_SETLK (e.g. look into fcn locks_remove_flock). In my 2.2.13 kernel
source, the first use of this I found in nfs/file.c (most other file
systems don't use this). Unfortunately it just passes this on to
nlmclnt_proc and I don't have enough time to follow this. Since you have
the sources ...

--
Josef M?llers (Pinguinpfleger bei FSC)
        If failure had no penalty success would not be a prize (T.  Pratchett)

 
 
 

1. Passing ptr to ptr to a function that takes ptr

Hi

I have the following program

#include <stdlib.h>
#include <stdio.h>

void call_func(void *t);

char test;
int main() {
        int b;
        void *a = (void *)&b;
        call_func(&a);
        return 0;

void call_func(void *t) {
        return;

As you can see I am passing a ptr to ptr to the function call_func when it
expects just a ptr. Now, this is pretty much an error. But I can not get
gcc to complain about it.

I tried with the following command line

gcc -Wall -pedantic -Wtraditional  -o aseem aseem.c

GCC version:
gcc version 2.95.3 20010315 (release)
This is on Sun Solaris 2.8

Any idea if any gcc option would flag the above as an error?

Thanks
Aseem.

2. console &dtlogin

3. about struct file_operations?

4. Inexpensive Alpha Linux box, where?

5. HPUX ptr -> SCO ptr

6. Logi.Mouse won't move, but is recognized.

7. Request: removal of fs/fs.h/super_block.u to enable partition locking

8. Azure LANpharoa

9. linux-2.5.66/fs/cramfs/inode.c typecheck - int vs. struct

10. fs/locks.c and fs/nfs/file.c cleanup

11. fs/locks.c: Fix posix locking for threaded tasks

12. fs/locks.c rewrite for better locking

13. Kyocera FS 1600 or FS 1600+ Printer drivers ( FS-1600 FS-1600+)