Graph/fsInspector.c File Reference

Driver for generating a graph by interpreting the file system as a graph. Traverse the file system from a particular root directory and construct a graph whose vertices are files and directories and whose edges are containment (within a file) or symbol links (as defined by unix). More...

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
#include <dirent.h>
#include <sys/statfs.h>
#include <sys/stat.h>
#include <errno.h>

Classes

struct  nl
 A NODELIST is a linked list of (node, id) pairs where the node is a string associated with the node, and is an integer identifier. More...
struct  el
 An EDGELIST is a linked list of (src,tgt) pairs where the src is a string associated with a file entry and tgt is a string associated with another file entry. More...

Typedefs

typedef nl NODELIST
 A NODELIST is a linked list of (node, id) pairs where the node is a string associated with the node, and is an integer identifier.
typedef nlNODELIST_PTR
 A NODELIST is a linked list of (node, id) pairs where the node is a string associated with the node, and is an integer identifier.
typedef el EDGELIST
 An EDGELIST is a linked list of (src,tgt) pairs where the src is a string associated with a file entry and tgt is a string associated with another file entry.
typedef elEDGELIST_PTR
 An EDGELIST is a linked list of (src,tgt) pairs where the src is a string associated with a file entry and tgt is a string associated with another file entry.

Functions

NODELIST_PTR findVertex (char *n)
 Locate a vertex by name or return NULL if not found.
void recordNode (char *n)
 Record the following string as a vertex.
void recordEdge (char *u, char *v)
 Edges are always added anew.
void process (int level, char *file)
 Process the given directory 'level' levels.
int main (int argc, char **argv)
 Application that loads up the file system, starting from '/' and creates a graph based upon the top 5 levels found.

Variables

NODELIST_PTR headVertex = NULL
 The headVertex of a list containing all visited files.
EDGELIST_PTR headEdge = NULL
 The headEdge of a list containing all known edges.
static int numVertices = 0
 Number of vertices discovered.
static int numEdges = 0
 Number of edges discovered.


Detailed Description

Driver for generating a graph by interpreting the file system as a graph. Traverse the file system from a particular root directory and construct a graph whose vertices are files and directories and whose edges are containment (within a file) or symbol links (as defined by unix).

Author:
George Heineman
Date:
6/15/08

Typedef Documentation

typedef struct el EDGELIST

An EDGELIST is a linked list of (src,tgt) pairs where the src is a string associated with a file entry and tgt is a string associated with another file entry.

The edge could either be containment or a symbolic link.

typedef struct el * EDGELIST_PTR

An EDGELIST is a linked list of (src,tgt) pairs where the src is a string associated with a file entry and tgt is a string associated with another file entry.

The edge could either be containment or a symbolic link.

typedef struct nl NODELIST

A NODELIST is a linked list of (node, id) pairs where the node is a string associated with the node, and is an integer identifier.

typedef struct nl * NODELIST_PTR

A NODELIST is a linked list of (node, id) pairs where the node is a string associated with the node, and is an integer identifier.


Function Documentation

NODELIST_PTR findVertex ( char *  n  ) 

Locate a vertex by name or return NULL if not found.

Parameters:
n desired vertex
Returns:
NODELIST_PTR in the list or NULL if not found.

int main ( int  argc,
char **  argv 
)

Application that loads up the file system, starting from '/' and creates a graph based upon the top 5 levels found.

void process ( int  level,
char *  file 
)

Process the given directory 'level' levels.

Parameters:
level number of levels to probe
file the top-level directory into which to probe.

void recordEdge ( char *  u,
char *  v 
)

Edges are always added anew.

void recordNode ( char *  n  ) 

Record the following string as a vertex.

Checks first to see if it has already been discovered, otherwise it is added anew to the headVertex list.

Parameters:
n the string identifier to be recorded (and searched for).


Variable Documentation

EDGELIST_PTR headEdge = NULL

The headEdge of a list containing all known edges.

NODELIST_PTR headVertex = NULL

The headVertex of a list containing all visited files.

int numEdges = 0 [static]

Number of edges discovered.

int numVertices = 0 [static]

Number of vertices discovered.

Algorithm Development Kit 1.0