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)
committerVolker Lendecke <vl@samba.org>
Mon, 18 May 2009 08:42:22 +0000 (10:42 +0200)
source3/include/proto.h
source3/smbd/files.c

index 81fc1c061f3a85d872b51023bf7e4d9be5a2a450..5b5f9098e025e93b85e271408a5f5cbdbff26bc6 100644 (file)
@@ -6285,6 +6285,10 @@ void file_close_pid(uint16 smbpid, int vuid);
 void file_init(void);
 void file_close_user(int vuid);
 void file_dump_open_table(void);
+struct files_struct *file_walk_table(
+       struct files_struct *(*fn)(struct files_struct *fsp,
+                                  void *private_data),
+       void *private_data);
 files_struct *file_find_fd(int fd);
 files_struct *file_find_dif(struct file_id id, unsigned long gen_id);
 files_struct *file_find_fsp(files_struct *orig_fsp);
index d2ea520146c846a1beedbaee1a264e98aa8da6f6..0e6dd7e457e6c264a2fe7c094c95e80d6b557ffc 100644 (file)
@@ -204,6 +204,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.
 ****************************************************************************/