views:

105

answers:

3

Hi guys i'm having a project for the university in which (above others ) i have to get the minix os version from kernell call.I'm not a very experienced programmer so this is what i have come to (with some help )

int main (int argc, char *argv[] )
{
    char M3ca1[23];
    message ml;
    m.m_u.m_m1.m3ca1= OS_VERSION;
    char temp=_syscall(MM,69,&m);
    printf("the os version is %c\n",temp);
    return 0;
}

and i get multiple errors.IF you have any ideas it would be greatly appreciated.

A: 

Now i've updated somehow the program.THe full source code is this

#include <sys/types.h>
#include <errno.h>
#include <signal.h>
#include <stdlib.h>
#include <stdio.h>
#include <lib.h>
#include <string.h>
#include "/usr/src/include/minix/config.h"
int main(void)
{
  char m3ca1[23];
  message m;
  m.m_u.m_m1.mip1= strcpy(char  *OS_VERSION,char  *s2);
  temp=_syscall(MM,69,&m);
  printf("the os version is %c\n",temp);
  return 0;
  }

void strcpy(char *ret, register const char *s2)
{
 register char *s1=ret;
 while (*s1++ != '\0');
 s1--;
 while (*s1++ = *s2++);
 return ret;
}

when i type "make" i get the following : line 13 :unkown selector mip1 line 13 char not expected make in /usr/src/commands/simple :exite code 1 Make :made "..." look old

majnun

majnun
A: 

This code does what you are asking for:

#include <stdio.h>
#include<minix/config.h>

int main(int argc, char**argv) {
    printf("the os version is %s.%s\n",OS_RELEASE,OS_VERSION);
    return 0;
}

If this is a university project I doubt this is what is being asked of you. Sure you aren't being asked to implement a new system call that gives the os version, and then write a small program that calls it?

D'Nabre
A: 

I saw your program and thank you.What i'm asked to do is what you said in your answer.I have to add a system call and then write a program that calls it.My english are not good enough to put it right from the first place.So i have no idea what to do and my deadline is 8 hours ahead.If anyone can send me in the right direction i would greatly appreciate it.I also wrote this code

#include <sys/types.h>
#include <errno.h>
#include <signal.h>
#include <stdlib.h>
#include <stdio.h>
#include <lib.h>
#include <string.h>
#include "../../kernel/config.h"

int main(void)
{

 char* version;
 message m;
 char ret=0;
 m.m3ca1[10]= strcpy( ret, OS_VERSION);  
 version=_syscall(MM,69,&m);
 printf("h ekdosh tou pyrhna einai %s\n", version);
 return (0);
}

char *
strcpy (char *ret, register const char *s2)
{
 register char *s1=ret;
 while (*s1++=*s2++);
 return ret;
}

and i get "can't compile,no transformation applies" as an error

majnun