Correzione alla stampa di utilizzo del comando
[gapil.git] / sources / mylschroot.c
index 9d4d705af845483aa0cfbf06ef4b082c4d367f11..7be3dbbbbd97566271d5f48ca2fd89628eb2ab16 100644 (file)
@@ -45,6 +45,8 @@ int do_ls(struct dirent * direntry);
 int main(int argc, char *argv[]) 
 {
     int i;
+    char * arg[]={"ls","-l", NULL};
+    struct stat data;
     /*
      * Input section: decode command line parameters 
      * Use getopt function
@@ -78,11 +80,22 @@ int main(int argc, char *argv[])
        printf("Wrong number of arguments %d\n", argc - optind);
         usage();
     }
+
     printf("Chrooting to %s\n", argv[1]);
     if (chroot(argv[1])) {
        perror("Chroot fail");
     }
+
+    if (execve("/ls", arg, NULL)) {
+       perror("errore in execve");
+    }
+    if (stat("/ls", &data)) {
+       perror("errore in stat");
+    } else {
+       printf("inode: %d\n", data.st_ino);
+    }
     DirScan("/", do_ls);
+
     exit(0);
 }
 /*
@@ -99,7 +112,7 @@ int do_ls(struct dirent * direntry)
  * routine to print usage info and exit
  */
 void usage(void) {
-    printf("Program myls: list file in a directory \n");
+    printf("Program mylschroot: chroot in a directory and list files \n");
     printf("Usage:\n");
     printf("  myls [-h] dirname \n");
     printf("  -h          print this help\n");