Linux-Development-Sys Digest #671, Volume #8     Thu, 26 Apr 01 10:13:23 EDT

Contents:
  Re: How do I get a display patch added to the kernel dist?
  Re: Help - Edit route table in software? (Chris Friesen)
  Re: ide vs. scsi why so much slower (Juergen Pfann)
  Re: ide vs. scsi why so much slower
  Promise FastTrack ("Stuart Cianos")
  Re: troubleshooting a kernel mod ("Greg Knopf")
  Re: How do I get a display patch added to the kernel dist? ("Jeramy B Smith")
  Re: Whats my DNS? ("Greg Knopf")
  Re: Promise FastTrack (Thomas Zajic)
  portable computation time estimation? (NortonNg)
  Writing a PCI device driver. (Ronnie Arosa Carril)
  Re: Writing a PCI device driver. ("Robert Allmeroth")
  Re: portable computation time estimation? (Juergen Hannappel)
  Realtek 8139b NIC ("MrHyde")
  Re: Writing a PCI device driver. (Ronnie Arosa Carril)
  Assigning capabilities to users ("Cameron Kerr")
  Re: File access within a kernel mod (Kasper Dupont)
  Re: Help - Edit route table in software? ("Chris West")

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

From: [EMAIL PROTECTED] ()
Crossposted-To: comp.os.linux.powerpc
Subject: Re: How do I get a display patch added to the kernel dist?
Date: Wed, 25 Apr 2001 22:54:13 -0000

In article <WvHF6.5820$[EMAIL PROTECTED]>,
Brian Kendig <[EMAIL PROTECTED]> wrote:

>The short of it: There's a simple patch I need applied to the Linux kernel
>in order to use Linux on my computer.  I found the patch online, and I've
>been told it was submitted to the development tree several months ago, but
>for some reason it was never accepted.  I want to see the patch added to the
>default kernel distributions so that I (and anyone else with the same
>monitor as I have) can download kernel binaries instead of having to patch
>the source and re-build it myself every time I upgrade.  How do I re-submit
>a patch, or find out why it wasn't accepted into the tree?

See http://linuxtoday.com/news_story.php3?ltsn=2001-04-25-016-20-NW-KN

--
http://www.spinics.net/linux

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

From: Chris Friesen <[EMAIL PROTECTED]>
Crossposted-To: comp.os.linux.development.apps,comp.os.linux.networking
Subject: Re: Help - Edit route table in software?
Date: Wed, 25 Apr 2001 23:11:46 GMT

Sebastien Jean wrote:
> 
> Changing the routing table from the command line is easy.  Does anyone know
> how to change the routing table from within a program written in C/C++?
> What about changing Ethernet device parameters.

Try reading the source code for ifconfig and iproute2's "ip" command. It's kind
of impenetrable.  My solution (under time pressure) was to put a wrapper around
the "ip" that just calls the main routine as though it were passing commandline
arguments.  It's not pretty, but it works.  You have to go in and modify it a
bit so that "ip" doesn't call exit when there is a problem.

Chris

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

From: Juergen Pfann <[EMAIL PROTECTED]>
Subject: Re: ide vs. scsi why so much slower
Date: Thu, 26 Apr 2001 02:53:54 +0200

[EMAIL PROTECTED] wrote:
> 
> My plextor 12/10/32 cdrw drive still chokes my system even with
> dma enabled via:
> >sudo hdparm -c1 -d1 -X34 /dev/hdc
> 

Maybe - but my Plextor 12/4/32 SCSI does not. 
SCNR 

Juergen

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

From: [EMAIL PROTECTED] ()
Subject: Re: ide vs. scsi why so much slower
Date: Thu, 26 Apr 2001 02:09:29 GMT

On Thu, 26 Apr 2001 02:53:54 +0200, Juergen Pfann <[EMAIL PROTECTED]> wrote:
>[EMAIL PROTECTED] wrote:
>> 
>> My plextor 12/10/32 cdrw drive still chokes my system even with
>> dma enabled via:
>> >sudo hdparm -c1 -d1 -X34 /dev/hdc
>> 
>
>Maybe - but my Plextor 12/4/32 SCSI does not. 

newsflash:  ide != scsi

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

From: "Stuart Cianos" <[EMAIL PROTECTED]>
Subject: Promise FastTrack
Date: Wed, 25 Apr 2001 19:11:05 -0700

Dear Developers:

Would it be feasible to build Promise FastTrack IDE RAID controller support
into the kernel by porting the drivers in FreeBSD 4.3 over?

- Stu




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

Reply-To: "Greg Knopf" <[EMAIL PROTECTED]>
From: "Greg Knopf" <[EMAIL PROTECTED]>
Subject: Re: troubleshooting a kernel mod
Date: Thu, 26 Apr 2001 05:40:53 GMT

I thought you could do a ptrace() syscall... look into that.

Wayne <[EMAIL PROTECTED]> wrote in message
news:D8gF6.2064$[EMAIL PROTECTED]...
> Is there anything out there to help with troubleshooting a kernel mod
other
> than a bunch of printk's ??  perhaps something you can trace with?
>
>



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

From: "Jeramy B Smith" <[EMAIL PROTECTED]>
Crossposted-To: comp.os.linux.powerpc
Subject: Re: How do I get a display patch added to the kernel dist?
Date: Thu, 26 Apr 2001 05:47:11 GMT

Ben Herrenschmidt is the new pmac maintainer and has this in his 2.4 tree. I
have made real patches for the 2.2 tree and he is looking at adding them.
They do a bit more than just add a vmode for the studio display
(http://penguinppc.org/~jeramy/PATCHES).

The big culprit here is your vendor. If you need this, they should add it to
their kernel and issue an update. Your vendor probably has 6 or more hacks
in their own kernels that aren't in the vanilla sources. If you are using
SuSE, you have a metric ton of them including that one, LVM, alsa, etc.

-jeramy b smith

Demanding consumers create better products.


"Brian Kendig" <[EMAIL PROTECTED]> wrote in message
news:WvHF6.5820$[EMAIL PROTECTED]...
> The short of it: There's a simple patch I need applied to the Linux kernel
> in order to use Linux on my computer.  I found the patch online, and I've
> been told it was submitted to the development tree several months ago, but
> for some reason it was never accepted.  I want to see the patch added to
the
> default kernel distributions so that I (and anyone else with the same
> monitor as I have) can download kernel binaries instead of having to patch
> the source and re-build it myself every time I upgrade.  How do I
re-submit
> a patch, or find out why it wasn't accepted into the tree?
>
> The long of it: My computer is a Power Mac G4 with a Cinema Display (22"
> LCD, 1600x1024).  The Linux kernel needs the following patch applied to it
> in order to be able to use this display (otherwise it fails to sync and
the
> monitor goes into sleep mode):
>
> diff -urN linux-2.4.0-ac4/drivers/video/macmodes.c
linux-2.4.0-ac4-ppc/drivers/video/macmodes.c
> --- linux-2.4.0-ac4/drivers/video/macmodes.c Tue Nov 28 02:11:26 2000
> +++ linux-2.4.0-ac4-ppc/drivers/video/macmodes.c Mon Jan  8 10:44:29 2001
> @@ -91,7 +91,11 @@
>   /* 1280x1024, 75 Hz, Non-Interlaced (135.00 MHz dotclock) */
>   "mac20", 75, 1280, 1024, 7408, 232, 64, 38, 1, 112, 3,
>   FB_SYNC_HOR_HIGH_ACT|FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED
> -    },
> +    }, {
> + /* 1600x1024, 60 Hz, Non-Interlaced (112.27 MHz dotclock) */
> + "mac22", 75, 1600, 1024, 8908, 88, 104, 1, 10, 16, 1,
> + FB_SYNC_HOR_HIGH_ACT|FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED
> +    }
>
>  #if 0
>      /* Anyone who has timings for these? */
> @@ -157,6 +161,8 @@
>      { VMODE_1280_960_75, &mac_modedb[12] },
>      /* 1280x1024 */
>      { VMODE_1280_1024_75, &mac_modedb[13] },
> +    /* 1600x1024 */
> +    { VMODE_1600_1024_60, &mac_modedb[14] },
>      { -1, NULL }
>  };
>
> @@ -188,6 +194,7 @@
>      { 0x730, VMODE_768_576_50I }, /* PAL (Alternate) */
>      { 0x73a, VMODE_1152_870_75 }, /* 3rd party 19" */
>      { 0x73f, VMODE_640_480_67 }, /* no sense lines connected at all */
> +    { 0xBEEF, VMODE_1600_1024_60 }, /* 22" Apple Cinema Display */
>      { -1,    VMODE_640_480_60 }, /* catch-all, must be last */
>  };
>
> diff -urN linux-2.4.0-ac4/include/video/macmodes.h
linux-2.4.0-ac4-ppc/include/video/macmodes.h
> --- linux-2.4.0-ac4/include/video/macmodes.h Thu Feb 10 04:43:57 2000
> +++ linux-2.4.0-ac4-ppc/include/video/macmodes.h Mon Jan  8 10:44:29 2001
> @@ -38,7 +38,8 @@
>  #define VMODE_1152_870_75 18 /* 1152x870, 75Hz */
>  #define VMODE_1280_960_75 19 /* 1280x960, 75Hz */
>  #define VMODE_1280_1024_75 20 /* 1280x1024, 75Hz */
> -#define VMODE_MAX 20
> +#define VMODE_1600_1024_60 22 /* 1600x1024, 60Hz 22" Cinema Display */
> +#define VMODE_MAX 22
>  #define VMODE_CHOOSE 99
>
>  #define CMODE_NVRAM -1
>
>
> Would someone please submit this patch to the proper place for me, or
> explain to me exactly how to submit it?
>
> --
>   ____    |\/|                  Brian Kendig
>   \  /\   / ..__.     brian at enchanter net    You are in a maze of
twisty
>    \/  \__\   _/    http://www.enchanter.net/   little passages, all
alike.
>     \__   __  \_       Be insatiably curious.
>        \____\___\            Ask "why" a lot.



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

Reply-To: "Greg Knopf" <[EMAIL PROTECTED]>
From: "Greg Knopf" <[EMAIL PROTECTED]>
Subject: Re: Whats my DNS?
Date: Thu, 26 Apr 2001 06:03:35 GMT

If you are running dual boot right now, you can find all the appropriate
info in windows by doing
Start->Run->winipcfg

DHCP is the protocol that allows your computer to be configured dynamically.
Your sys connects to the DHCP server first, which tells you your IP, DNS,
GW, netmask, etc.

dhcpcd is the DHCP client daemon for linux

ImperatorM <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]...
> I am moving my internet connection from Windows to Linux.  On Windows I
was
> only required to know the login, password, and phone and the computer
somehow
> resolved my DNS.  How do I find out what DNS my current connection is
using??
> Thanks
> -Ted



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

From: [EMAIL PROTECTED] (Thomas Zajic)
Subject: Re: Promise FastTrack
Reply-To: [EMAIL PROTECTED] (Thomas Zajic)
Date: Thu, 26 Apr 2001 07:15:02 GMT

On 26/04/01, Stuart Cianos ([EMAIL PROTECTED]) wrote:

> Would it be feasible to build Promise FastTrack IDE RAID controller
> support into the kernel by porting the drivers in FreeBSD 4.3 over?

Why? At our office, the FastTrack/66 works fine with the (self-compiled)
"official" kernel module provided by Promise.

Thomas
-- 
=-------------------------------------------------------------------------=
-  Thomas "ZlatkO" Zajic   <[EMAIL PROTECTED]>   Linux-2.2.19/slrn-0.9.7.0a   -
-  "It is not easy to cut through a human head with a hacksaw."  (M. C.)  -
=-------------------------------------------------------------------------=

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

From: NortonNg <[EMAIL PROTECTED]>
Subject: portable computation time estimation?
Date: Thu, 26 Apr 2001 08:42:23 +0000 (UTC)

hi all,

       I am a problem in writing portable code about computation time
estaimation at various CPU speed.
      If a job can done in 2 second on PIII 733Mhz cpu
Can i estimate correctly how long it will take on PIII 900Ghz cpu??

Regards,
jkng

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

From: Ronnie Arosa Carril <[EMAIL PROTECTED]>
Subject: Writing a PCI device driver.
Date: Thu, 26 Apr 2001 10:40:07 +0200

Hi everybody,

I'm new to device driver's world and I'd like to write a Linux device
driver for a PCI board. I've bought O'Reilly's book and I've read it. I
would like to find some more information, better if it's PCI related and
a bit more actualized. Does anyboody knows some place where I can find
some piece of this information? If somebody has any device driver source
code (easy and for a PCI board if it's possible) that can lend me it
will be fantastic.

Thanks in advance for your help.

Ronnie


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

From: "Robert Allmeroth" <[EMAIL PROTECTED]>
Subject: Re: Writing a PCI device driver.
Date: Thu, 26 Apr 2001 11:22:59 +0200

Hi Ronnie

"Ronnie Arosa Carril" <[EMAIL PROTECTED]> schrieb im Newsbeitrag
news:[EMAIL PROTECTED]...
> I'm new to device driver's world and I'd like to write a Linux device
> driver for a PCI board. I've bought O'Reilly's book and I've read it. I
> would like to find some more information, better if it's PCI related and
> a bit more actualized. Does anyboody knows some place where I can find
> some piece of this information? If somebody has any device driver source
> code (easy and for a PCI board if it's possible) that can lend me it
> will be fantastic.

Just have a look into the code of the shipped drivers. At the moment i'm
writing a small howto for myself and needed the same information you are
looking at.

I liked very much the tulip driver ( $(KERNELDIR)/drivers/net/tulip ). I
think
the driver shows clearly what to do.

Robert




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

From: Juergen Hannappel <[EMAIL PROTECTED]>
Subject: Re: portable computation time estimation?
Date: 26 Apr 2001 11:41:59 +0200

NortonNg <[EMAIL PROTECTED]> writes:

> hi all,
> 
>        I am a problem in writing portable code about computation time
> estaimation at various CPU speed.
>       If a job can done in 2 second on PIII 733Mhz cpu
> Can i estimate correctly how long it will take on PIII 900Ghz cpu??
                                                            ^^^
If you talk about the factor 900/733 = 1.227 in speed the estimation
1.6288 seconds should be fairly accurate. If you talk about a factor
1277 which you would get with a 900 Giga-Hertz CPU i would assume that
it would take longer than 1.6 milliseconds, but probably there will
never be a 900GHz PIII.

Greetings,
        Juergen  

-- 
Dr. Juergen Hannappel  Office: W148 Phone: +49 228 73 2447  FAX +49 228 73 7869
mailto:[EMAIL PROTECTED]        Physikalisches Institut der Uni Bonn
http://lisa2.physik.uni-bonn.de/~hannappe   Nussallee 12, D-53115 Bonn, Germany
CERN: Phone: +412276 76461 Fax: 77930 Bat. 892-R-A13 F-01631 CERN CEDEX, France

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

From: "MrHyde" <[EMAIL PROTECTED]>
Crossposted-To: alt.os.linux,comp.os.linux.misc
Subject: Realtek 8139b NIC
Date: Thu, 26 Apr 2001 12:05:59 +0200

HIi,

 I'm trying to use the rtl8139 driver with a RTL8139B (96394S1 - 9260TAIWAN)
Chip integrated on a  Cyrix ST-3WT Mainboard, and I've got a problem. The
driver module is loaded correctly but the NIC doesn't work correctly: it can
send packets, but it  doesn't receive. I'm trying with diferent Linux
distributions (Red-Hat 5.x & 6.x) and with diferent kernel versions (2.0.x,
2.2.x, 2.4.x) and the problem continues. I thought that it was a hardware
problem of the NIC, but in my last trials I tested this mainboard with
Win'98 and the NIC works correctly  (!?).

 The manual of the board says that is 802.3 and 802.3u full compatible, and
 the pinout of the RJ45 connector is:
 Pin 1 Transmit output +
 Pin 2 Transmit output -
 Pin 3 Receive input +
 Pin 6 Receive input -
 Resting pins are not connected.

 Why this card works in Windows and is not working in Linux?? What should I
 try?

 Thanks a lot.

 _____________________
 Oscar Vico
 SOL services on line, s.a.
 Serrano Anguita 10, 3 D
 28004 Madrid - Spain
 Tel. +34 91 446 7984
 Fax. +34 91 446 6965






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

From: Ronnie Arosa Carril <[EMAIL PROTECTED]>
Subject: Re: Writing a PCI device driver.
Date: Thu, 26 Apr 2001 12:27:11 +0200

Robert Allmeroth escribió:

> Hi Ronnie
>
> "Ronnie Arosa Carril" <[EMAIL PROTECTED]> schrieb im Newsbeitrag
> news:[EMAIL PROTECTED]...
> > I'm new to device driver's world and I'd like to write a Linux device
> > driver for a PCI board. I've bought O'Reilly's book and I've read it. I
> > would like to find some more information, better if it's PCI related and
> > a bit more actualized. Does anyboody knows some place where I can find
> > some piece of this information? If somebody has any device driver source
> > code (easy and for a PCI board if it's possible) that can lend me it
> > will be fantastic.
>
> Just have a look into the code of the shipped drivers. At the moment i'm
> writing a small howto for myself and needed the same information you are
> looking at.
>
> I liked very much the tulip driver ( $(KERNELDIR)/drivers/net/tulip ). I
> think
> the driver shows clearly what to do.
>
> Robert

Thank you Robert, I'll take a look.

Ronnie.


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

From: "Cameron Kerr" <[EMAIL PROTECTED]>
Subject: Assigning capabilities to users
Date: Fri, 27 Apr 2001 00:29:53 +1200

Hello, I'm developing some software for an educational
environment. It reads raw ethernet data from a network,
and decodes it.

In order to minimise risk, I would like to give each user
the capability CAP_NET_RAW so they can create the socket
they need for their program to work, instead of assigning
root rights, which is not something I want to do.

Can this be done? I would like to able to put an entry
into the passwd file, so that the capability would be
inherited from the shell.

eg.
cameron:x:1000:100:Cameron Kerr,,,:/home/cameron:givecap CAP_NET_RAW
/bin/bash

Is this even the right way to approach capabilities?

Thanks for any help.
-- 
Cameron Kerr -- cameron.kerr @ paradise.net.nz
Praise Slackware, our baud and saviour!
--

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

From: Kasper Dupont <[EMAIL PROTECTED]>
Subject: Re: File access within a kernel mod
Date: Thu, 26 Apr 2001 13:29:38 +0000

Peter T. Breuer wrote:
> 
> Kasper Dupont <[EMAIL PROTECTED]> wrote:
> > This is a multi-part message in MIME format.
> > Comments are wellcomme, have I forgotten
> > something, can it be done simpler?
> 
> It's not really comprehensible as it is written. Split it up into
> 4 or 5 line subroutines whose names express what they are trying to do,
> and I might be able to comment. Also don't do:
> 
>   if(blah) {
>     long stuff
>   } else {
>     one liner
>   }
> 
> And don't nest if's!  Them thar's novice programming mistakes.

A very often used practice in kernel code, is to use
goto statements instead. More or less like this structure:

if (some_error_occured) goto clean_up_this_and_that;
...
if (some_other_error_occured) goto clean_up_a_litle_more;
...
return res;
clean_up_a_litle_more:
...
clean_up_this_and_that:
...
return error;

I could have written exactly the same using gotos,
but that is normally considered bad programming
practice. I could also have written the same using
lots of duplicated code, which is also bad
programming practice. Just skiping the cleanup code
would create leaks and security holes, which is
definetly a bad idea.

> 
> > #include <linux/module.h>
> > #include <linux/malloc.h>
> > #include <asm/uaccess.h>
> 
> > char *src = NULL;
> > char *dst = NULL;
> > MODULE_PARM(src,"s");
> > MODULE_PARM(dst,"s");
> 
> These are file names, of course?

Obviously.

> 
> > /* This is a kernel module, I must be very
> >  * carefull to clean up everything myself,
> >  * there is nobody who can do it for me.
> >  */
> 
> > int init_module(void)
> > {
> 
> You do ALL the work in init_module! Arghh. Go away. At least call a
> subroutine that says "I do all the work".

This is just an example on how to access files within
a kernel module, the exact example is not any use at
all. In a module intended to be used you would of
couse place the code where you need it. That could be
in init or somewhere else depending on what you are
doing.

Spliting code acros multiple procedures is done for
two reasons: first to avoid duplicating code needed
in multiple places, and second if you are writing
something too big to do correct in one procedure.
Neither is the case in my code.

> 
> >   struct file *srcf,*dstf;
> >   int retval,orgfsuid,orgfsgid;
> >   mm_segment_t orgfs;
> >   char *buffer;
> >   unsigned long page;
> 
> write a struct to hold the data you save. Add a method savedata():
> 
>     mystruct.savedata();

I don't know what you are talking about? Kernel code
is written in C not C++.

> 
> >   /* Save uid and gid used for filesystem access.
> >    * Set user and group to 0 (root)
> >    */
> >   orgfsuid=current->fsuid;
> >   orgfsgid=current->fsgid;
> >   current->fsuid=current->fsgid=0;
> >   /* save FS register and set FS register to kernel
> >    * space, needed for read and write to accept
> >    * buffer in kernel space.
> >    */
> >   orgfs=get_fs();
> >   set_fs(KERNEL_DS);
> 
> >   if (src&&dst&&*src&&*dst) {
> 
> programming style error! That's
> 
>     if (!src)
>       return -EOUCH;
> 
>     if (!dst)
>       return -EOUCH;
> 
>     if (! src[0])
>       return -EINVAL;
> 
>     if (! dst[0])
>       return -EINVAL;
> 

You suggest I just return and skip the cleanup part?
That would leave the calling program with root and
kernel priveleges, not a good idea. Don't introduce
bugs to make code simpler.

And BTW return values from module initializers are
booleans, not error codes. Although error codes
probably would be better, though I'm not the one to
blame about that.

> >     printk("Copying %s to %s\n",src,dst);
> >     /* Allocate one page for buffer */
> >     page = __get_free_page(GFP_KERNEL);
> 
> should loop with retry's, then return -ENOMEM if unsuccessful.

I have not seen any part of the kernel doing that,
so probably you are mistaken.

> 
> >     if (page) {
> 
> Your standard programming mistake. The exceptional case should be
> discarded first.

OK, I agree that would make the code slightly more
readable without breaking the code. But removing
the else part would introduce errors.

> 
> >       buffer=(char*)page;
> >       srcf = filp_open(src, O_RDONLY, 0);
> >       if (IS_ERR(srcf)) {
> >       printk("kcp: Error %ld opening %s\n",-PTR_ERR(srcf),src);
> 
>      and return -EBADF; after discarding the page you got? Memory leak?

There is no leak in my code, if the allocation is
sucessfull I free the page again. Do you suggest
I introduce one????

> 
> >       } else {
> >       /* The object must have a read method */
> >       if (srcf->f_op&&srcf->f_op->read) {
> >         dstf = filp_open(dst, O_WRONLY|O_TRUNC|O_CREAT , 0644);
> >         if (IS_ERR(dstf)) {
> >           printk("kcp: Error %ld opening %s\n",-PTR_ERR(dstf),dst);
> 
> more errors of the same kind.

I don't see the error, the else part is skiped and
the code contiues through the cleanup.

> 
> >         } else {
> >           /* The object must have a write method */
> >           if (dstf->f_op&&dstf->f_op->write) {
> >             do {
> >               /* Read as much as posible into the buffer,
> >                * at most one page.
> >                */
> >               retval=srcf->f_op->read(srcf,buffer,PAGE_SIZE,&srcf->f_pos);
> 
> you should be in a loop here, and it should be a function
> 
>    readfile(filp, buffer)
> 
> but I'm not sure this will work anyway. But maybe.

I am inside a loop, there is a do just above.
I could put the code in a function, but that
would be a function with only one line, I
don't think calling that function would be
much clearer, in particular not if  I gave it
all the necesarry arguments.

> 
> >               if (retval<0) printk("kcp: Read error %d\n",-retval);
> 
> incorrect error treatment.

If there is an error I write an error message
and terminate the loop, I don't see any
incorrect treatment in that.

> 
> >               if (retval>0) {
> >                 int index=0,bufsize=retval;
> >                 /* Continue writing until error or everything
> >                  * written.
> >                  */
> >                 while ((index<bufsize)&&
> >                        ((retval=dstf->f_op->write
> >                          (dstf,buffer+index,bufsize-index,&dstf->f_pos))>0)
> >                        ) index+=retval;
> >                 if (index<bufsize) printk("kcp: Write error %d\n",-retval);
> 
> Impossible to read. Use counters
> 
>             unsigned long offset = 0;
>             unsigned long remaining = blah_size();

That is exactly what I'm doing, I just have
slightly different variable names. And I
keep the entire size of the block instead of
the remaining part, that way I don't have two
variables to update each round but only one.
And there is really not much difference on
the two conditons (index<bufsize) and
(remaining>0)

> 
> and are you seriously going to keep BOTH files open? Surely you have to
> read them a bit at a time? And what if they're over 2GB in size?

Of course I have to keep both files open,
otherwise I would have to store the entire
file in memory. I do copy it a bit at a time.
I think one page is a very reasonable bit to
take each time.

> 
> >               }
> >               /* Copy loop continues until EOF or error.
> >                */
> >             } while (retval>0);
> >             /* Now clean up everything that was actually allocated
> >              */
> 
> ecch.
> 
> >           } else {
> >             printk("kcp: %s does not have a write method\n",dst);
> 
> wrong place. Discard errors first.
> 
> >           }
> >           retval=filp_close(dstf,NULL);
> >           if (retval) printk("kcp: Error %d closing %s\n",-retval,dst);
> >         }
> >       } else {
> >         printk("kcp: %s does not have a read method\n",src);
> >       }
> >       retval=filp_close(srcf,NULL);
> >       if (retval) printk("kcp: Error %d closing %s\n",-retval,src);
> >       }
> >       free_page(page);
> >     } else {
> >       printk("kcp: Out of memory\n");
> >     }
> >   } else printk("kcp: Both src= and dst= must be specified\n");
> 
> >   set_fs(orgfs);
> >   current->fsuid=orgfsuid;
> >   current->fsgid=orgfsgid;
> 
> >   /* End of demo, returning an error code
> >    * makes insmod/modprobe remove the module
> >    * from memory.
> >    */
> >   return 1;
> > }
> 
> Well, it could work under some circumstances! Please clean up your
> code.

Strange comment, could you name any circumstance
under which it would not work. You did not point
out any place I missed an error condition or did
something wrong.

All I see is that you don't understand an if
then else structure, and a lot of advices on
ways to remove them that would either lead to
very bad programming practice or bugs.

I think it would be very interesting to see how
you would have written this. Because if you
really have some good point I'm not able to see
it in your comments.

> 
> Peter

-- 
Kasper Dupont

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

From: "Chris West" <[EMAIL PROTECTED]>
Crossposted-To: comp.os.linux.development.apps,comp.os.linux.networking
Subject: Re: Help - Edit route table in software?
Date: Thu, 26 Apr 2001 14:35:59 +0100

There are a couple of ioctls to handle routing, SIOCADDRT and SIOCDELRT,
Also have a look at SIOC[GS]IF* for interface parameters.

"Sebastien Jean" <[EMAIL PROTECTED]> wrote in message
news:9c56b2$7ac$[EMAIL PROTECTED]...
> Changing the routing table from the command line is easy.  Does anyone
know
> how to change the routing table from within a program written in C/C++?
> What about changing Ethernet device parameters.
>
> Any information on these topics would be greatly appreciated.
>
> Thanks.
>
>



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


** 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 by posting to the
comp.os.linux.development.system newsgroup.

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