Linux-Development-Sys Digest #563, Volume #8     Tue, 13 Mar 01 17:13:11 EST

Contents:
  reading input frpm an other process (Clutters)
  Re: Can linux be trusted? (Willam Hughes)
  IPC parameters (Dragan Cvetkovic)
  Re: Is bootsect.s the code of MBR?? (Bernd Strieder)
  Re: Setting Linux Disk Buffer Cache (Andries Engelbrecht)
  missing definitions (linker problem) (Daniel Koerner)
  Re: IPC parameters ("Lawrence K. Chen, P.Eng.")
  insmod reports unresolved kernel symbols (Manfred Plagmann)
  system call interface to insmod (Jothi P Neelamegam)
  Re: IPC parameters (Dragan Cvetkovic)

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

From: Clutters <[EMAIL PROTECTED]>
Subject: reading input frpm an other process
Date: Tue, 13 Mar 2001 23:46:21 +1300


here is the problem i gust can not seem to work out a way of  checking
for errors in the functions  below (in dictionary.c) that use the tcl
interpreter  because some of them only generate output if there is an
error so if i try to check for errorsmy code gets stuk  when all is
going well.
eg the fuctions like loaddict and startbackup do not return anything
unless the file is missing or there is bad data or somthing.
any ideas please
any constructive comments on other aspects of my coed would be
appreciated.
please dont have a go at me about using non-ANSI functions and stuff

/*==============================
debug.h=====================================*/
/* this is not realy that important to the problem it just makes the
other code compile properly */
#ifndef _jpc_DEBUG_H
#define _jpc_DEBUG_H
#define _DEBUG_ // for the moment untill i learn about makefiles.
#include <stdio.h>

#ifdef _DEBUG_

#define debug0(zero)                      fprintf(stderr,zero);
fflush(stderr);
#define debug1(zero,one)                  fprintf(stderr,zero,one);
fflush(stderr);
#define debug2(zero,one,two)              fprintf(stderr,zero,one,two);
fflush(stderr);
#define debug3(zero,one,two,three)
fprintf(stderr,zero,one,two,three); fflush(stderr);

#endif

#ifndef _DEBUG_

#define debug0(zero)                      /*(stdout,zero);*/
#define debug1(zero,one)                 /*(stdout,zero,one);*/
#define debug2(zero,one,two)              /*(stdout,zero,one,two);*/
#define debug3(zero,one,two,three)
/*(stdout,zero,one,two,three);*/
#endif

#endif



/* ==============================child.h
==================================*/
#ifndef _mdw_CHILD_H
#define _mdw_CHILD_H
#include <stdio.h>
#include <sys/types.h>
#include <sys/time.h>
extern int start_child(char *cmd,
        FILE **readpipe, FILE **writepipe);
#endif



/*============================== child.c
====================================*/
/* this code (child.c/child.h) was writen by someone other than me but
it is prety selfe explanitory */
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include "child.h"
/* Exec the named cmd as a child process, returning
 * two pipes to communicate with the process, and
 * the child's process ID */



int start_child(char *cmd, FILE **readpipe, FILE **writepipe)
{
  int childpid, pipe1[2], pipe2[2];
  if ((pipe(pipe1) < 0) || (pipe(pipe2) < 0))
    {
      perror("pipe"); exit(-1);
    }
  if ((childpid = vfork()) < 0)
    {
      perror("fork"); return(-1);
    } else if (childpid > 0) {  /* Parent. */
      close(pipe1[0]); close(pipe2[1]);
      /* Write to child is pipe1[1], read from
       * child is pipe2[0].  */
      *readpipe = fdopen(pipe2[0],"r");
      *writepipe=fdopen(pipe1[1],"w");
      setlinebuf(*writepipe);
      return childpid;
    }
  else
    {  /* Child. */
      close(pipe1[1]); close(pipe2[0]);
      /* Read from parent is pipe1[0], write to
       * parent is pipe2[1].  */
      dup2(pipe1[0],0);
      dup2(pipe2[1],1);
      close(pipe1[0]); close(pipe2[1]);
      if (execlp(cmd,cmd,NULL) < 0)
 perror("execlp");
      /* Never returns */
    }

}



/*=====================================
dictionary.h============================*/
#ifndef _jpc_DICTIONARY_H_
#define _jpc_DICTIONARY_H_


#include "child.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <limits.h>
#include "debug.h"

#define resultsize 10000
FILE * tclWRITE_TO;
FILE * tclREAD_FROM;
char result[resultsize];
char private_dict_path[PATH_MAX];

/*function prototypes*/

int startbackup();


int dictionary_start(char * commandpath, char* dictpath);
/*
 * this function will start the tcl interpreter and set it up for use
 * it loads the dictionary from the specified file
 */

int restore();
/*
 * this coppies the backup dictionary over the current dictionary
 * good if the current dictionary gets corrupted or deleted
 */

int loaddict(char * dictpath);
/*
 * this function will load a dictionary from the
 * specafied file
 */

int savedict( char* path);
/*
 * this function will save the dictionary to the
 * specified file
 */


char *  keylget( char* key);
/*
 * this function will return the value associated
 * with index from the dictionary specified by dict
 * if the value is not found then value is set to ""
 * for complete documentation of this function see the tcl man pages
 */


int keylset( char * key , char * value);
/*
 * this function will set the value associated with
 * the index in the  dictionary to the one that is provided
 * if the key is not found then it is added to the dictionary to the end

of the dictionary
 * for complete documentation of this function see the tcl man pages
 */


int setall(char * dict);
/*
 * this function will replace the current dictionary with
 * the new dictionary given by char * dict
 */

char * getall();
/*
 * returns the whole dictionary
 */


int lockall();
/*
 *set every user's lock to on
 */


int unlockall();
/*
 *set every user's lock to off
 */




#endif

/*====================================dictionary.c==============================

*/
#include "dictionary.h"
#define _INDEPENDENT_TEST_DICTIONARY_C_ // again this is just untill i
get around to learning makefiles



char *  fgetmax(char * result , int size , FILE * fp)
/* just ignor the fact that function it is a mess because i dont know
what i am diong  but this is the heart of my problem if there is an
error from the functions below
 * it is not always just one line
 */
{ char * c;
  debug0("char *  fgetmax(char * result , int size , FILE * fp) \n");

  c = fgets(result,size,fp);
  fprintf(stdout,"%s\n===============================\n",result);
  fflush(stdout);

  return result;
}


int initTcl()
{

 debug0("int initTcl() \n");
  fputs("proc save_dict {} { system cp -f /var/diald/dictionary
/var/diald/dictionary.backup\n exec sync &\n after 1200000 save_dict
}\n",tclWRITE_TO);

  return 0;
}


int startbackup()
{
 debug0("int startbackup() \n");
  fputs( "save_dict\n",tclWRITE_TO);
  fgetmax(result,resultsize,tclREAD_FROM);
  return 0;
}
int dictionary_start(char * commandpath, char* dictpath)
{
   debug0("int dictionary_start(char * commandpath, char* dictpath)
\n");
  if(commandpath==NULL)
    strcpy(commandpath,"/usr/bin/tcl");
  if( start_child(commandpath,&tclREAD_FROM,&tclWRITE_TO)<0)
    {
      fprintf(stderr,"Could not start interpreter\n");
      exit(EXIT_FAILURE);
    }
  initTcl();
  loaddict(dictpath);


  return 0;
}

int restore()
{
 debug0(" int restore()\n");
  fputs("system cp -f /var/diald/dictionary.backup
/var/diald/dictionary\n exec sync&\n",tclWRITE_TO);
  return 0;
}

int loaddict(char * dictpath)
{
 debug0("int loaddict(char * dictpath) \n");
  strcpy(private_dict_path,dictpath);

  fputs( "if [catch { set dictionary [read_file ",tclWRITE_TO);
  fputs(dictpath,tclWRITE_TO);
  fputs("] } ] {system cp -f ",tclWRITE_TO);
  fputs(dictpath,tclWRITE_TO);
  fputs(".backup ",tclWRITE_TO);
  fputs(dictpath,tclWRITE_TO);
  fputs(" }\n",tclWRITE_TO);
  return 0;

}




int savedict( char* path)
{
 debug0("int savedict( char* path) \n");
  fputs( "write_file ", tclWRITE_TO);
  fputs( path, tclWRITE_TO);
  fputs( " $dictionary\n exec sync &\n", tclWRITE_TO);
  return 0;
}

char *  keylget( char* key)
{
   debug0(" \n");
   //if [expr ![keylget dictionary [lindex $input 1] value]] {set value
""}


  fputs( "if [expr ![keylget dictionary ", tclWRITE_TO);
  fputs(key,tclWRITE_TO);
  fputs(" value]] {set value \"\"}\necho $value\n",tclWRITE_TO);
  fgetmax(result,resultsize,tclREAD_FROM);
  return 0;
}

int keylset( char * key , char * value)
{
   debug0("int keylset( char * key , char * value) \n");
  fputs("keylset dictionary ",tclWRITE_TO);
  fputs(key,tclWRITE_TO);
  fputs(" ",tclWRITE_TO);
  fputs(value,tclWRITE_TO);
  fputs("\n",tclWRITE_TO);
  savedict(private_dict_path);
  return 0;
}


int setall(char * dict)
{
   debug0(" int setall(char * dict)\n");
  fputs( "set dictionary  ",tclWRITE_TO);
  fputs(dict ,tclWRITE_TO);
  fputs("\n" ,tclWRITE_TO);
  return 0;
}

char * getall()
{
 debug0("char * getall() \n");
  fputs(  "echo $dictionary\n",tclWRITE_TO);
  fgetmax(result,resultsize,tclREAD_FROM);
  return 0;
}


int lockall()
{
 debug0("int lockall() \n");
  fputs( " foreach user [keylkeys dictionary password] { keylset
dictionary lock.$user on }\n",tclWRITE_TO);
  return 0;

}

int unlockall()
{
   debug0("int unlockall() \n");
  fputs( " foreach user [keylkeys dictionary password] { keylset
dictionary lock.$user off }\n",tclWRITE_TO);
  return 0;
}


#ifdef _INDEPENDENT_TEST_DICTIONARY_C_

int main (void)
{
  char  dictpath[40000];

  char  index[40000];
  char  value[40000];
  int DICTPATH = 0;
  int choice;

  while(1){
    fprintf(stdout,"1.  startbackup\n2. dictionary_start\n3. restore\n4.

loaddict\n5. savedict\n6. keylget\n7. keylset\n8. setall\n9. getall
\n10. lockall \n11. unlockall
 12. Quit\n");
    scanf("%d" ,&choice);
    switch(choice){

    case 1 :
      startbackup();
      break;
    case 2:
      while (DICTPATH == 0){
 fprintf(stdout,"enter the path:\n");
 if (EOF == scanf("%s", dictpath)) fprintf( stderr,"that file is
fucked");
 dictionary_start("/usr/bin/tcl",dictpath);
 break;
      case 3 :
 restore();

 break;
      case 4:
 loaddict(dictpath);


 break;
      case 5:
 savedict(dictpath);
 break;
      case 6:
 fprintf(stdout,"enter key:\n");
 scanf("%s",index);
 keylget(index);
 break;
      case 7:
 fprintf(stdout,"enter key :\n");
 scanf("%s",index);
 fprintf(stdout,"enter value :\n");
 scanf("%s",value);
 keylset(index,value);
 break;
      case 8:
 fprintf(stdout,"enter new dict :\n");
 scanf("%s",value);
 setall(value);
 break;
      case 9:
 getall();
 break;
      case 10:
 lockall();
 break;
      case 11:
 unlockall();
 break;
      case 12:
 exit( EXIT_SUCCESS);
 break;
      default:
 fscanf(stdin,"%s",value);
 fprintf( stdout,"sory try again that is not a good selection\n\n");

 scanf("%d" ,&choice);
 break;


      }
    }


  }
  exit( EXIT_SUCCESS);
}

#endif






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

From: Willam Hughes <[EMAIL PROTECTED]>
Crossposted-To: 
comp.lang.c,comp.os.linux.development.apps,comp.sys.be.programmer,comp.sys.mac.programmer.misc,comp.unix.bsd.freebsd.misc,comp.unix.bsd.misc,gnu.gcc
Subject: Re: Can linux be trusted?
Date: Tue, 13 Mar 2001 11:08:04 -0500
Reply-To: me

[EMAIL PROTECTED] wrote:

> In article <[EMAIL PROTECTED]>, Robert Redelmeier  <[EMAIL PROTECTED]> wrote:
>
> >> How ? Is it an exact binary number ?
>
> >YES!  3d = 1.1b * 2^1b .
> >
> >In general, all non-mantissa over[under?]flowing integers
> >can be exactly representing by floats.
>
> You are assuming that normalized floats are x.xxxx * 10^nn and not
> 0.xxxx * 10^nn.
>

The question of how you store your floating point numbers
(e.g. implicit leading 1 or not) has nothing to do with
whether a given real number x has an exact binary
representation.  (clearly all integers have an exact
binary representation).

                     -William Hughes


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

Subject: IPC parameters
From: Dragan Cvetkovic <[EMAIL PROTECTED]>
Reply-To: [EMAIL PROTECTED]
Date: 13 Mar 2001 10:22:01 -0500

        Hi,
how do I tune IPC parameters on Linux systems (Debian in this case) to
change the default limits? For example, Solaris has /etc/system file where
you can specify maximal size of shared memory, size of message queues
etc. Is something like that available on Linux? Is it needed?

Thanks a lot. Dragan

-- 
Dragan Cvetkovic, 

To be or not to be is true. G. Boole

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

From: Bernd Strieder <[EMAIL PROTECTED]>
Subject: Re: Is bootsect.s the code of MBR??
Date: Tue, 13 Mar 2001 17:06:43 +0100

hushui wrote:
> 
> thank you.
> > The kernel image has a boot  sector in the front so that
>  the front is following the 512 bytes boot sector (mbr) ??? Is it called the
> second boot sector?

The kernel can be booted if you copy it to the beginning of a device
that is booted via BIOS. The first 512 bytes of the kernel are designed
to make this possible. These 512 bytes are a bootsector, but they are
not a MBR. A MBR contains some things more, the partition table and
perhaps some code for booting. Usually the MBR contains some code to
read from the partition table which partition is activated and boots
this partition.

LILO can be installed into a bootsector of a partition started by the
code of the MBR. LILO installed in the MBR is designed to keep the
partition table, while adding some code to be able to boot the partition
you specified. The kernel copied to the begeginning of a block device
will kill the MBR, especially the partition table so this is only used
to create floppy discs with just the kernel on it to boot. LILO can boot
a kernel spread over the whole disc in some filesystem (only ext2?), no
need to copy it to the beginning of a partition to use the kernels
bootsector. AFAIK the kernel has different entry points, one for the
BIOS and one for LILO, so its usable for both methods to boot without
changing it.

> 
>  > LILO has its own boot sector. This is contained in the binary file
> > /boot/boot.b.  When you run lilo to install it, it copies from this
> > file to the boot sector of the target boot device.
> you means the first 512 bytes of the harddisk,that is mbr  ??
> I want to know the code in mbr (except the partion table) is including
> what??? lilo's code that is boot.b???

The code in MBRs is usually used to load more code to do more
sophisticated booting. There are many possibilities here. Every
bootloader has different ideas, and there are still a lot of them. You
have to look at the concrete things in the sources.

How booting is done has been in a permanent flux since I first got into
contact with Linux 6 years ago. It seems that there never has been found
a method to do it the right way for the majority. Linux always had to
accomodate to being one of many OSs on a PC. That makes booting more
hairy than ever needed. It is a symptom of Linux, that there are often
confusingly many methods to do simple things, but it has solidified a
lot over the years.

Bernd Strieder


> 
>  thank you .
> I am a start learner.

Heavy goin' for a start learner, but somehow logical. Let's start where
the whole game starts. You have some way in front of you to get through.

Bernd Strieder

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

From: Andries Engelbrecht <[EMAIL PROTECTED]>
Subject: Re: Setting Linux Disk Buffer Cache
Date: Tue, 13 Mar 2001 17:30:03 -0000

I already recieved replies back that it is not possible to fix the buffer 
cache to a certain value. Is it however possible to set the block size of 
the filesystem in Linux? I'm using ext2 filesystems.

Andries Engelbrecht wrote:
> 
> Is it possible to set Linux to use a certain amount of RAM for disk 
buffer 
> cache or a percentage of total RAM for this purpose?
> 
> If so, how can I do it?
> 


--
Posted via CNET Help.com
http://www.help.com/

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

From: Daniel Koerner <[EMAIL PROTECTED]>
Subject: missing definitions (linker problem)
Date: Tue, 13 Mar 2001 21:14:48 +0100

Hi folks.

Anyone heard about functions like:

undefined reference to `__check_eh_spec'
undefined reference to `__start_cp_handler'
undefined reference to `__eh_alloc'

(taken from my linker output - by the way: doing crossompile)

Daniel

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

From: "Lawrence K. Chen, P.Eng." <[EMAIL PROTECTED]>
Subject: Re: IPC parameters
Date: Tue, 13 Mar 2001 14:36:22 -0500

Well, when I wanted to change semaphore settings on my Linux-2.2.x systems, I
edited sem.h in

/usr/src/linux/include/linux

And, rebuilt the kernel.

However, Linux 2.4 might allow you access to this via sysctl(8).

Then is would be something like:

sysctl -p /etc/sysctl.conf

Then a line like:

kernel.sem="SEMMSL SEMMNS SEMOPM SEMMNI"

would do it.

I haven't tried it, because the default values are sufficient to get my
database started.

Dragan Cvetkovic wrote:
> 
>         Hi,
> how do I tune IPC parameters on Linux systems (Debian in this case) to
> change the default limits? For example, Solaris has /etc/system file where
> you can specify maximal size of shared memory, size of message queues
> etc. Is something like that available on Linux? Is it needed?
> 
> Thanks a lot. Dragan
> 
> --
> Dragan Cvetkovic,
> 
> To be or not to be is true. G. Boole

-- 
    Who: Lawrence Chen, P.Eng.          Email: [EMAIL PROTECTED]
   What: Software Developer               URL: http://www.opentext.com/basis
  Where: Open Text, BASIS Division      Phone: 614-761-7449
         5080 Tuttle Crossing Blvd.       Fax: 614-761-7269
         M/S 7&8
         Dublin, OH  43016                ICQ: 12129673
  DISCLAIMER: All opinions expressed are mine and *NOT* my employers

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

From: Manfred Plagmann <[EMAIL PROTECTED]>
Subject: insmod reports unresolved kernel symbols
Date: Wed, 14 Mar 2001 09:28:52 +1300

Hi,
I am in the middle to write a simple ISA driver and tried to load it
using insmod -f. It comes back with a list of unresolved symbols which
are all (as far as I can tell) kernel symbols such as printk, kmalloc,
kfree, register_chrdev, ...

What am I missing? I tried to load A. Rubini's scull example driver with
the very same result.

Any help is appreciated.

Manfred



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

From: Jothi P Neelamegam <[EMAIL PROTECTED]>
Subject: system call interface to insmod
Date: Tue, 13 Mar 2001 15:02:16 -0600

Hi All,

Is there a system call interface to insmod - i.e. can I insmod a module
from inside a c program, rather than from console.

Thanks
Jothi



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

Subject: Re: IPC parameters
From: Dragan Cvetkovic <[EMAIL PROTECTED]>
Reply-To: [EMAIL PROTECTED]
Date: 13 Mar 2001 16:11:18 -0500

"Lawrence K. Chen, P.Eng." <[EMAIL PROTECTED]> writes:
> However, Linux 2.4 might allow you access to this via sysctl(8).
> 
> Then is would be something like:
> 
> sysctl -p /etc/sysctl.conf
> 
> Then a line like:
> 
> kernel.sem="SEMMSL SEMMNS SEMOPM SEMMNI"
> 
> would do it.
> 
        Hm, I thought I have cancelled my message (since I have found
sysctl(8)) which seem to exist on my 2.2.18pre21 Debian system. However, I
noticed some interesting behaviour there: my machine (with 64MB of memory)
has (as per /proc/sys/kernel/shm*) shmmax = 33554432 and shmall =
4194304. I can decrease it to say 1000000 but I can not increase it to more
than 4194304. An other system (Redhat 6.2 with kernel 2.2.16 and 128MB of
memory) has shmmax = 33554432 (as on my system) but shmall = 16777216. How
come? Is there some limit for shmall that depends on RAM size?  File
/etc/sysctl.conf is the same on both machines.

Thanks, Dragan

-- 
Dragan Cvetkovic, 

To be or not to be is true. G. Boole

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


** 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