CS360 Midterm -- October 18, 2000. Cheat Sheet

Stat

Here are relevant fields for the stat struct:

struct stat {
  int    st_size;
  int    st_ino;
  int    st_mode;
  int    st_nlink;
  time_t st_atime;
  time_t st_mtime;
  ...
}

S_ISDIR(int) -- returns whether or not the given mode is a directory.

int stat(char *name, struct stat *buf);    /* Returns 0 if ok */
int lstat(char *name, struct stat *buf);   /* Returns 0 if ok */

Opendir

Here are relevant fields for the dirent struct:

struct dirent {
  char   d_name[256];
...
}

DIR *opendir(char *name);          /* Returns NULL on an error */
int closedir(DIR *d);
struct dirent *readdir(DIR *d);    /* Returns NULL when there are no more
                                      directory listings */

Dllists

typedef struct dllist {
  struct dllist *flink;
  struct dllist *blink;
  Jval val;
} *Dllist;

extern Dllist new_dllist();
extern free_dllist(Dllist);
extern dll_append(Dllist, Jval);

#define dll_traverse(ptr, list) \
  for (ptr = (list)->flink; ptr != (list); ptr = ptr->flink)




Jvals


typedef union {
  int i;
  char *s;
  void *v;
  double d;
  ....
} Jval;

Jval new_jval_i(int);
Jval new_jval_s(char *);

Other system calls

int chmod(char *path, int mode);
int unlink(char *path);       /* Unlinks a file
int remove(char *path);       /* Unlinks a file, or destroys an  empty directory
int rmdir(char *path);        /* Destroys an empty directory */