Hello,
This patch implement new interface of file_operations.iterator (only
for 3.10.0 kernel), since file_operations.readdir was removed in [1]
2233f31aade393641f0eaed43a71110e629bb900
This will allow build vboxsf module on linux >= 3.10.
[1]
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=2233f31aade393641f0eaed43a71110e629bb900
--
Respectfully
Azat Khuzhin
Index: src/VBox/Additions/linux/sharedfolders/dirops.c
===================================================================
--- src/VBox/Additions/linux/sharedfolders/dirops.c (revision 47533)
+++ src/VBox/Additions/linux/sharedfolders/dirops.c (working copy)
@@ -233,6 +233,7 @@
* b. failure to compute fake inode number
* c. filldir returns an error (see comment on that)
*/
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 10, 0)
static int sf_dir_read (struct file *dir, void *opaque, filldir_t filldir)
{
TRACE();
@@ -286,10 +287,73 @@
BUG();
}
+#else
+
+int sf_dir_iterate (struct file *dir, struct dir_context *ctx)
+{
+ TRACE();
+
+ for (;;)
+ {
+ int err;
+ ino_t fake_ino;
+ loff_t sanity;
+ char d_name[NAME_MAX];
+
+ err = sf_getdent(dir, d_name);
+ switch (err)
+ {
+ case 1:
+ return 0;
+
+ case 0:
+ break;
+
+ case -1:
+ default:
+ /* skip erroneous entry and proceed */
+ LogFunc(("sf_getdent error %d\n", err));
+ ctx->pos += 1;
+ dir->f_pos += 1;
+ continue;
+ }
+
+ /* d_name now contains a valid entry name */
+
+ sanity = ctx->pos + 0xbeef;
+ fake_ino = sanity;
+ if (sanity - fake_ino)
+ {
+ LogRelFunc(("can not compute ino\n"));
+ return -EINVAL;
+ }
+
+ err = dir_emit(ctx, d_name, strlen(d_name),
+ fake_ino, DT_UNKNOWN);
+ if (!err)
+ {
+ LogFunc(("filldir returned error %d\n", err));
+ /* Rely on the fact that filldir returns error
+ only when it runs out of space in opaque */
+ return 0;
+ }
+
+ ctx->pos += 1;
+ dir->f_pos += 1;
+ }
+
+ BUG();
+}
+#endif
+
struct file_operations sf_dir_fops =
{
.open = sf_dir_open,
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 10, 0)
+ .iterate = sf_dir_iterate,
+#else
.readdir = sf_dir_read,
+#endif
.release = sf_dir_release,
.read = generic_read_dir
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37)
_______________________________________________
vbox-dev mailing list
[email protected]
https://www.virtualbox.org/mailman/listinfo/vbox-dev