home *** CD-ROM | disk | FTP | other *** search
/ Boot Disc 15 / boot-disc-1997-11.iso / Debian / Tools / LODLIN16.ZIP / LODLIN16 / INITRD / LINUXRC.C < prev    next >
C/C++ Source or Header  |  1996-03-18  |  845b  |  38 lines

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <sys/types.h>
  4. #include <fcntl.h>
  5. #include <unistd.h>
  6. #include <sys/mount.h>
  7. #include <linux/fs.h>
  8.  
  9.  
  10. void mount_proc(void)
  11. {
  12.   /* mkdir("/proc",0744); */
  13.   mount(0,"/proc","proc",0,0);  
  14. }
  15.  
  16.  
  17. main(int argc, char **argv, char **env)
  18. {
  19.   char **a=argv, **e=env;
  20.   char *real_root;
  21.   FILE *f;
  22.   fputs("\n\n\n\nHello, here ist /linuxrc printing\n",stdout);
  23.   fputs("This is our argv[]:\n",stdout);
  24.   while (*a) printf(">%s<\n",*a++);
  25.   fputs("This is our env[]:\n",stdout);
  26.   while (*e) printf(">%s<\n",*e++);
  27.   real_root = getenv("real_root");
  28.   if (real_root) {
  29.     printf("we are changing root to device %s\n",real_root);
  30.     mount_proc();
  31.     if (! (f=fopen("/proc/sys/kernel/real-root-dev","w"))) return 0;
  32.     fprintf(f, "%s\n",real_root);
  33.     fclose(f);
  34.   }
  35.   fputs("\n\n",stdout);
  36.   return 0;
  37. }
  38.