diff options
| author | bhgv <bhgv.empire@gmail.com> | 2018-03-01 16:54:45 +0200 |
|---|---|---|
| committer | bhgv <bhgv.empire@gmail.com> | 2018-03-01 16:54:45 +0200 |
| commit | b786f20bbab5a59046aa78a2c6c2a11536497202 (patch) | |
| tree | 0851ecdec889eb9b7ba3751cc04d4f0b474e4a9e /liblogfs/path.c | |
inferno-os tree was separated from the inferno-os-android (separated from the Android driver)
Diffstat (limited to 'liblogfs/path.c')
| -rw-r--r-- | liblogfs/path.c | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/liblogfs/path.c b/liblogfs/path.c new file mode 100644 index 0000000..f82e5b5 --- /dev/null +++ b/liblogfs/path.c @@ -0,0 +1,50 @@ +#include "logfsos.h" +#include "logfs.h" +#include "local.h" + +enum { + PATHMOD = 127 +}; + +static int +compare(void *a, void *b) +{ + Path *f = a; + ulong path = (ulong)b; /* sic */ + return f->path == path; +} + +static int +allocsize(void *key) +{ + USED(key); + return sizeof(Path); +} + +char * +logfspathmapnew(PathMap **pathmapp) +{ + return logfsmapnew(PATHMOD, logfshashulong, compare, allocsize, nil, pathmapp); +} + +char * +logfspathmapnewentry(PathMap *m, ulong path, Entry *e, Path **pathmapp) +{ + char *errmsg; + errmsg = logfsmapnewentry(m, (void*)path, pathmapp); + if(errmsg) + return errmsg; + if(*pathmapp == nil) + return nil; + (*pathmapp)->path = path; + (*pathmapp)->entry = e; + return nil; +} + +Entry * +logfspathmapfinde(PathMap *m, ulong path) +{ + Path *p; + p = logfspathmapfindentry(m, path); + return p ? p->entry : nil; +} |
