+static unsigned yaffs_gc_control_callback(yaffs_Device *dev)
+{
+ return yaffs_gc_control;
+}
+
+static void yaffs_GrossLock(yaffs_Device *dev)
+{
+ T(LOCK_TRACE && YAFFS_TRACE_OS, ("yaffs locking %p\n", current));
+ down(&(yaffs_DeviceToContext(dev)->grossLock));
+ T(LOCK_TRACE && YAFFS_TRACE_OS, ("yaffs locked %p\n", current));
+}
+
+static void yaffs_GrossUnlock(yaffs_Device *dev)
+{
+ T(LOCK_TRACE && YAFFS_TRACE_OS, ("yaffs unlocking %p\n", current));
+ up(&(yaffs_DeviceToContext(dev)->grossLock));
+}
+
+
+/*-----------------------------------------------------------------*/
+/* Directory search context allows us to unlock access to yaffs during
+ * filldir without causing problems with the directory being modified.
+ * This is similar to the tried and tested mechanism used in yaffs direct.
+ *
+ * A search context iterates along a doubly linked list of siblings in the
+ * directory. If the iterating object is deleted then this would corrupt
+ * the list iteration, likely causing a crash. The search context avoids
+ * this by using the removeObjectCallback to move the search context to the
+ * next object before the object is deleted.
+ *
+ * Many readdirs (and thus seach conexts) may be alive simulateously so
+ * each yaffs_Device has a list of these.
+ *
+ * A seach context lives for the duration of a readdir.
+ *
+ * All these functions must be called while yaffs is locked.
+ */
+
+struct yaffs_SearchContext {
+ yaffs_Device *dev;
+ yaffs_Object *dirObj;
+ yaffs_Object *nextReturn;
+ struct ylist_head others;
+};
+
+/*
+ * yaffs_NewSearch() creates a new search context, initialises it and
+ * adds it to the device's search context list.
+ *
+ * Called at start of readdir.
+ */
+static struct yaffs_SearchContext * yaffs_NewSearch(yaffs_Object *dir)