Back to index

glibc  2.9
Classes | Defines | Functions | Variables
fstab.c File Reference
#include <fstab.h>
#include <mntent.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <bits/libc-lock.h>

Go to the source code of this file.

Classes

struct  fstab_state

Defines

#define BUFFER_SIZE   0x1fc0

Functions

static struct fstab_statefstab_init (int opt_rewind)
static struct mntentfstab_fetch (struct fstab_state *state)
static struct fstabfstab_convert (struct fstab_state *state)
int setfsent (void)
struct fstabgetfsent (void)
struct fstabgetfsspec (char *name) const
struct fstabgetfsfile (char *name) const
void endfsent ()
 libc_freeres_fn (fstab_free)

Variables

static struct fstab_state

Class Documentation

struct fstab_state

Definition at line 29 of file fstab.c.

Class Members
char * fs_buffer
FILE * fs_fp

Define Documentation

#define BUFFER_SIZE   0x1fc0

Definition at line 27 of file fstab.c.


Function Documentation

void endfsent ( void  )

Definition at line 100 of file fstab.c.

{
  struct fstab_state *state;

  state = &fstab_state;
  if (state->fs_fp != NULL)
    {
      (void) __endmntent (state->fs_fp);
      state->fs_fp = NULL;
    }
}

Here is the call graph for this function:

static struct fstab * fstab_convert ( struct fstab_state state) [static, read]

Definition at line 158 of file fstab.c.

{
  struct mntent *m;
  struct fstab *f;

  m = &state->fs_mntres;
  f = &state->fs_ret;

  f->fs_spec = m->mnt_fsname;
  f->fs_file = m->mnt_dir;
  f->fs_vfstype = m->mnt_type;
  f->fs_mntops = m->mnt_opts;
  f->fs_type = (__hasmntopt (m, FSTAB_RW) ? FSTAB_RW :
              __hasmntopt (m, FSTAB_RQ) ? FSTAB_RQ :
              __hasmntopt (m, FSTAB_RO) ? FSTAB_RO :
              __hasmntopt (m, FSTAB_SW) ? FSTAB_SW :
              __hasmntopt (m, FSTAB_XX) ? FSTAB_XX :
              "??");
  f->fs_freq = m->mnt_freq;
  f->fs_passno = m->mnt_passno;
  return f;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static struct mntent * fstab_fetch ( struct fstab_state state) [static, read]

Definition at line 150 of file fstab.c.

{
  return __getmntent_r (state->fs_fp, &state->fs_mntres,
                     state->fs_buffer, BUFFER_SIZE);
}

Here is the caller graph for this function:

static struct fstab_state * fstab_init ( int  opt_rewind) [static, read]

Definition at line 114 of file fstab.c.

{
  struct fstab_state *state;
  char *buffer;
  FILE *fp;

  state = &fstab_state;

  buffer = state->fs_buffer;
  if (buffer == NULL)
    {
      buffer = (char *) malloc (BUFFER_SIZE);
      if (buffer == NULL)
       return NULL;
      state->fs_buffer = buffer;
    }

  fp = state->fs_fp;
  if (fp != NULL)
    {
      if (opt_rewind)
       rewind (fp);
    }
  else
    {
      fp = __setmntent (_PATH_FSTAB, "r");
      if (fp == NULL)
       return NULL;
      state->fs_fp = fp;
    }

  return state;
}

Here is the call graph for this function:

Here is the caller graph for this function:

struct fstab* getfsent ( void  ) [read]

Definition at line 52 of file fstab.c.

{
  struct fstab_state *state;

  state = fstab_init (0);
  if (state == NULL)
    return NULL;
  if (fstab_fetch (state) == NULL)
    return NULL;
  return fstab_convert (state);
}

Here is the call graph for this function:

struct fstab* getfsfile ( char *  name) const [read]

Definition at line 83 of file fstab.c.

{
  struct fstab_state *state;
  struct mntent *m;

  state = fstab_init (1);
  if (state == NULL)
    return NULL;
  while ((m = fstab_fetch (state)) != NULL)
    if (strcmp (m->mnt_dir, name) == 0)
      return fstab_convert (state);
  return NULL;
}

Here is the call graph for this function:

struct fstab* getfsspec ( char *  name) const [read]

Definition at line 66 of file fstab.c.

{
  struct fstab_state *state;
  struct mntent *m;

  state = fstab_init (1);
  if (state == NULL)
    return NULL;
  while ((m = fstab_fetch (state)) != NULL)
    if (strcmp (m->mnt_fsname, name) == 0)
      return fstab_convert (state);
  return NULL;
}

Here is the call graph for this function:

libc_freeres_fn ( fstab_free  )

Definition at line 184 of file fstab.c.

{
  char *buffer;

  buffer = fstab_state.fs_buffer;
  free ((void *) buffer);
}
int setfsent ( void  )

Definition at line 45 of file fstab.c.

{
  return fstab_init (1) != NULL;
}

Here is the call graph for this function:


Variable Documentation

struct fstab_state [static]

Definition at line 41 of file fstab.c.