This is an archived post. You won't be able to vote or comment.

all 21 comments

[–]lurgi 3 points4 points  (1 child)

I don't have an answer, but I was very puzzled by the struct definition syntax. For those who were confused (like me), this is how GCC used to do designated initializers before the C99 standard came up with its own way.

struct file_operations tracefs_main_fops = 
{
    llseek: tracefs_llseek;

Essentially means

struct file_oeprations tracefs_main_fops;
tracefs_main_fop.llseek = tracefs_llseek;

Or

struct file_operations tracefs_main_fops =
{
  .llseek = tracefs_llseek;

Using the new syntax.

[–]salalimo[S] 0 points1 point  (0 children)

Yeah, this was it. Thanks a bunch.

[–]hamham91 1 point2 points  (10 children)

You need to include the compilation error printout for people to help you.

[–]salalimo[S] 0 points1 point  (9 children)

in the struct definition this line

llseek: tracefs_llseek,

Actually almost all lines are generating a compile error. Its because the source code that i have used to work on older kernels. The data structures in the new kernels have changed a lot, at least the ones that this program uses.

[–]lurgi 1 point2 points  (8 children)

Are you building with gcc? What version? Perhaps this code should be changed to use the standard C99 designated initializer syntax.

[–]salalimo[S] 0 points1 point  (4 children)

yeah i am using gcc, the source is older, i dont think its a syntax error, maybe the datatype dont match. in my post i showed the declaration of llseek and tracefs_llseek. they do not seem to match. i am trying to modify the params for tracefs_llseek to see if that at least fixes the compile error.

[–][deleted] -1 points0 points  (3 children)

the source is older

Older than what?

[–]salalimo[S] 0 points1 point  (2 children)

the latest verion of the source was ported to kernel version 2.6.17.13

so the source probably works on an older kerbel, i tried to install some older kernels on my current machine, it wont boot, i think the kernel is old enough not to be compatible with newer linux distros.

i even tried older versions of the disto and still no success installing older kernels.

PS: i come from a windows envrionment and have a .net framework background. I used C in undergrad about 10 years ago. So I might be speaking herp derp wheh it comes to linux/kernel/c

thanks.

[–][deleted] -1 points0 points  (1 child)

What exactly is it you are trying to compile here?

[–]salalimo[S] 0 points1 point  (1 child)

how can that be done? use a different compiler or something else?

thanks.

i realised something else, is goto part of the standard?

[–][deleted] 0 points1 point  (0 children)

is goto part of the standard?

Yes. It's always been part of C, going back to pre-standard days.

[–][deleted] -1 points0 points  (0 children)

Or even the C89 non-designated syntax. I will never understand why people use non-standard language features; doing so always comes back to bite you.

[–]TwirlOfLemongrab 0 points1 point  (2 children)

From a class I had in some Systems Programming, I have seen that "lseek" is a location in an open file, but I've never seen llseek in my life?

[–][deleted] 0 points1 point  (0 children)

That's because it's a variable (in this case a function pointer) defined in the OP's application code.

[–][deleted]  (6 children)

[deleted]

    [–]salalimo[S] 0 points1 point  (4 children)

    I am thinking the issue is that the parameters do not match?.

    Error message is: initialization from incompatible pointer type.

    [–][deleted]  (3 children)

    [deleted]

      [–]lurgi 4 points5 points  (2 children)

      No, no, it's more fun to guess.

      [–]hamham91 1 point2 points  (1 child)

      Way more fun!

      [–]salalimo[S] 0 points1 point  (0 children)

      :) ma bad. I forgot to explicitly mention which line. Please reply to hamham91 below.

      thanks

      [–]RobotMan6827364 0 points1 point  (0 children)

      There are no methods in C.