| Rev | Line |   | 
|---|
| [9] | 1 | /*
 | 
|---|
 | 2 | newroot.c
 | 
|---|
 | 3 | 
 | 
|---|
 | 4 | Replace the current root with a new one
 | 
|---|
 | 5 | */
 | 
|---|
 | 6 | 
 | 
|---|
 | 7 | #include <errno.h>
 | 
|---|
 | 8 | #include <stdio.h>
 | 
|---|
 | 9 | #include <stdlib.h>
 | 
|---|
 | 10 | #include <string.h>
 | 
|---|
 | 11 | #include <unistd.h>
 | 
|---|
 | 12 | 
 | 
|---|
 | 13 | int main(int argc, char *argv[])
 | 
|---|
 | 14 | {
 | 
|---|
 | 15 |         int r;
 | 
|---|
 | 16 |         char *dev;
 | 
|---|
 | 17 | 
 | 
|---|
 | 18 |         if (argc != 2)
 | 
|---|
 | 19 |         {
 | 
|---|
 | 20 |                 fprintf(stderr, "Usage: newroot <block-special>\n");
 | 
|---|
 | 21 |                 exit(1);
 | 
|---|
 | 22 |         }
 | 
|---|
 | 23 |         dev= argv[1];
 | 
|---|
 | 24 |         r= mount(dev, "/", 0 /* !ro */);
 | 
|---|
 | 25 |         if (r != 0)
 | 
|---|
 | 26 |         {
 | 
|---|
 | 27 |                 fprintf(stderr, "newroot: mount failed: %s\n", strerror(errno));
 | 
|---|
 | 28 |                 exit(1);
 | 
|---|
 | 29 |         }
 | 
|---|
 | 30 |         return 0;
 | 
|---|
 | 31 | }
 | 
|---|
       
      
  Note:
 See   
TracBrowser
 for help on using the repository browser.