/[grub]/grub2/util/grub-emu.c
ViewVC logotype

Diff of /grub2/util/grub-emu.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.20 by okuji, Sat Aug 6 15:50:07 2005 UTC revision 1.21 by okuji, Sun Aug 14 19:36:55 2005 UTC
# Line 23  Line 23 
23  #include <argp.h>  #include <argp.h>
24  #include <string.h>  #include <string.h>
25  #include <signal.h>  #include <signal.h>
26    #include <sys/types.h>
27    #include <unistd.h>
28    
29  #include <grub/mm.h>  #include <grub/mm.h>
30  #include <grub/setjmp.h>  #include <grub/setjmp.h>
# Line 95  static struct argp_option options[] = { Line 97  static struct argp_option options[] = {
97    {"device-map",  'm', "FILE", 0, "use FILE as the device map", 0},    {"device-map",  'm', "FILE", 0, "use FILE as the device map", 0},
98    {"directory",   'd', "DIR",  0, "use GRUB files in the directory DIR", 0},    {"directory",   'd', "DIR",  0, "use GRUB files in the directory DIR", 0},
99    {"verbose",     'v', 0     , 0, "print verbose messages", 0},    {"verbose",     'v', 0     , 0, "print verbose messages", 0},
100      {"hold",        'H', "SECONDS", OPTION_ARG_OPTIONAL, "wait until a debugger will attach", 0},
101    { 0, 0, 0, 0, 0, 0 }    { 0, 0, 0, 0, 0, 0 }
102  };  };
103    
# Line 103  struct arguments Line 106  struct arguments
106    char *root_dev;    char *root_dev;
107    char *dev_map;    char *dev_map;
108    char *dir;    char *dir;
109      int hold;
110  };  };
111    
112  static error_t  static error_t
# Line 124  parse_opt (int key, char *arg, struct ar Line 128  parse_opt (int key, char *arg, struct ar
128      case 'v':      case 'v':
129        verbosity++;        verbosity++;
130        break;        break;
131        case 'H':
132          args->hold = arg ? atoi (arg) : -1;
133          break;
134      case ARGP_KEY_END:      case ARGP_KEY_END:
135        break;        break;
136      default:      default:
# Line 143  main (int argc, char *argv[]) Line 150  main (int argc, char *argv[])
150    struct arguments args =    struct arguments args =
151      {      {
152        .dir = DEFAULT_DIRECTORY,        .dir = DEFAULT_DIRECTORY,
153        .dev_map = DEFAULT_DEVICE_MAP        .dev_map = DEFAULT_DEVICE_MAP,
154          .hold = 0
155      };      };
156        
157    progname = "grub-emu";    progname = "grub-emu";
158        
159    argp_parse (&argp, argc, argv, 0, 0, &args);    argp_parse (&argp, argc, argv, 0, 0, &args);
160    
161      /* Wait until the ARGS.HOLD variable is cleared by an attached debugger. */
162      if (args.hold && verbosity > 0)
163        printf ("Run \"gdb %s %d\", and set ARGS.HOLD to zero.\n",
164                progname, (int) getpid ());
165      while (args.hold)
166        {
167          if (args.hold > 0)
168            args.hold--;
169    
170          sleep (1);
171        }
172      
173    /* Make sure that there is a root device.  */    /* Make sure that there is a root device.  */
174    if (! args.root_dev)    if (! args.root_dev)
175      {      {

Legend:
Removed from v.1.20  
changed lines
  Added in v.1.21

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26