Error in adding system call in OpenBSD 6.3

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Error in adding system call in OpenBSD 6.3

neerajpal
Hello guys,

I am facing some issue during adding system call on OpenBSD 6.3. I
have shown my pathways to add system call, please guys correct me if
somewhere I have forgotten something to add or build.

1) echo "331 { int sys_hello(void); }" >> /usr/src/sys/kern/syscalls.master

2) make init_sysent.c

3) /usr/src/sys/kern/sys_hello.c

#include <sys/types.h>
#include <sys/param.h>
#include <sys/kernel.h>
#include <sys/syscallargs.h>

int
sys_hello(struct proc *p, void *v, register_t *retval)
{
printf("Hello world from kernel space.\n");
return (0);
}

4) echo "file kern/sys_hello.c" >> /usr/src/sys/conf/files

5) cd /usr/src/sys/arch/amd64/compile/CUSTOM.MP/

6) make obj && make -j4

And, then, It throws an error given below,

"
ld -T ld.script -X --warn-common -nopie -o bsd ${SYSTEM_HEAD} vers.o ${OBJS}

init_sysent.o:(.data+0x14b8): undefined reference to `sys_hello'

*** Error 1 in /usr/src/sys/arch/amd64/compile/CUSTOM.MP (Makefile:918
'bsd': @echo ld -T ld.script -X --warn-common -nopie -o bsd
'${SYSTEM...)
"

I have even tried to "make" with "-n" and "-d"options, so, that I can
debug make process, but, it didn't help me.

I have also tried to manually include sys.hello.o in {OBJS} in file
"/usr/src/sys/arch/amd64/compile/CUSTOM.MP/obj/Makefile" and also in
{CFILES} etc. like all other system calls files included. For example,
sys_generic.c etc.

But, some days ago, I did the same with OpenBSD 6.2 or 6.3 (I forgot)
in VirtualBox and it was working at that time.
The system call was added successfully at that time.

Reply | Threaded
Open this post in threaded view
|

Re: Error in adding system call in OpenBSD 6.3

Paul Irofti-4
On Sun, Apr 22, 2018 at 12:23:09AM +0530, Neeraj Pal wrote:
> Hello guys,
>
> I am facing some issue during adding system call on OpenBSD 6.3. I
> have shown my pathways to add system call, please guys correct me if
> somewhere I have forgotten something to add or build.
>
> 1) echo "331 { int sys_hello(void); }" >> /usr/src/sys/kern/syscalls.master
>
> 2) make init_sysent.c

I don't know what this does, but you are supposed to run
kern/makesyscalls.sh after modifying syscalls.master.

Reply | Threaded
Open this post in threaded view
|

Re: Error in adding system call in OpenBSD 6.3

neerajpal
On Sun, Apr 22, 2018 at 3:14 AM, Paul Irofti <[hidden email]> wrote:

> On Sun, Apr 22, 2018 at 12:23:09AM +0530, Neeraj Pal wrote:
>> Hello guys,
>>
>> I am facing some issue during adding system call on OpenBSD 6.3. I
>> have shown my pathways to add system call, please guys correct me if
>> somewhere I have forgotten something to add or build.
>>
>> 1) echo "331 { int sys_hello(void); }" >> /usr/src/sys/kern/syscalls.master
>>
>> 2) make init_sysent.c
>
> I don't know what this does, but you are supposed to run
> kern/makesyscalls.sh after modifying syscalls.master.

Oh, okay. But, "make init_sysent.c" will regenerate the init_sysent.c,
syscalls.c, syscallargs.h, and syscalls.h files, all of which depend
on syscalls.master.
And, I think all are same, I mean if you do "sh makesyscalls.sh
syscalls.conf syscalls.master" or "make syscalls" or "make
init_sysent.c", they all produce the same result.

Reply | Threaded
Open this post in threaded view
|

Re: Error in adding system call in OpenBSD 6.3

Ted Unangst-6
In reply to this post by neerajpal
Neeraj Pal wrote:

> 4) echo "file kern/sys_hello.c" >> /usr/src/sys/conf/files
>
> 5) cd /usr/src/sys/arch/amd64/compile/CUSTOM.MP/
>
> 6) make obj && make -j4
>
> And, then, It throws an error given below,
>
> "
> ld -T ld.script -X --warn-common -nopie -o bsd ${SYSTEM_HEAD} vers.o ${OBJS}
>
> init_sysent.o:(.data+0x14b8): undefined reference to `sys_hello'

this looks like the object wasn't added. you skipped make config.

Reply | Threaded
Open this post in threaded view
|

Re: Error in adding system call in OpenBSD 6.3

neerajpal
okay. Sure,

Instead of sys_hello.c I created a new one sys_test.c. So, guys don't
confuse with above sys_hello.c and this time sys_test.c, both are the
same file.

Then after that, I went through all the steps including "make config"

make obj && make config && make -j4

Then it throws this error this time. And, I am not able to understand this.


In file included from /usr/src/sys/kern/sys_test.c:4:
/usr/src/sys/sys/syscallargs.h:153:13: error: unknown type name
'socklen_t'; did you mean '__socklen_t'?
        syscallarg(socklen_t *) fromlenaddr;
                   ^~~~~~~~~
                   __socklen_t
/usr/src/sys/sys/syscallargs.h:17:12: note: expanded from macro 'syscallarg'
                struct { x datum; } le;                                 \
                         ^
/usr/src/sys/sys/_types.h:61:20: note: '__socklen_t' declared here
typedef __uint32_t      __socklen_t;    /* length type for network syscalls */
                        ^
In file included from /usr/src/sys/kern/sys_test.c:4:
/usr/src/sys/sys/syscallargs.h:153:2: error: expected expression
        syscallarg(socklen_t *) fromlenaddr;
        ^
/usr/src/sys/sys/syscallargs.h:19:48: note: expanded from macro 'syscallarg'
                        int8_t pad[ (sizeof (register_t) < sizeof (x))  \
                                                                    ^
/usr/src/sys/sys/syscallargs.h:153:13: error: use of undeclared
identifier 'socklen_t'
        syscallarg(socklen_t *) fromlenaddr;
                   ^
/usr/src/sys/sys/syscallargs.h:153:2: error: expected expression
        syscallarg(socklen_t *) fromlenaddr;
        ^
/usr/src/sys/sys/syscallargs.h:21:38: note: expanded from macro 'syscallarg'
                                : sizeof (register_t) - sizeof (x)];    \
                                                                 ^
/usr/src/sys/sys/syscallargs.h:153:13: error: use of undeclared
identifier 'socklen_t'
        syscallarg(socklen_t *) fromlenaddr;
                   ^
/usr/src/sys/sys/syscallargs.h:153:13: error: unknown type name
'socklen_t'; did you mean '__socklen_t'?
        syscallarg(socklen_t *) fromlenaddr;
                   ^~~~~~~~~
                   __socklen_t
/usr/src/sys/sys/syscallargs.h:22:4: note: expanded from macro 'syscallarg'
                        x datum;                                        \
                        ^
/usr/src/sys/sys/_types.h:61:20: note: '__socklen_t' declared here
typedef __uint32_t      __socklen_t;    /* length type for network syscalls */
                        ^
In file included from /usr/src/sys/kern/sys_test.c:4:
/usr/src/sys/sys/syscallargs.h:159:13: error: unknown type name
'socklen_t'; did you mean '__socklen_t'?
        syscallarg(socklen_t *) anamelen;
                   ^~~~~~~~~
                   __socklen_t
/usr/src/sys/sys/syscallargs.h:17:12: note: expanded from macro 'syscallarg'
                struct { x datum; } le;                                 \
                         ^
/usr/src/sys/sys/_types.h:61:20: note: '__socklen_t' declared here
typedef __uint32_t      __socklen_t;    /* length type for network syscalls */
                        ^
In file included from /usr/src/sys/kern/sys_test.c:4:
/usr/src/sys/sys/syscallargs.h:159:2: error: expected expression
        syscallarg(socklen_t *) anamelen;
        ^
/usr/src/sys/sys/syscallargs.h:19:48: note: expanded from macro 'syscallarg'
                        int8_t pad[ (sizeof (register_t) < sizeof (x))  \
                                                                    ^
/usr/src/sys/sys/syscallargs.h:159:13: error: use of undeclared
identifier 'socklen_t'
        syscallarg(socklen_t *) anamelen;
                   ^
/usr/src/sys/sys/syscallargs.h:159:2: error: expected expression
        syscallarg(socklen_t *) anamelen;
        ^
/usr/src/sys/sys/syscallargs.h:21:38: note: expanded from macro 'syscallarg'
                                : sizeof (register_t) - sizeof (x)];    \
                                                                 ^
/usr/src/sys/sys/syscallargs.h:159:13: error: use of undeclared
identifier 'socklen_t'
        syscallarg(socklen_t *) anamelen;
                   ^
/usr/src/sys/sys/syscallargs.h:159:13: error: unknown type name
'socklen_t'; did you mean '__socklen_t'?
        syscallarg(socklen_t *) anamelen;
                   ^~~~~~~~~
                   __socklen_t
/usr/src/sys/sys/syscallargs.h:22:4: note: expanded from macro 'syscallarg'
                        x datum;                                        \
                        ^
/usr/src/sys/sys/_types.h:61:20: note: '__socklen_t' declared here
typedef __uint32_t      __socklen_t;    /* length type for network syscalls */
                        ^
In file included from /usr/src/sys/kern/sys_test.c:4:
/usr/src/sys/sys/syscallargs.h:165:13: error: unknown type name
'socklen_t'; did you mean '__socklen_t'?
        syscallarg(socklen_t *) alen;
                   ^~~~~~~~~
                   __socklen_t
/usr/src/sys/sys/syscallargs.h:17:12: note: expanded from macro 'syscallarg'
                struct { x datum; } le;                                 \
                         ^
/usr/src/sys/sys/_types.h:61:20: note: '__socklen_t' declared here
typedef __uint32_t      __socklen_t;    /* length type for network syscalls */
                        ^
In file included from /usr/src/sys/kern/sys_test.c:4:
/usr/src/sys/sys/syscallargs.h:165:2: error: expected expression
        syscallarg(socklen_t *) alen;
        ^
/usr/src/sys/sys/syscallargs.h:19:48: note: expanded from macro 'syscallarg'
                        int8_t pad[ (sizeof (register_t) < sizeof (x))  \
                                                                    ^
/usr/src/sys/sys/syscallargs.h:165:13: error: use of undeclared
identifier 'socklen_t'
        syscallarg(socklen_t *) alen;
                   ^
/usr/src/sys/sys/syscallargs.h:165:2: error: expected expression
        syscallarg(socklen_t *) alen;
        ^
/usr/src/sys/sys/syscallargs.h:21:38: note: expanded from macro 'syscallarg'
                                : sizeof (register_t) - sizeof (x)];    \
                                                                 ^
/usr/src/sys/sys/syscallargs.h:165:13: error: use of undeclared
identifier 'socklen_t'
        syscallarg(socklen_t *) alen;
                   ^
/usr/src/sys/sys/syscallargs.h:165:13: error: unknown type name
'socklen_t'; did you mean '__socklen_t'?
        syscallarg(socklen_t *) alen;
                   ^~~~~~~~~
                   __socklen_t
/usr/src/sys/sys/syscallargs.h:22:4: note: expanded from macro 'syscallarg'
                        x datum;                                        \
                        ^
/usr/src/sys/sys/_types.h:61:20: note: '__socklen_t' declared here
typedef __uint32_t      __socklen_t;    /* length type for network syscalls */
                        ^
In file included from /usr/src/sys/kern/sys_test.c:4:
/usr/src/sys/sys/syscallargs.h:171:13: error: unknown type name
'socklen_t'; did you mean '__socklen_t'?
        syscallarg(socklen_t *) alen;
                   ^~~~~~~~~
                   __socklen_t
/usr/src/sys/sys/syscallargs.h:17:12: note: expanded from macro 'syscallarg'
                struct { x datum; } le;                                 \
                         ^
/usr/src/sys/sys/_types.h:61:20: note: '__socklen_t' declared here
typedef __uint32_t      __socklen_t;    /* length type for network syscalls */
                        ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
*** Error 1 in /usr/src/sys/arch/amd64/compile/CUSTOM.MP
(Makefile:1018 'sys_test.o')









On Tue, Apr 24, 2018 at 12:18 AM, Ted Unangst <[hidden email]> wrote:

> Neeraj Pal wrote:
>> 4) echo "file kern/sys_hello.c" >> /usr/src/sys/conf/files
>>
>> 5) cd /usr/src/sys/arch/amd64/compile/CUSTOM.MP/
>>
>> 6) make obj && make -j4
>>
>> And, then, It throws an error given below,
>>
>> "
>> ld -T ld.script -X --warn-common -nopie -o bsd ${SYSTEM_HEAD} vers.o ${OBJS}
>>
>> init_sysent.o:(.data+0x14b8): undefined reference to `sys_hello'
>
> this looks like the object wasn't added. you skipped make config.

Reply | Threaded
Open this post in threaded view
|

Re: Error in adding system call in OpenBSD 6.3

Theo de Raadt-2
So..... you don't know what you are doing.


Neeraj Pal <[hidden email]> wrote:

> okay. Sure,
>
> Instead of sys_hello.c I created a new one sys_test.c. So, guys don't
> confuse with above sys_hello.c and this time sys_test.c, both are the
> same file.
>
> Then after that, I went through all the steps including "make config"
>
> make obj && make config && make -j4
>
> Then it throws this error this time. And, I am not able to understand this.
>
>
> In file included from /usr/src/sys/kern/sys_test.c:4:
> /usr/src/sys/sys/syscallargs.h:153:13: error: unknown type name
> 'socklen_t'; did you mean '__socklen_t'?
>         syscallarg(socklen_t *) fromlenaddr;
>                    ^~~~~~~~~
>                    __socklen_t
> /usr/src/sys/sys/syscallargs.h:17:12: note: expanded from macro 'syscallarg'
>                 struct { x datum; } le;                                 \
>                          ^
> /usr/src/sys/sys/_types.h:61:20: note: '__socklen_t' declared here
> typedef __uint32_t      __socklen_t;    /* length type for network syscalls */
>                         ^
> In file included from /usr/src/sys/kern/sys_test.c:4:
> /usr/src/sys/sys/syscallargs.h:153:2: error: expected expression
>         syscallarg(socklen_t *) fromlenaddr;
>         ^
> /usr/src/sys/sys/syscallargs.h:19:48: note: expanded from macro 'syscallarg'
>                         int8_t pad[ (sizeof (register_t) < sizeof (x))  \
>                                                                     ^
> /usr/src/sys/sys/syscallargs.h:153:13: error: use of undeclared
> identifier 'socklen_t'
>         syscallarg(socklen_t *) fromlenaddr;
>                    ^
> /usr/src/sys/sys/syscallargs.h:153:2: error: expected expression
>         syscallarg(socklen_t *) fromlenaddr;
>         ^
> /usr/src/sys/sys/syscallargs.h:21:38: note: expanded from macro 'syscallarg'
>                                 : sizeof (register_t) - sizeof (x)];    \
>                                                                  ^
> /usr/src/sys/sys/syscallargs.h:153:13: error: use of undeclared
> identifier 'socklen_t'
>         syscallarg(socklen_t *) fromlenaddr;
>                    ^
> /usr/src/sys/sys/syscallargs.h:153:13: error: unknown type name
> 'socklen_t'; did you mean '__socklen_t'?
>         syscallarg(socklen_t *) fromlenaddr;
>                    ^~~~~~~~~
>                    __socklen_t
> /usr/src/sys/sys/syscallargs.h:22:4: note: expanded from macro 'syscallarg'
>                         x datum;                                        \
>                         ^
> /usr/src/sys/sys/_types.h:61:20: note: '__socklen_t' declared here
> typedef __uint32_t      __socklen_t;    /* length type for network syscalls */
>                         ^
> In file included from /usr/src/sys/kern/sys_test.c:4:
> /usr/src/sys/sys/syscallargs.h:159:13: error: unknown type name
> 'socklen_t'; did you mean '__socklen_t'?
>         syscallarg(socklen_t *) anamelen;
>                    ^~~~~~~~~
>                    __socklen_t
> /usr/src/sys/sys/syscallargs.h:17:12: note: expanded from macro 'syscallarg'
>                 struct { x datum; } le;                                 \
>                          ^
> /usr/src/sys/sys/_types.h:61:20: note: '__socklen_t' declared here
> typedef __uint32_t      __socklen_t;    /* length type for network syscalls */
>                         ^
> In file included from /usr/src/sys/kern/sys_test.c:4:
> /usr/src/sys/sys/syscallargs.h:159:2: error: expected expression
>         syscallarg(socklen_t *) anamelen;
>         ^
> /usr/src/sys/sys/syscallargs.h:19:48: note: expanded from macro 'syscallarg'
>                         int8_t pad[ (sizeof (register_t) < sizeof (x))  \
>                                                                     ^
> /usr/src/sys/sys/syscallargs.h:159:13: error: use of undeclared
> identifier 'socklen_t'
>         syscallarg(socklen_t *) anamelen;
>                    ^
> /usr/src/sys/sys/syscallargs.h:159:2: error: expected expression
>         syscallarg(socklen_t *) anamelen;
>         ^
> /usr/src/sys/sys/syscallargs.h:21:38: note: expanded from macro 'syscallarg'
>                                 : sizeof (register_t) - sizeof (x)];    \
>                                                                  ^
> /usr/src/sys/sys/syscallargs.h:159:13: error: use of undeclared
> identifier 'socklen_t'
>         syscallarg(socklen_t *) anamelen;
>                    ^
> /usr/src/sys/sys/syscallargs.h:159:13: error: unknown type name
> 'socklen_t'; did you mean '__socklen_t'?
>         syscallarg(socklen_t *) anamelen;
>                    ^~~~~~~~~
>                    __socklen_t
> /usr/src/sys/sys/syscallargs.h:22:4: note: expanded from macro 'syscallarg'
>                         x datum;                                        \
>                         ^
> /usr/src/sys/sys/_types.h:61:20: note: '__socklen_t' declared here
> typedef __uint32_t      __socklen_t;    /* length type for network syscalls */
>                         ^
> In file included from /usr/src/sys/kern/sys_test.c:4:
> /usr/src/sys/sys/syscallargs.h:165:13: error: unknown type name
> 'socklen_t'; did you mean '__socklen_t'?
>         syscallarg(socklen_t *) alen;
>                    ^~~~~~~~~
>                    __socklen_t
> /usr/src/sys/sys/syscallargs.h:17:12: note: expanded from macro 'syscallarg'
>                 struct { x datum; } le;                                 \
>                          ^
> /usr/src/sys/sys/_types.h:61:20: note: '__socklen_t' declared here
> typedef __uint32_t      __socklen_t;    /* length type for network syscalls */
>                         ^
> In file included from /usr/src/sys/kern/sys_test.c:4:
> /usr/src/sys/sys/syscallargs.h:165:2: error: expected expression
>         syscallarg(socklen_t *) alen;
>         ^
> /usr/src/sys/sys/syscallargs.h:19:48: note: expanded from macro 'syscallarg'
>                         int8_t pad[ (sizeof (register_t) < sizeof (x))  \
>                                                                     ^
> /usr/src/sys/sys/syscallargs.h:165:13: error: use of undeclared
> identifier 'socklen_t'
>         syscallarg(socklen_t *) alen;
>                    ^
> /usr/src/sys/sys/syscallargs.h:165:2: error: expected expression
>         syscallarg(socklen_t *) alen;
>         ^
> /usr/src/sys/sys/syscallargs.h:21:38: note: expanded from macro 'syscallarg'
>                                 : sizeof (register_t) - sizeof (x)];    \
>                                                                  ^
> /usr/src/sys/sys/syscallargs.h:165:13: error: use of undeclared
> identifier 'socklen_t'
>         syscallarg(socklen_t *) alen;
>                    ^
> /usr/src/sys/sys/syscallargs.h:165:13: error: unknown type name
> 'socklen_t'; did you mean '__socklen_t'?
>         syscallarg(socklen_t *) alen;
>                    ^~~~~~~~~
>                    __socklen_t
> /usr/src/sys/sys/syscallargs.h:22:4: note: expanded from macro 'syscallarg'
>                         x datum;                                        \
>                         ^
> /usr/src/sys/sys/_types.h:61:20: note: '__socklen_t' declared here
> typedef __uint32_t      __socklen_t;    /* length type for network syscalls */
>                         ^
> In file included from /usr/src/sys/kern/sys_test.c:4:
> /usr/src/sys/sys/syscallargs.h:171:13: error: unknown type name
> 'socklen_t'; did you mean '__socklen_t'?
>         syscallarg(socklen_t *) alen;
>                    ^~~~~~~~~
>                    __socklen_t
> /usr/src/sys/sys/syscallargs.h:17:12: note: expanded from macro 'syscallarg'
>                 struct { x datum; } le;                                 \
>                          ^
> /usr/src/sys/sys/_types.h:61:20: note: '__socklen_t' declared here
> typedef __uint32_t      __socklen_t;    /* length type for network syscalls */
>                         ^
> fatal error: too many errors emitted, stopping now [-ferror-limit=]
> 20 errors generated.
> *** Error 1 in /usr/src/sys/arch/amd64/compile/CUSTOM.MP
> (Makefile:1018 'sys_test.o')
>
>
>
>
>
>
>
>
>
> On Tue, Apr 24, 2018 at 12:18 AM, Ted Unangst <[hidden email]> wrote:
> > Neeraj Pal wrote:
> >> 4) echo "file kern/sys_hello.c" >> /usr/src/sys/conf/files
> >>
> >> 5) cd /usr/src/sys/arch/amd64/compile/CUSTOM.MP/
> >>
> >> 6) make obj && make -j4
> >>
> >> And, then, It throws an error given below,
> >>
> >> "
> >> ld -T ld.script -X --warn-common -nopie -o bsd ${SYSTEM_HEAD} vers.o ${OBJS}
> >>
> >> init_sysent.o:(.data+0x14b8): undefined reference to `sys_hello'
> >
> > this looks like the object wasn't added. you skipped make config.
>

Reply | Threaded
Open this post in threaded view
|

Re: Error in adding system call in OpenBSD 6.3

neerajpal
No, I know. But from last some days it's been like too confusing, I
mean first, it was working after some 15 days ago with the pathway
that I have just described, then now not working, then as Ted said, I
skipped config, now I have done that also but still some errors.
I don't know why these errors, I mean why from syscallsrgs.h file,
even after doing sh makesyscalls.sh syscalls.conf syscalls.master.
And also I am not even doing some socket and all then why these errors.

Sorry, If I have forgotten some basic stuff or asking non-sense
beginners question.

On Tue, Apr 24, 2018 at 3:04 AM, Theo de Raadt <[hidden email]> wrote:

> So..... you don't know what you are doing.
>
>
> Neeraj Pal <[hidden email]> wrote:
>> okay. Sure,
>>
>> Instead of sys_hello.c I created a new one sys_test.c. So, guys don't
>> confuse with above sys_hello.c and this time sys_test.c, both are the
>> same file.
>>
>> Then after that, I went through all the steps including "make config"
>>
>> make obj && make config && make -j4
>>
>> Then it throws this error this time. And, I am not able to understand this.
>>
>>
>> In file included from /usr/src/sys/kern/sys_test.c:4:
>> /usr/src/sys/sys/syscallargs.h:153:13: error: unknown type name
>> 'socklen_t'; did you mean '__socklen_t'?
>>         syscallarg(socklen_t *) fromlenaddr;
>>                    ^~~~~~~~~
>>                    __socklen_t
>> /usr/src/sys/sys/syscallargs.h:17:12: note: expanded from macro 'syscallarg'
>>                 struct { x datum; } le;                                 \
>>                          ^
>> /usr/src/sys/sys/_types.h:61:20: note: '__socklen_t' declared here
>> typedef __uint32_t      __socklen_t;    /* length type for network syscalls */
>>                         ^
>> In file included from /usr/src/sys/kern/sys_test.c:4:
>> /usr/src/sys/sys/syscallargs.h:153:2: error: expected expression
>>         syscallarg(socklen_t *) fromlenaddr;
>>         ^
>> /usr/src/sys/sys/syscallargs.h:19:48: note: expanded from macro 'syscallarg'
>>                         int8_t pad[ (sizeof (register_t) < sizeof (x))  \
>>                                                                     ^
>> /usr/src/sys/sys/syscallargs.h:153:13: error: use of undeclared
>> identifier 'socklen_t'
>>         syscallarg(socklen_t *) fromlenaddr;
>>                    ^
>> /usr/src/sys/sys/syscallargs.h:153:2: error: expected expression
>>         syscallarg(socklen_t *) fromlenaddr;
>>         ^
>> /usr/src/sys/sys/syscallargs.h:21:38: note: expanded from macro 'syscallarg'
>>                                 : sizeof (register_t) - sizeof (x)];    \
>>                                                                  ^
>> /usr/src/sys/sys/syscallargs.h:153:13: error: use of undeclared
>> identifier 'socklen_t'
>>         syscallarg(socklen_t *) fromlenaddr;
>>                    ^
>> /usr/src/sys/sys/syscallargs.h:153:13: error: unknown type name
>> 'socklen_t'; did you mean '__socklen_t'?
>>         syscallarg(socklen_t *) fromlenaddr;
>>                    ^~~~~~~~~
>>                    __socklen_t
>> /usr/src/sys/sys/syscallargs.h:22:4: note: expanded from macro 'syscallarg'
>>                         x datum;                                        \
>>                         ^
>> /usr/src/sys/sys/_types.h:61:20: note: '__socklen_t' declared here
>> typedef __uint32_t      __socklen_t;    /* length type for network syscalls */
>>                         ^
>> In file included from /usr/src/sys/kern/sys_test.c:4:
>> /usr/src/sys/sys/syscallargs.h:159:13: error: unknown type name
>> 'socklen_t'; did you mean '__socklen_t'?
>>         syscallarg(socklen_t *) anamelen;
>>                    ^~~~~~~~~
>>                    __socklen_t
>> /usr/src/sys/sys/syscallargs.h:17:12: note: expanded from macro 'syscallarg'
>>                 struct { x datum; } le;                                 \
>>                          ^
>> /usr/src/sys/sys/_types.h:61:20: note: '__socklen_t' declared here
>> typedef __uint32_t      __socklen_t;    /* length type for network syscalls */
>>                         ^
>> In file included from /usr/src/sys/kern/sys_test.c:4:
>> /usr/src/sys/sys/syscallargs.h:159:2: error: expected expression
>>         syscallarg(socklen_t *) anamelen;
>>         ^
>> /usr/src/sys/sys/syscallargs.h:19:48: note: expanded from macro 'syscallarg'
>>                         int8_t pad[ (sizeof (register_t) < sizeof (x))  \
>>                                                                     ^
>> /usr/src/sys/sys/syscallargs.h:159:13: error: use of undeclared
>> identifier 'socklen_t'
>>         syscallarg(socklen_t *) anamelen;
>>                    ^
>> /usr/src/sys/sys/syscallargs.h:159:2: error: expected expression
>>         syscallarg(socklen_t *) anamelen;
>>         ^
>> /usr/src/sys/sys/syscallargs.h:21:38: note: expanded from macro 'syscallarg'
>>                                 : sizeof (register_t) - sizeof (x)];    \
>>                                                                  ^
>> /usr/src/sys/sys/syscallargs.h:159:13: error: use of undeclared
>> identifier 'socklen_t'
>>         syscallarg(socklen_t *) anamelen;
>>                    ^
>> /usr/src/sys/sys/syscallargs.h:159:13: error: unknown type name
>> 'socklen_t'; did you mean '__socklen_t'?
>>         syscallarg(socklen_t *) anamelen;
>>                    ^~~~~~~~~
>>                    __socklen_t
>> /usr/src/sys/sys/syscallargs.h:22:4: note: expanded from macro 'syscallarg'
>>                         x datum;                                        \
>>                         ^
>> /usr/src/sys/sys/_types.h:61:20: note: '__socklen_t' declared here
>> typedef __uint32_t      __socklen_t;    /* length type for network syscalls */
>>                         ^
>> In file included from /usr/src/sys/kern/sys_test.c:4:
>> /usr/src/sys/sys/syscallargs.h:165:13: error: unknown type name
>> 'socklen_t'; did you mean '__socklen_t'?
>>         syscallarg(socklen_t *) alen;
>>                    ^~~~~~~~~
>>                    __socklen_t
>> /usr/src/sys/sys/syscallargs.h:17:12: note: expanded from macro 'syscallarg'
>>                 struct { x datum; } le;                                 \
>>                          ^
>> /usr/src/sys/sys/_types.h:61:20: note: '__socklen_t' declared here
>> typedef __uint32_t      __socklen_t;    /* length type for network syscalls */
>>                         ^
>> In file included from /usr/src/sys/kern/sys_test.c:4:
>> /usr/src/sys/sys/syscallargs.h:165:2: error: expected expression
>>         syscallarg(socklen_t *) alen;
>>         ^
>> /usr/src/sys/sys/syscallargs.h:19:48: note: expanded from macro 'syscallarg'
>>                         int8_t pad[ (sizeof (register_t) < sizeof (x))  \
>>                                                                     ^
>> /usr/src/sys/sys/syscallargs.h:165:13: error: use of undeclared
>> identifier 'socklen_t'
>>         syscallarg(socklen_t *) alen;
>>                    ^
>> /usr/src/sys/sys/syscallargs.h:165:2: error: expected expression
>>         syscallarg(socklen_t *) alen;
>>         ^
>> /usr/src/sys/sys/syscallargs.h:21:38: note: expanded from macro 'syscallarg'
>>                                 : sizeof (register_t) - sizeof (x)];    \
>>                                                                  ^
>> /usr/src/sys/sys/syscallargs.h:165:13: error: use of undeclared
>> identifier 'socklen_t'
>>         syscallarg(socklen_t *) alen;
>>                    ^
>> /usr/src/sys/sys/syscallargs.h:165:13: error: unknown type name
>> 'socklen_t'; did you mean '__socklen_t'?
>>         syscallarg(socklen_t *) alen;
>>                    ^~~~~~~~~
>>                    __socklen_t
>> /usr/src/sys/sys/syscallargs.h:22:4: note: expanded from macro 'syscallarg'
>>                         x datum;                                        \
>>                         ^
>> /usr/src/sys/sys/_types.h:61:20: note: '__socklen_t' declared here
>> typedef __uint32_t      __socklen_t;    /* length type for network syscalls */
>>                         ^
>> In file included from /usr/src/sys/kern/sys_test.c:4:
>> /usr/src/sys/sys/syscallargs.h:171:13: error: unknown type name
>> 'socklen_t'; did you mean '__socklen_t'?
>>         syscallarg(socklen_t *) alen;
>>                    ^~~~~~~~~
>>                    __socklen_t
>> /usr/src/sys/sys/syscallargs.h:17:12: note: expanded from macro 'syscallarg'
>>                 struct { x datum; } le;                                 \
>>                          ^
>> /usr/src/sys/sys/_types.h:61:20: note: '__socklen_t' declared here
>> typedef __uint32_t      __socklen_t;    /* length type for network syscalls */
>>                         ^
>> fatal error: too many errors emitted, stopping now [-ferror-limit=]
>> 20 errors generated.
>> *** Error 1 in /usr/src/sys/arch/amd64/compile/CUSTOM.MP
>> (Makefile:1018 'sys_test.o')
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> On Tue, Apr 24, 2018 at 12:18 AM, Ted Unangst <[hidden email]> wrote:
>> > Neeraj Pal wrote:
>> >> 4) echo "file kern/sys_hello.c" >> /usr/src/sys/conf/files
>> >>
>> >> 5) cd /usr/src/sys/arch/amd64/compile/CUSTOM.MP/
>> >>
>> >> 6) make obj && make -j4
>> >>
>> >> And, then, It throws an error given below,
>> >>
>> >> "
>> >> ld -T ld.script -X --warn-common -nopie -o bsd ${SYSTEM_HEAD} vers.o ${OBJS}
>> >>
>> >> init_sysent.o:(.data+0x14b8): undefined reference to `sys_hello'
>> >
>> > this looks like the object wasn't added. you skipped make config.
>>

Reply | Threaded
Open this post in threaded view
|

Re: Error in adding system call in OpenBSD 6.3

Ted Unangst-6
In reply to this post by neerajpal
Neeraj Pal wrote:
>
> In file included from /usr/src/sys/kern/sys_test.c:4:
> /usr/src/sys/sys/syscallargs.h:153:13: error: unknown type name
> 'socklen_t'; did you mean '__socklen_t'?

Your includes are in the wrong or some are missing. I think you should start
by adding code to a file that already compiles, that's much less trouble.

Reply | Threaded
Open this post in threaded view
|

Re: Error in adding system call in OpenBSD 6.3

neerajpal
Yeah, It works.

I have just made two modifications:

1) make config
2) includes <sys/systm.h> for the printf and <sys/mount.h> for errors
that I pasted after doing "make config" file .

Now evrything works fine.

Sorry for asking some confusing non-clear kind of question.

 Thank you, everyone, for the support. And, from on next time I will
keep things clear. So, that it would be easy to answer for everyone.
And also I will try to solve the problem on my own and giving more
time for self research instead of just asking here.

On Tue, Apr 24, 2018 at 7:45 AM, Ted Unangst <[hidden email]> wrote:
> Neeraj Pal wrote:
>>
>> In file included from /usr/src/sys/kern/sys_test.c:4:
>> /usr/src/sys/sys/syscallargs.h:153:13: error: unknown type name
>> 'socklen_t'; did you mean '__socklen_t'?
>
> Your includes are in the wrong or some are missing. I think you should start
> by adding code to a file that already compiles, that's much less trouble.
>