Linux-Development-Sys Digest #968, Volume #7     Thu, 22 Jun 00 13:13:15 EDT

Contents:
  Re: Driver devel (interruptible_sleep_on_timeout) (Espen Sand)
  Re: Driver devel (interruptible_sleep_on_timeout) (Espen Sand)
  Re: read(2) error EINTR (Warren Young)
  Re: error number (Warren Young)
  Re: QUERY: swap to/from a char device? (Warren Young)
  math calls in kernel module tricky? (Frank Boon)
  ld including dead code ("RM")
  Shared memory attach and detash (David Minor)
  __va??__pa?? ("WSH")
  help help about OS ("fonz")
  process cpu time ("Michael Faurot")
  cannot delete shared memory segments ("Kris Desjardins")
  Re: math calls in kernel module tricky? (Bryan Hackney)
  Re: What is a single address space & multi address space? (Kaz Kylheku)
  Newbie serial comms... (Jeremy Young)
  Re: Newbie serial comms... (Kaz Kylheku)
  [Announce]: RSBAC v1.0.9b released (A. Ott)
  Re: Newbie serial comms... (Jeremy Young)

----------------------------------------------------------------------------

From: Espen Sand <[EMAIL PROTECTED]>
Subject: Re: Driver devel (interruptible_sleep_on_timeout)
Date: Thu, 22 Jun 2000 09:22:25 GMT

Peter Pointner wrote:
> 
> Espen Sand <[EMAIL PROTECTED]> wrote:
> > Hi all,
> 
> > I am in the process of moving some driver code from
> > a 2.0.x system to 2.2x. The driver reads data from external
> > HW which sends an interrupt each time it has prepared some.
> > If there is no data pending when I want to read,
> > I do an interruptible sleep for a second. Normally new
> > data will arrive long before the second has elapsed.
> 
> > How should this be done in 2.2x? Is the
> > interruptible_sleep_on_timeout() the preferred method? To
> > me it seems so, but how should I detect that a timeout has
> > occurred or not? (the complier is not happy about the
> > "current->signal & ~current->blocked" test below)
> 
> If you look at some drivers in the standard kernel, you will see
> that (current->signal & ~current->blocked) is replaced by
> signal_pending(current)


Yes, I figured that. I just could not find some docs that said
it really was so. Thanks anyway.


> 
> > Here is how I did it in 2.0.x
> 
> > /* wait for resonse */
> > current->timeout = jiffies + i960.readTimeout;
> > interruptible_sleep_on( &i960.waitQueue );
> > current->timeout = 0;
> > sti();
> > if( current->signal & ~current->blocked )
> > {
> >    /* New data has arrived */
> >    ...
> > }
> 
> > /* The interrupt function */
> > static void i960_interrupt( int irq, void *dev_id,
> >       struct pt_regs *regs )
> > {
> >     ....
> >     wake_up_interruptible( &i960.waitQueue );
> >     ....
> > }
> 
> Are you really sure that you are doing it this way? Why should
> a pending signal mean that there is new data?


he,he. Got the cut/paste wrong there :)

------------------------------

From: Espen Sand <[EMAIL PROTECTED]>
Subject: Re: Driver devel (interruptible_sleep_on_timeout)
Date: Thu, 22 Jun 2000 09:28:43 GMT

Peter Pointner wrote:
> 
> Espen Sand <[EMAIL PROTECTED]> wrote:
> > Hi all,
> 
> > I am in the process of moving some driver code from
> > a 2.0.x system to 2.2x. The driver reads data from external
> > HW which sends an interrupt each time it has prepared some.
> > If there is no data pending when I want to read,
> > I do an interruptible sleep for a second. Normally new
> > data will arrive long before the second has elapsed.
> 
> > How should this be done in 2.2x? Is the
> > interruptible_sleep_on_timeout() the preferred method? To
> > me it seems so, but how should I detect that a timeout has
> > occurred or not? (the complier is not happy about the
> > "current->signal & ~current->blocked" test below)
> 
> If you look at some drivers in the standard kernel, you will see
> that (current->signal & ~current->blocked) is replaced by
> signal_pending(current)
>

Yes, I figured that. I just could not find some docs that said
it really was so. Thanks anyway.

> 
> > Here is how I did it in 2.0.x
> 
> > /* wait for resonse */
> > current->timeout = jiffies + i960.readTimeout;
> > interruptible_sleep_on( &i960.waitQueue );
> > current->timeout = 0;
> > sti();
> > if( current->signal & ~current->blocked )
> > {
> >    /* New data has arrived */
> >    ...
> > }
> 
> > /* The interrupt function */
> > static void i960_interrupt( int irq, void *dev_id,
> >       struct pt_regs *regs )
> > {
> >     ....
> >     wake_up_interruptible( &i960.waitQueue );
> >     ....
> > }
> 
> Are you really sure that you are doing it this way? Why should
> a pending signal mean that there is new data?
> 

he,he. Got the cut/paste wrong there :)

------------------------------

Date: Thu, 22 Jun 2000 03:34:01 -0600
From: Warren Young <[EMAIL PROTECTED]>
Subject: Re: read(2) error EINTR

Paul D. Smith" wrote:
> 
> %% Warren Young <[EMAIL PROTECTED]> writes:
> 
>   wy> EINTR happens when something happens deep in the bowels of the
>   wy> kernel that forces it to stop blocking on a system call.  Some
>   wy> signals on some OSes are known to cause this, but it's not
>   wy> specified to work by any standard I know of.
> 
> Every standard provides for the possibility that read doesn't restart.

I meant that I don't know of any standard that says "if you send SIGFOO
to a process, read(2) will return EINTR".  Maybe I misunderstood the
original post, but I thought that's what he was looking for.

-- 
= Warren Young, maintainer of the Winsock Programmer's FAQ at:
=     http://www.cyberport.com/~tangent/programming/winsock/
= 
= ICBM Address: 36.8274040 N, 108.0204086 W, alt. 1714m

------------------------------

Date: Thu, 22 Jun 2000 03:43:18 -0600
From: Warren Young <[EMAIL PROTECTED]>
Subject: Re: error number

[EMAIL PROTECTED] wrote:
> 
>   Does a kernel api (like kmalloc) on failure set the appropriate error
> code (in errno global variable).

When kmalloc fails it just does a printk() complaint and returns NULL. 
See mm/slab.c.

errno is only set when a syscall returns to userland.  A function like
sys_read() (the kernel side of read(2)) has code like "return -EBADF;". 
The generic syscall mechanism then looks for negative numbers returned
from the syscall: if the return is negative, the syscall code negates
the value and puts it in errno, then returns -1.

kmalloc()'s a bad example anyway, because it only has one failure mode:
"there's no more memory".  :)
-- 
= Warren Young, maintainer of the Winsock Programmer's FAQ at:
=     http://www.cyberport.com/~tangent/programming/winsock/
= 
= ICBM Address: 36.8274040 N, 108.0204086 W, alt. 1714m

------------------------------

Date: Thu, 22 Jun 2000 03:50:22 -0600
From: Warren Young <[EMAIL PROTECTED]>
Subject: Re: QUERY: swap to/from a char device?

Tom Roberts wrote:
> 
> The Linux kernel can swap to/from both a block device (the usual
> case such as a disk partition) and a file. Can this file be a char
> device?

A character device is linear: you read a stream of bytes from it or you
write a stream of bytes to it.  There is no standard way of seeking or
rewinding within a character device.  This is by design: random access
versus stream access is the only thing that distinguishes character from
block devices.  Take the SCSI tape driver for example: you rewind the
tape with a special ioctl(), not with something like lseek(2).

Obviously this matters, because if you can't rewind the device, you
can't go back and read what you've previously written.
 
> I have the choice of writing either a char or block driver, but am
> much more familiar with char drivers. I have no desire to mount a
> filesystem on this device, only using it for swapping. 

A swap partition isn't just raw storage.  There is in fact a crude
filesystem structure on it.  That's what mkswap(8) does.
-- 
= Warren Young, maintainer of the Winsock Programmer's FAQ at:
=     http://www.cyberport.com/~tangent/programming/winsock/
= 
= ICBM Address: 36.8274040 N, 108.0204086 W, alt. 1714m

------------------------------

From: Frank Boon <[EMAIL PROTECTED]>
Subject: math calls in kernel module tricky?
Date: Thu, 22 Jun 2000 13:54:37 +0200

Hi,

We've just developed a Linux kernel module which is a driver for 
a GPS digital board. In the driver, we need to perform some
floating point calculations to drive the H/W. Debugging the
driver showed that the float results are not always correct.

Is there an intrinsic problem in using the FPU inside a module?
I could not find a definite answer with a good explantion yet.
Maybe som eof you have experience with using the FPU inside
a kernel module

Frank Boon
[EMAIL PROTECTED]

------------------------------

Reply-To: "RM" <[EMAIL PROTECTED]>
From: "RM" <[EMAIL PROTECTED]>
Crossposted-To: gnu.gcc.help
Subject: ld including dead code
Date: Thu, 22 Jun 2000 07:23:14 -0400

Why would LD link dead code into a binary, and how do I eliminate it?

The code in question is contained in libraries that the final binary (a
modular device driver) is linked against.  There are no references to this
code.  I verified this by removing the "dead" code from the library, and
re-linking.  The linker did not issue any "unresolved symbol" errors.

Thanks,
R. Main.




------------------------------

From: David Minor <[EMAIL PROTECTED]>
Subject: Shared memory attach and detash
Date: Thu, 22 Jun 2000 15:08:25 +0300

I was wondering if there is a way to implement a process (not thread)
work queue by attaching and detaching segments of shared memory to the
processes eating the queue.  That is, each process would request work
from the queue and that work (both data and code to process the data)
would be detached from the general pool  (root process) and attached to
the (worker) process.  This would provide an amazing level of memory
protection for workqueue style processing.  Has anybody out there done
something like this?  It sounds to me like you'd need to write a custom
memory management scheme to keep track of which objects exist on which
pages of shared memory.

David Minor



------------------------------

From: "WSH" <[EMAIL PROTECTED]>
Subject: __va??__pa??
Date: Thu, 22 Jun 2000 22:07:11 +0800

excuse me
but I want to ask for this stupid question:
can anybody tell me about "__va" and "__pa" defined in include/asm/page.h??
what function do they provide??

for example, in arch/i386/kernel/setup.c
...
if(read_endbase_from_BIOS){
    i386_endbase=(*(unsigned short *)__va(0x413)*1024)&PAGE_MASK;
....

PS what is 0x413 in the example

thanks for your help~~I am just starting reading it...sorry for it



------------------------------

From: "fonz" <[EMAIL PROTECTED]>
Subject: help help about OS
Date: Fri, 23 Jun 2000 02:48:27 +1200

help help about OS
tomorrow we have a exam of operating system
can anyone give brief defines the following
if u can explain one or two of the following
it's also enough for me
many thank you
but please please hurry
thank you again


VMS
Amoeba
Solaris
JavaOS
Hurd
Plan 9
Window NT
QNX
Rhapsody
Linux
RAID
ANDF
ADA
The Unix 'Select' system call
The Mach Microkernel
The POSIX Standard
Pentium Memory Management
OS Benchmarks
The OSF DCE
The NOW Project
NTFS
Livelock
Win32 Threads
Linux Scheduling
Programming with sockets
The POSIX standard
Lod Balancinng



------------------------------

From: "Michael Faurot" <[EMAIL PROTECTED]>
Crossposted-To: comp.os.linux.development.apps
Subject: process cpu time
Date: 22 Jun 2000 14:57:52 GMT

I'm trying to devise a method, from within a shell program, to determine
if a specific process is hung or not.  What I'm thinking of doing is
checking the amount of cpu time the process has used, sleep for several
minutes and then check again to see if that has increased or not.

I suspect I can do this by parsing one of the pseudo files under /proc/PID
(where PID represent the process ID of the process to be checked).
Which pseudo file would tell me this and where within that file would
I find the amount of CPU time that's been used?

Thanks.

-- 
==============================================================================
 Michael | mfaurot  | Build a system that even a fool can use and only a
 Faurot  | atww.net | fool will want to use it.

------------------------------

From: "Kris Desjardins" <[EMAIL PROTECTED]>
Subject: cannot delete shared memory segments
Date: Thu, 22 Jun 2000 10:59:48 -0400

I am running a Dell Workstation 610 using an SMP kernel version 2.2.13.  The
problems occurs when we run a program AVS, it leaves behind shared memory
segments which we cannot delete using ipcrm. Does anyone know if this has
been addressed in any newer kernels?



------------------------------

From: Bryan Hackney <[EMAIL PROTECTED]>
Subject: Re: math calls in kernel module tricky?
Date: Thu, 22 Jun 2000 10:37:32 -0500

Frank Boon wrote:
> 
> Hi,
> 
> We've just developed a Linux kernel module which is a driver for
> a GPS digital board. In the driver, we need to perform some
> floating point calculations to drive the H/W. Debugging the
> driver showed that the float results are not always correct.
> 
> Is there an intrinsic problem in using the FPU inside a module?
> I could not find a definite answer with a good explantion yet.
> Maybe som eof you have experience with using the FPU inside
> a kernel module
> 
> Frank Boon
> [EMAIL PROTECTED]

I assume x86 here.

Floating point machine state is not saved and restored while in the
kernel. You have to manage the state of the FPU yourself while in
the kernel, or come up with clever ways of doing the work in fixed
point. The latter is very often possible.

Sorry I can't point to a reference, but I'm sure some of the reading
starts at Intel.


-- 
                                 Bryan Hackney / BHC / [EMAIL PROTECTED]
                                        http://bhconsult.com/
                                        http://bhconsult.com/bh/pgp.key

------------------------------

From: [EMAIL PROTECTED] (Kaz Kylheku)
Subject: Re: What is a single address space & multi address space?
Reply-To: [EMAIL PROTECTED]
Date: Thu, 22 Jun 2000 16:07:41 GMT

On Thu, 22 Jun 2000 08:00:56 GMT, [EMAIL PROTECTED] <[EMAIL PROTECTED]>
wrote:
>I have no idea about the single address space.. and multi address
>space..
>
>these terms are uttered frequently ..
>
>What are these.. ? and What's the difference between single and multi
>address space...
>
>Please let me know these..

Try reading a decent textbook on computer architecture, e.g. _Computer
Organization and Architecture_ by William Stallings.

Also try some other comp.* newsgroup that is not Linux specific; many other
virtual memory operating systems provide address space separation.

The newsgroup comp.arch seems to be appropriate for this topic.

In a nutshell when a computing system provides multiple address spaces, it
means that the meaning of an address depends on which address space you are
considered to be in. This provides a separation between domains, usually
processes. Domains are protected from corrupting each other's data because they
have no way of addressing into other spaces (though views of common memory
regions can be mapped into multiple address spaces, possibly at different
addresses).  Address spaces also simplify the layout of a process.  Some code
and data areas of a process can be mapped at fixed, well-known addresses in its
private space, simplifying the procedures for setting up a new process.

-- 
#exclude <windows.h>

------------------------------

From: Jeremy Young <[EMAIL PROTECTED]>
Subject: Newbie serial comms...
Date: Thu, 22 Jun 2000 17:14:53 +0100

OK, this is probably so incredibly simple you won't believe I'm asking 
it...

I want to read a serial port under C. I'm using KDevelop and I guess 
it's hooked into gcc. I've tested the port with mgetty and it works, 
cables are all OK, communicating 9600, no parity, 8, 1.

Now I'm trying to write a program that simply opens it and echos the 
bytes on the screen but I can't get past the open() function. I don't 
know what on earth I'm doing wrong and it's probably easy but I have:


        {
                cout << "Opening port\n";
                int PortFD = open( "/dev/ttyS0", O_RDONLY );
                cout << "look it's open!\n";
                ....
        }

And I can't get it to run past "Opening port". It calls open() then just 
sits there, nothing else happens, it never reaches the next line. What 
on earth is wrong? I tried using ifstream under C++ and get the same 
thing. I tried the debugger and it's somewhere IN open with nothing 
happening.

Don't understand. Can anyone help?

I haven't even got to setting baud rates or anything like that as all 
that happens after the port is opened. I've looked at the example in 
"Linux Application Development" and it seems to be much the same (except 
I'm trying to write in C++).

Any help would be appreciated,

Jeremy


------------------------------

From: [EMAIL PROTECTED] (Kaz Kylheku)
Subject: Re: Newbie serial comms...
Reply-To: [EMAIL PROTECTED]
Date: Thu, 22 Jun 2000 16:24:05 GMT

On Thu, 22 Jun 2000 17:14:53 +0100, Jeremy Young <[EMAIL PROTECTED]> wrote:
>       {
>               cout << "Opening port\n";
>               int PortFD = open( "/dev/ttyS0", O_RDONLY );
>               cout << "look it's open!\n";
>               ....
>       }
>
>And I can't get it to run past "Opening port". It calls open() then just 
>sits there, nothing else happens, it never reaches the next line. What 
>on earth is wrong? I tried using ifstream under C++ and get the same 
>thing. I tried the debugger and it's somewhere IN open with nothing 
>happening.

It's waiting for the modem control lines to indicate that the remote device is
ready to talk. If you don't want this to happen, you have to set the CLOCAL
flag on the terminal.

How do you set the CLOCAL flag on the terminal file descriptor if the
open() system call blocks in the first place?

The answer is to do a non-blocking open.

-- 
#exclude <windows.h>

------------------------------

Date: 22 Jun 2000 16:18:00 +0200
From: [EMAIL PROTECTED] (A. Ott)
Crossposted-To: comp.security.misc,comp.security.unix
Subject: [Announce]: RSBAC v1.0.9b released

Hi to you all!

After quite a few pre's, version 1.0.9b of the Rule Set Based Access  
Control (RSBAC) package for the Linux kernel has been released.

You can find it on the RSBAC homepage at http://www.rsbac.org.

The changes against version 1.0.9a are:

 - Port to 2.3.42 - 2.3.99-pre3
 - Port to 2.2.14 - 2.2.16
 - 32 Bit Uid/Gid with new attribute versions
 - User and program based logging
 - AUTH capability ranges
 - Made write to MSDOS fs a config option, so use it on your own risk
    (see config help)
 - MAC levels 0-252 instead of 0-3
 - Added config option for ioport access (X support)


Patch Archive description:
=========================
Name:          rsbac
Version:       1.0.9b
Kernelver:     2.2.11 - 2.2.16, 2.3.42 - 2.3.99-pre3
Status:        8 (UP), unknown (SMP)
Author:        Amon Ott <[EMAIL PROTECTED]>
Maintainer:    Amon Ott <[EMAIL PROTECTED]>
Description:   Rule Set Based Access Control (RSBAC)
Date:          13-June-2000
Descfile-URL:  http://www.rsbac.org/rsbac.desc
Download-URL:  http://www.rsbac.org/download.htm
Homepage-URL:  http://www.rsbac.org/
Manual-URL:    http://www.rsbac.org/instadm.htm

What is RSBAC?
==============
RSBAC is an open source security extension for current Linux kernels.
It is based on the Generalized Framework for Access Control (GFAC) by
Abrams and LaPadula and provides a flexible system of access control
based on several modules.

All security relevant system calls are extended by security
enforcement code. This code calls the central decision component, which
in turn calls all active decision modules and generates a combined decision.
This decision is then enforced by the system call extensions.

Decisions are based on the type of access (request type), the access target
and on the values
of attributes attached to the subject calling and to the target to be
accessed. Additional independent attributes can be used by individual modules,
e.g. the
privacy module (PM). All attributes are stored in fully protected
directories, one on each mounted device. Thus changes to attributes require
special system calls provided.

As all types of access decisions are based on general decision requests,
many different security policies can be implemented as a decision module. In
the current RSBAC version (1.0.9b), eight modules are included:

MAC: Bell-LaPadula Mandatory Access Control (limited to 64 compartments)

FC: Functional Control. A simple role based model, restricting access
to security information to security officers and access to system
information to administrators.

SIM: Security Information Modification. Only security
administrators are allowed to modify data labeled as security information

PM: Privacy Model. Simone Fischer-Huebner's Privacy Model in its first
implementation. See our paper on PM implementation for the National
Information Systems Security Conference (NISSC 98)

MS: Malware Scan. Scan all files for malware on execution
(optionally on all file read accesses or on all TCP/UDP read accesses),
deny access if infected. Currently the Linux viruses Bliss.A and Bliss.B
and a handfull of others are detected. See our paper on malware detection
and avoidance for The Third Nordic Workshop on Secure IT Systems (Nordsec'98)

FF: File Flags. Provide and use flags for dirs and files,
currently execute_only (files), read_only (files and dirs), search_only
(dirs), secure_delete (files) and add_inherited (files and dirs).
Only security officers may modify these flags.

RC: Role Compatibility. Defines (up to) 64 roles and 64 types for each
target type (file, dir, dev, ipc, scd, process). For each role compatibility
to all types and to other roles can be set individually and with request
granularity.

AUTH: Authorization enforcement. Controls all CHANGE_OWNER
requests for process targets, only programs/processes with general setuid
allowance and those with a capability for the target user ID may setuid.
Capabilities are controlled by other programs/processes.

ACL: Access Control Lists. For every object there is an Access Control List,
defining which subjects may access this object with which request types.
Subjects can be of type user, RC role and ACL group. Objects are grouped
by their target type, but have individual ACLs. If there is no ACL entry for a
subject at an object, rights are inherited from parent objects, restricted by
an inheritance mask. Direct (user) and indirect (role, group) rights are
accumulated.
For each object type there is a default ACL on top of the normal hierarchy.
Group management has been added in version 1.0.9a.

The underlying models are described in the module description at RSBAC
homepage (http://www.rsbac.org).

A general goal of RSBAC has been to some day reach (obsolete) Orange Book
(TCSEC) B1 level. Now it is mostly targeting to be useful as secure and
multi-purposed networked system, with special interest in firewalls.

--
Please remove second ao for E-Mail reply - no spam please!

------------------------------

From: Jeremy Young <[EMAIL PROTECTED]>
Subject: Re: Newbie serial comms...
Date: Thu, 22 Jun 2000 17:34:59 +0100

In article <[EMAIL PROTECTED]>, 
[EMAIL PROTECTED] says...
> On Thu, 22 Jun 2000 17:14:53 +0100, Jeremy Young <[EMAIL PROTECTED]> wrote:
> >     {
> >             cout << "Opening port\n";
> >             int PortFD = open( "/dev/ttyS0", O_RDONLY );
> >             cout << "look it's open!\n";
> >             ....
> >     }
> >
> >And I can't get it to run past "Opening port". It calls open() then just 
> >sits there, nothing else happens, it never reaches the next line. What 
> >on earth is wrong? I tried using ifstream under C++ and get the same 
> >thing. I tried the debugger and it's somewhere IN open with nothing 
> >happening.
> 
> It's waiting for the modem control lines to indicate that the remote device is
> ready to talk. If you don't want this to happen, you have to set the CLOCAL
> flag on the terminal.
> 
> How do you set the CLOCAL flag on the terminal file descriptor if the
> open() system call blocks in the first place?
> 
> The answer is to do a non-blocking open.
> 
> 

Excellent, wonderful. Thankyou very much. That is precisely what I need. 
I am surprised that Linux Application Development made no mention of 
this and the sample program used O_RDWR for the open....

Thanks again

Jeremy

------------------------------


** FOR YOUR REFERENCE **

The service address, to which questions about the list itself and requests
to be added to or deleted from it should be directed, is:

    Internet: [EMAIL PROTECTED]

You can send mail to the entire list (and comp.os.linux.development.system) via:

    Internet: [EMAIL PROTECTED]

Linux may be obtained via one of these FTP sites:
    ftp.funet.fi                                pub/Linux
    tsx-11.mit.edu                              pub/linux
    sunsite.unc.edu                             pub/Linux

End of Linux-Development-System Digest
******************************

Reply via email to