Add "file_walk_table" to do stuff with all open files
authorVolker Lendecke <vl@samba.org>
Mon, 18 May 2009 07:46:05 +0000 (09:46 +0200)
committerMichael Adam <obnox@samba.org>
Mon, 18 May 2009 09:56:19 +0000 (11:56 +0200)
Signed-off-by: Michael Adam <obnox@samba.org>
source/smbd/files.c

index 8ed8eaf4f38aa45f669354d0f1da21a2e949be18..f643892835d9c84bf3fc8bf78e601d9b70ad6dfe 100644 (file)
@@ -225,6 +225,28 @@ void file_close_user(int vuid)
        }
 }
 
+/*
+ * Walk the files table until "fn" returns non-NULL
+ */
+
+struct files_struct *file_walk_table(
+       struct files_struct *(*fn)(struct files_struct *fsp,
+                                  void *private_data),
+       void *private_data)
+{
+       struct files_struct *fsp, *next;
+
+       for (fsp = Files; fsp; fsp = next) {
+               struct files_struct *ret;
+               next = fsp->next;
+               ret = fn(fsp, private_data);
+               if (ret != NULL) {
+                       return ret;
+               }
+       }
+       return NULL;
+}
+
 /****************************************************************************
  Debug to enumerate all open files in the smbd.
 ****************************************************************************/