Back to index

glibc  2.9
Enumerations | Functions | Variables
subopt.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

Go to the source code of this file.

Enumerations

enum  {
  RO_OPTION = 0, RW_OPTION, READ_SIZE_OPTION, WRITE_SIZE_OPTION,
  THE_END
}

Functions

int main (int argc, char *argv[])

Variables

int do_all
const char * type
int read_size
int write_size
int read_only
const char * mount_opts []

Enumeration Type Documentation

anonymous enum
Enumerator:
RO_OPTION 
RW_OPTION 
READ_SIZE_OPTION 
WRITE_SIZE_OPTION 
THE_END 

Definition at line 11 of file subopt.c.


Function Documentation

int main ( int  argc,
char *  argv[] 
)

Definition at line 30 of file subopt.c.

{
  char *subopts, *value;
  int opt;

  while ((opt = getopt (argc, argv, "at:o:")) != -1)
    switch (opt)
      {
      case 'a':
        do_all = 1;
        break;
      case 't':
        type = optarg;
        break;
      case 'o':
        subopts = optarg;
        while (*subopts != '\0')
          switch (getsubopt (&subopts, mount_opts, &value))
            {
            case RO_OPTION:
              read_only = 1;
              break;
            case RW_OPTION:
              read_only = 0;
              break;
            case READ_SIZE_OPTION:
              if (value == NULL)
                abort ();
              read_size = atoi (value);
              break;
            case WRITE_SIZE_OPTION:
              if (value == NULL)
                abort ();
              write_size = atoi (value);
              break;
            default:
              /* Unknown suboption.  */
              printf ("Unknown suboption `%s'\n", value);
              break;
            }
        break;
      default:
        abort ();
      }

  /* Do the real work.  */

  return 0;
}

Here is the call graph for this function:


Variable Documentation

Definition at line 5 of file subopt.c.

const char* mount_opts[]
Initial value:
{
  [RO_OPTION] = "ro",
  [RW_OPTION] = "rw",
  [READ_SIZE_OPTION] = "rsize",
  [WRITE_SIZE_OPTION] = "wsize",
  [THE_END] = NULL
}

Definition at line 20 of file subopt.c.

Definition at line 9 of file subopt.c.

Definition at line 7 of file subopt.c.

const char* type

Definition at line 6 of file subopt.c.

Definition at line 8 of file subopt.c.