[Kos-cvs] kos/modules/karm nscache.c,1.11,1.12 nscache.h,1.5,1.6
thomas at kos.enix.org
thomas at kos.enix.org
Sun Jan 30 18:25:07 CET 2005
Update of /home/kos/cvs/kos/modules/karm
In directory the-doors:/tmp/cvs-serv9548/modules/karm
Modified Files:
nscache.c nscache.h
Log Message:
2005-01-30 Thomas Petazzoni <thomas at crazy.kos.nx>
* modules/karm/nscache.c: Doxygen documentation + GPL header.
* modules/karm/nscache.h: Doxygen documentation + GPL header.
Index: nscache.c
===================================================================
RCS file: /home/kos/cvs/kos/modules/karm/nscache.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- nscache.c 20 Aug 2003 21:32:32 -0000 1.11
+++ nscache.c 30 Jan 2005 17:25:05 -0000 1.12
@@ -1,3 +1,38 @@
+/*
+ * Copyright (C) 2000-2005
+ * David Decotigny, Julien Munier, Thomas Petazzoni
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+ * USA.
+ *
+ * @(#) $Id$
+ */
+
+/** @file
+ * Global name-space cache implementation
+ *
+ * This file contains functions that allows to maintain the global
+ * name-space cache. The global name-space cache is a partial
+ * representation of the filesystem hierarchy. It allows to ease and
+ * speed up file lookups.
+ *
+ * The global name-space cache is mostly a tree of struct nsnode
+ * elements. Each element may have zero, one or more childs, just like
+ * in any other filesystem hierarchy.
+ */
+
#include <karm/nscache.h>
#include <lib/list/liblist.h>
#include <lib/std/string.h>
@@ -17,6 +52,17 @@
#define NSCACHE_DEBUG(fmt,args...)
#endif
+/**
+ * Tells whether two directories name are equivalent. It compares the
+ * two given strings until it reaches NULL or '/', which are the two
+ * allowed separators for directory names.
+ *
+ * @param dir1 First directory name
+ *
+ * @param dir2 Second directory name
+ *
+ * @result TRUE is directory names are equal, FALSE otherwise
+ */
bool_t dirname_eq(char* dir1, char* dir2)
{
for ( ; *dir1 == *dir2 ; dir1++, dir2++)
@@ -26,15 +72,27 @@
return (EODirname(dir1) && EODirname(dir2));
}
-
+/**
+ * Computes the length of the first directory/file name in the given
+ * path, i.e the length of "sblurp" in "//sblurp///an/example".
+ *
+ * @param str The path from which we want to extract the length of the
+ * first part.
+ *
+ * @param begin_dirname A pointer to the real start of the first part
+ * is returned. The real start is computed after skipping all '/'
+ * before the first part name.
+ *
+ * @result Length of the first part
+ */
size_t dirname_len(const char *str, char ** begin_dirname)
{
char *cptr;
size_t len = 0;
/* Skip any '/////' before dir name */
- for (*begin_dirname = (char *) str ;
- **begin_dirname == '/' ;
+ for (*begin_dirname = (char *) str ;
+ **begin_dirname == '/' ;
(*begin_dirname)++)
continue;
@@ -54,11 +112,12 @@
* This function initializes the nscache, by creating the root node of
* the filesystem hierarchy, with the given informations.
*
- * kres : the kernel resource which is related to the root of the
- * filesystem hierarchy.
- * fs_infos : the mounted filesystem informations
+ * @param kres the kernel resource which is related to the root of the
+ * filesystem hierarchy.
*
- * Returns 0 on success, an error code on failure
+ * @param fs_infos the mounted filesystem informations
+ *
+ * @return Returns ESUCCESS on success, an error code on failure
*/
result_t nscache_init (struct kres *kres, void *fs_infos)
{
@@ -85,7 +144,7 @@
root_nsnode->mountpoint.mounted_root = NULL;
root_nsnode->mounted_root.fs_infos = fs_infos;
root_nsnode->mounted_root.mountpoint = NULL;
-
+
return ESUCCESS;
}
Index: nscache.h
===================================================================
RCS file: /home/kos/cvs/kos/modules/karm/nscache.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- nscache.h 28 Dec 2004 18:44:30 -0000 1.5
+++ nscache.h 30 Jan 2005 17:25:05 -0000 1.6
@@ -1,3 +1,29 @@
+/*
+ * Copyright (C) 2000-2005
+ * David Decotigny, Julien Munier, Thomas Petazzoni
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+ * USA.
+ *
+ * @(#) $Id$
+ */
+
+/** @file
+ * Global name-space cache public definitions
+ */
+
#ifndef __NSNODE_H__
#define __NSNODE_H__
More information about the Kos-cvs
mailing list