LKML Archive mirror
 help / color / mirror / Atom feed
* Kernel 2.x POSIX Compliance/Conformance...
@ 2004-02-04 19:30 Randazzo, Michael
  2004-02-04 19:40 ` Valdis.Kletnieks
  0 siblings, 1 reply; 10+ messages in thread
From: Randazzo, Michael @ 2004-02-04 19:30 UTC (permalink / raw
  To: 'linux-kernel@vger.kernel.org'

All,

Can someone inform me of the POSIX compliance/Conformance of the Linux 
Kernel, esp. for module (driver) development.

Posix.1 (1003.1)
Posix.4 (1003.1b)
etc....

I have made attempts to use (Posix semaphores) in my LKM, but find 
no POSIX support in /lib/modules/<uname -r>/build/include/unistd.h

Any help is appreciated...

M.
 
"This message may contain company proprietary information. If you are not
the intended recipient, any disclosure, copying, distribution or reliance on
the contents of this message is prohibited. If you received this message in
error, please delete and notify me."


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Kernel 2.x POSIX Compliance/Conformance...
  2004-02-04 19:30 Randazzo, Michael
@ 2004-02-04 19:40 ` Valdis.Kletnieks
  0 siblings, 0 replies; 10+ messages in thread
From: Valdis.Kletnieks @ 2004-02-04 19:40 UTC (permalink / raw
  To: Randazzo, Michael; +Cc: 'linux-kernel@vger.kernel.org'

[-- Attachment #1: Type: text/plain, Size: 552 bytes --]

On Wed, 04 Feb 2004 14:30:39 EST, "Randazzo, Michael" <RANDAZZO@ddc-web.com>  said:

> I have made attempts to use (Posix semaphores) in my LKM, but find 
> no POSIX support in /lib/modules/<uname -r>/build/include/unistd.h

Attempting to use syscalls intended for userspace while inside the kernel
is generally regarded as Bad Juju.

'man semctl' says:

     Under  Linux,  the  function semctl is not a system call, but is imple-
       mented via the system call ipc(2).

#define __NR_ipc                117

is what you weren't finding in unistd.h

[-- Attachment #2: Type: application/pgp-signature, Size: 226 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* RE: Kernel 2.x POSIX Compliance/Conformance...
@ 2004-02-04 19:44 Randazzo, Michael
  2004-02-04 19:58 ` Valdis.Kletnieks
  0 siblings, 1 reply; 10+ messages in thread
From: Randazzo, Michael @ 2004-02-04 19:44 UTC (permalink / raw
  To: 'Valdis.Kletnieks@vt.edu', Randazzo, Michael
  Cc: 'linux-kernel@vger.kernel.org'

I was using at sem_close(), sem_destroy90, sem_open() ...

according to Posix.4, these are defined in semaphore.h - but
are not defined in /lib/modules/<uname -r>/build/include/semaphore.h

Are Posix.4 calls only for userspace?

M.

-----Original Message-----
From: Valdis.Kletnieks@vt.edu [mailto:Valdis.Kletnieks@vt.edu]
Sent: Wednesday, February 04, 2004 2:41 PM
To: Randazzo, Michael
Cc: 'linux-kernel@vger.kernel.org'
Subject: Re: Kernel 2.x POSIX Compliance/Conformance... 


On Wed, 04 Feb 2004 14:30:39 EST, "Randazzo, Michael" <RANDAZZO@ddc-web.com>
said:

> I have made attempts to use (Posix semaphores) in my LKM, but find 
> no POSIX support in /lib/modules/<uname -r>/build/include/unistd.h

Attempting to use syscalls intended for userspace while inside the kernel
is generally regarded as Bad Juju.

'man semctl' says:

     Under  Linux,  the  function semctl is not a system call, but is imple-
       mented via the system call ipc(2).

#define __NR_ipc                117

is what you weren't finding in unistd.h
 
"This message may contain company proprietary information. If you are not
the intended recipient, any disclosure, copying, distribution or reliance on
the contents of this message is prohibited. If you received this message in
error, please delete and notify me."


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Kernel 2.x POSIX Compliance/Conformance...
  2004-02-04 19:44 Kernel 2.x POSIX Compliance/Conformance Randazzo, Michael
@ 2004-02-04 19:58 ` Valdis.Kletnieks
  0 siblings, 0 replies; 10+ messages in thread
From: Valdis.Kletnieks @ 2004-02-04 19:58 UTC (permalink / raw
  To: Randazzo, Michael; +Cc: 'linux-kernel@vger.kernel.org'

[-- Attachment #1: Type: text/plain, Size: 501 bytes --]

On Wed, 04 Feb 2004 14:44:00 EST, "Randazzo, Michael" said:
> I was using at sem_close(), sem_destroy90, sem_open() ...
> 
> according to Posix.4, these are defined in semaphore.h - but
> are not defined in /lib/modules/<uname -r>/build/include/semaphore.h
> 
> Are Posix.4 calls only for userspace?

System calls in general are for userspace.  Often, there exist alternate
entry points for kernel services, or other ways to do it (for instance,
the kernel has its own code for locks and semaphores).

[-- Attachment #2: Type: application/pgp-signature, Size: 226 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* RE: Kernel 2.x POSIX Compliance/Conformance...
@ 2004-02-04 20:18 Randazzo, Michael
  2004-02-04 20:21 ` Valdis.Kletnieks
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Randazzo, Michael @ 2004-02-04 20:18 UTC (permalink / raw
  To: 'Valdis.Kletnieks@vt.edu', Randazzo, Michael
  Cc: 'linux-kernel@vger.kernel.org'

Where are the kernel calls defined for locks and semaphores?

How come the kernel headers don't define Posix.4 
semaphores (_POSIX_SEMAPHROES) or Posix itself
(_POSIX_VERSION is undefined)

M.

-----Original Message-----
From: Valdis.Kletnieks@vt.edu [mailto:Valdis.Kletnieks@vt.edu]
Sent: Wednesday, February 04, 2004 2:59 PM
To: Randazzo, Michael
Cc: 'linux-kernel@vger.kernel.org'
Subject: Re: Kernel 2.x POSIX Compliance/Conformance... 


On Wed, 04 Feb 2004 14:44:00 EST, "Randazzo, Michael" said:
> I was using at sem_close(), sem_destroy90, sem_open() ...
> 
> according to Posix.4, these are defined in semaphore.h - but
> are not defined in /lib/modules/<uname -r>/build/include/semaphore.h
> 
> Are Posix.4 calls only for userspace?

System calls in general are for userspace.  Often, there exist alternate
entry points for kernel services, or other ways to do it (for instance,
the kernel has its own code for locks and semaphores).
 
"This message may contain company proprietary information. If you are not
the intended recipient, any disclosure, copying, distribution or reliance on
the contents of this message is prohibited. If you received this message in
error, please delete and notify me."


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Kernel 2.x POSIX Compliance/Conformance...
  2004-02-04 20:18 Randazzo, Michael
@ 2004-02-04 20:21 ` Valdis.Kletnieks
  2004-02-04 20:51 ` Torrey Hoffman
  2004-02-04 21:02 ` J.A. Magallon
  2 siblings, 0 replies; 10+ messages in thread
From: Valdis.Kletnieks @ 2004-02-04 20:21 UTC (permalink / raw
  To: Randazzo, Michael; +Cc: 'linux-kernel@vger.kernel.org'

[-- Attachment #1: Type: text/plain, Size: 336 bytes --]

On Wed, 04 Feb 2004 15:18:17 EST, "Randazzo, Michael" said:
> Where are the kernel calls defined for locks and semaphores?
> 
> How come the kernel headers don't define Posix.4 
> semaphores (_POSIX_SEMAPHROES) or Posix itself
> (_POSIX_VERSION is undefined)

Posix.4 and _POSIX_VERSION are for *userspace*

The kernel isn't userspace.

[-- Attachment #2: Type: application/pgp-signature, Size: 226 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* RE: Kernel 2.x POSIX Compliance/Conformance...
@ 2004-02-04 20:22 Randazzo, Michael
  2004-02-04 21:39 ` Richard B. Johnson
  0 siblings, 1 reply; 10+ messages in thread
From: Randazzo, Michael @ 2004-02-04 20:22 UTC (permalink / raw
  To: 'Valdis.Kletnieks@vt.edu', Randazzo, Michael
  Cc: 'linux-kernel@vger.kernel.org'

ok...I think I get it....

I can't use any of the posix functions in 
device drivers (modules).....is this correct?

M.

-----Original Message-----
From: Valdis.Kletnieks@vt.edu [mailto:Valdis.Kletnieks@vt.edu]
Sent: Wednesday, February 04, 2004 3:21 PM
To: Randazzo, Michael
Cc: 'linux-kernel@vger.kernel.org'
Subject: Re: Kernel 2.x POSIX Compliance/Conformance... 


On Wed, 04 Feb 2004 15:18:17 EST, "Randazzo, Michael" said:
> Where are the kernel calls defined for locks and semaphores?
> 
> How come the kernel headers don't define Posix.4 
> semaphores (_POSIX_SEMAPHROES) or Posix itself
> (_POSIX_VERSION is undefined)

Posix.4 and _POSIX_VERSION are for *userspace*

The kernel isn't userspace.
 
"This message may contain company proprietary information. If you are not
the intended recipient, any disclosure, copying, distribution or reliance on
the contents of this message is prohibited. If you received this message in
error, please delete and notify me."


^ permalink raw reply	[flat|nested] 10+ messages in thread

* RE: Kernel 2.x POSIX Compliance/Conformance...
  2004-02-04 20:18 Randazzo, Michael
  2004-02-04 20:21 ` Valdis.Kletnieks
@ 2004-02-04 20:51 ` Torrey Hoffman
  2004-02-04 21:02 ` J.A. Magallon
  2 siblings, 0 replies; 10+ messages in thread
From: Torrey Hoffman @ 2004-02-04 20:51 UTC (permalink / raw
  To: Randazzo, Michael
  Cc: 'Valdis.Kletnieks@vt.edu',
	'linux-kernel@vger.kernel.org'

On Wed, 2004-02-04 at 12:18, Randazzo, Michael wrote:
> Where are the kernel calls defined for locks and semaphores?
> 
> How come the kernel headers don't define Posix.4 
> semaphores (_POSIX_SEMAPHROES) or Posix itself
> (_POSIX_VERSION is undefined)
> 

I think you need to read "Linux Device Drivers".  If you don't want to
buy it, you can read it for free online.

http://www.xml.com/ldd/chapter/book/

Chapter 9, pages 284-286 discusses locking and atomic operations.


-- 
Torrey Hoffman <thoffman@arnor.net>


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Kernel 2.x POSIX Compliance/Conformance...
  2004-02-04 20:18 Randazzo, Michael
  2004-02-04 20:21 ` Valdis.Kletnieks
  2004-02-04 20:51 ` Torrey Hoffman
@ 2004-02-04 21:02 ` J.A. Magallon
  2 siblings, 0 replies; 10+ messages in thread
From: J.A. Magallon @ 2004-02-04 21:02 UTC (permalink / raw
  To: Randazzo, Michael
  Cc: 'Valdis.Kletnieks@vt.edu',
	'linux-kernel@vger.kernel.org'


On 2004.02.04, "Randazzo, Michael" wrote:
> Where are the kernel calls defined for locks and semaphores?
> 
> How come the kernel headers don't define Posix.4 
> semaphores (_POSIX_SEMAPHROES) or Posix itself
> (_POSIX_VERSION is undefined)
> 

The kernel internals are not nor Posix, nor SysV nor anything. It is just
by chance (or logic ;)) that some functions in kernel are named like the
userspace similars. Kernel source is in its own namespace.

One example (not a syscall, but useful I expect):
- Kernel has a 'sys_clone()' function, numbered __NR_clone
- GLibc implements a linux-specific system-call 'clone()', using sys_clone
- Glibc uses 'clone()' to implement 'fork()'

So, don't try to look for fork() inside the kernel.

-- 
J.A. Magallon <jamagallon()able!es>     \                 Software is like sex:
werewolf!able!es                         \           It's better when it's free
Mandrake Linux release 10.0 (Cooker) for i586
Linux 2.6.2-rc3-jam1 (gcc 3.3.2 (Mandrake Linux 10.0 3.3.2-4mdk))

^ permalink raw reply	[flat|nested] 10+ messages in thread

* RE: Kernel 2.x POSIX Compliance/Conformance...
  2004-02-04 20:22 Randazzo, Michael
@ 2004-02-04 21:39 ` Richard B. Johnson
  0 siblings, 0 replies; 10+ messages in thread
From: Richard B. Johnson @ 2004-02-04 21:39 UTC (permalink / raw
  To: Randazzo, Michael
  Cc: 'Valdis.Kletnieks@vt.edu',
	'linux-kernel@vger.kernel.org'

On Wed, 4 Feb 2004, Randazzo, Michael wrote:

> ok...I think I get it....
>
> I can't use any of the posix functions in
> device drivers (modules).....is this correct?
>
> M.

You cannot ever use any 'C' runtime library functions in your
modules. This means you cannot use open(), close(), read(),
write(), lseek(), etc. However, the kernel has some of its
own POSIX-compliant functions like memset(), memcpy(), strcpy(),
etc. You can look in ../linux-nn.nn/lib or look through the
headers to see what's available. There are semaphones and
other locking mechanisms available for use in the kernel
which, I recall, was your first inquiry.

Cheers,
Dick Johnson
Penguin : Linux version 2.4.24 on an i686 machine (797.90 BogoMips).
            Note 96.31% of all statistics are fiction.



^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2004-02-04 21:42 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-02-04 19:44 Kernel 2.x POSIX Compliance/Conformance Randazzo, Michael
2004-02-04 19:58 ` Valdis.Kletnieks
  -- strict thread matches above, loose matches on Subject: below --
2004-02-04 20:22 Randazzo, Michael
2004-02-04 21:39 ` Richard B. Johnson
2004-02-04 20:18 Randazzo, Michael
2004-02-04 20:21 ` Valdis.Kletnieks
2004-02-04 20:51 ` Torrey Hoffman
2004-02-04 21:02 ` J.A. Magallon
2004-02-04 19:30 Randazzo, Michael
2004-02-04 19:40 ` Valdis.Kletnieks

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).