summaryrefslogtreecommitdiff
path: root/src/VBox/Additions/linux/sharedfolders
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@baserock.org>2014-03-26 19:21:20 +0000
committer <>2014-05-08 15:03:54 +0000
commitfb123f93f9f5ce42c8e5785d2f8e0edaf951740e (patch)
treec2103d76aec5f1f10892cd1d3a38e24f665ae5db /src/VBox/Additions/linux/sharedfolders
parent58ed4748338f9466599adfc8a9171280ed99e23f (diff)
downloadVirtualBox-master.tar.gz
Imported from /home/lorry/working-area/delta_VirtualBox/VirtualBox-4.3.10.tar.bz2.HEADVirtualBox-4.3.10master
Diffstat (limited to 'src/VBox/Additions/linux/sharedfolders')
-rw-r--r--src/VBox/Additions/linux/sharedfolders/dirops.c38
-rw-r--r--src/VBox/Additions/linux/sharedfolders/mount.vboxsf.c2
-rw-r--r--src/VBox/Additions/linux/sharedfolders/regops.c2
-rw-r--r--src/VBox/Additions/linux/sharedfolders/utils.c6
-rw-r--r--src/VBox/Additions/linux/sharedfolders/vfsmod.c78
5 files changed, 82 insertions, 44 deletions
diff --git a/src/VBox/Additions/linux/sharedfolders/dirops.c b/src/VBox/Additions/linux/sharedfolders/dirops.c
index f7f558a0..dcaddab1 100644
--- a/src/VBox/Additions/linux/sharedfolders/dirops.c
+++ b/src/VBox/Additions/linux/sharedfolders/dirops.c
@@ -233,7 +233,11 @@ static int sf_getdent(struct file *dir, char d_name[NAME_MAX])
* b. failure to compute fake inode number
* c. filldir returns an error (see comment on that)
*/
-static int sf_dir_read (struct file *dir, void *opaque, filldir_t filldir)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)
+static int sf_dir_iterate(struct file *dir, struct dir_context *ctx)
+#else
+static int sf_dir_read(struct file *dir, void *opaque, filldir_t filldir)
+#endif
{
TRACE();
for (;;)
@@ -257,12 +261,19 @@ static int sf_dir_read (struct file *dir, void *opaque, filldir_t filldir)
/* skip erroneous entry and proceed */
LogFunc(("sf_getdent error %d\n", err));
dir->f_pos += 1;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)
+ ctx->pos += 1;
+#endif
continue;
}
/* d_name now contains a valid entry name */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)
+ sanity = ctx->pos + 0xbeef;
+#else
sanity = dir->f_pos + 0xbeef;
+#endif
fake_ino = sanity;
if (sanity - fake_ino)
{
@@ -270,8 +281,14 @@ static int sf_dir_read (struct file *dir, void *opaque, filldir_t filldir)
return -EINVAL;
}
- err = filldir(opaque, d_name, strlen(d_name),
- dir->f_pos, fake_ino, DT_UNKNOWN);
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)
+ if (!dir_emit(ctx, d_name, strlen(d_name), fake_ino, DT_UNKNOWN))
+ {
+ LogFunc(("dir_emit failed\n"));
+ return 0;
+ }
+#else
+ err = filldir(opaque, d_name, strlen(d_name), dir->f_pos, fake_ino, DT_UNKNOWN);
if (err)
{
LogFunc(("filldir returned error %d\n", err));
@@ -279,8 +296,12 @@ static int sf_dir_read (struct file *dir, void *opaque, filldir_t filldir)
only when it runs out of space in opaque */
return 0;
}
+#endif
dir->f_pos += 1;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)
+ ctx->pos += 1;
+#endif
}
BUG();
@@ -289,7 +310,11 @@ static int sf_dir_read (struct file *dir, void *opaque, filldir_t filldir)
struct file_operations sf_dir_fops =
{
.open = sf_dir_open,
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 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)
@@ -451,13 +476,6 @@ static int sf_instantiate(struct inode *parent, struct dentry *dentry,
sf_init_inode(sf_g, inode, info);
sf_new_i->path = path;
SET_INODE_INFO(inode, sf_new_i);
-
- dentry->d_time = jiffies;
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 38)
- d_set_d_op(dentry, &sf_dentry_ops);
-#else
- dentry->d_op = &sf_dentry_ops;
-#endif
sf_new_i->force_restat = 1;
sf_new_i->force_reread = 0;
diff --git a/src/VBox/Additions/linux/sharedfolders/mount.vboxsf.c b/src/VBox/Additions/linux/sharedfolders/mount.vboxsf.c
index 2bce2849..fd3097a8 100644
--- a/src/VBox/Additions/linux/sharedfolders/mount.vboxsf.c
+++ b/src/VBox/Additions/linux/sharedfolders/mount.vboxsf.c
@@ -7,7 +7,7 @@
*/
/*
- * Copyright (C) 2006-2010 Oracle Corporation
+ * Copyright (C) 2006-2012 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
diff --git a/src/VBox/Additions/linux/sharedfolders/regops.c b/src/VBox/Additions/linux/sharedfolders/regops.c
index 9cce1739..a3bbd696 100644
--- a/src/VBox/Additions/linux/sharedfolders/regops.c
+++ b/src/VBox/Additions/linux/sharedfolders/regops.c
@@ -4,7 +4,7 @@
*/
/*
- * Copyright (C) 2006-2010 Oracle Corporation
+ * Copyright (C) 2006-2012 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
diff --git a/src/VBox/Additions/linux/sharedfolders/utils.c b/src/VBox/Additions/linux/sharedfolders/utils.c
index aa9c3965..674af7a5 100644
--- a/src/VBox/Additions/linux/sharedfolders/utils.c
+++ b/src/VBox/Additions/linux/sharedfolders/utils.c
@@ -144,8 +144,14 @@ void sf_init_inode(struct sf_glob_info *sf_g, struct inode *inode,
#endif
}
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 5, 0)
+ inode->i_uid = make_kuid(current_user_ns(), sf_g->uid);
+ inode->i_gid = make_kgid(current_user_ns(), sf_g->gid);
+#else
inode->i_uid = sf_g->uid;
inode->i_gid = sf_g->gid;
+#endif
+
inode->i_size = info->cbObject;
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 19) && !defined(KERNEL_FC6)
inode->i_blksize = 4096;
diff --git a/src/VBox/Additions/linux/sharedfolders/vfsmod.c b/src/VBox/Additions/linux/sharedfolders/vfsmod.c
index 4a7e9638..b465a29d 100644
--- a/src/VBox/Additions/linux/sharedfolders/vfsmod.c
+++ b/src/VBox/Additions/linux/sharedfolders/vfsmod.c
@@ -10,7 +10,7 @@
*/
/*
- * Copyright (C) 2006-2010 Oracle Corporation
+ * Copyright (C) 2006-2012 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
@@ -106,28 +106,43 @@ static int sf_glob_alloc(struct vbsf_mount_info_new *info, struct sf_glob_info *
str_name->u16Size = name_len + 1;
memcpy(str_name->String.utf8, info->name, name_len + 1);
-/* Check if NLS charset is valid and not points to UTF8 table */
-#define VFSMOD_HAS_NLS(_name) \
- (_name[0] && strcmp(_name, "utf8"))
- if (VFSMOD_HAS_NLS(info->nls_name))
+#define _IS_UTF8(_str) \
+ (strcmp(_str, "utf8") == 0)
+#define _IS_EMPTY(_str) \
+ (strcmp(_str, "") == 0)
+
+ /* Check if NLS charset is valid and not points to UTF8 table */
+ if (info->nls_name[0])
{
- sf_g->nls = load_nls(info->nls_name);
- if (!sf_g->nls)
+ if (_IS_UTF8(info->nls_name))
+ sf_g->nls = NULL;
+ else
{
- err = -EINVAL;
- LogFunc(("failed to load nls %s\n", info->nls_name));
- goto fail1;
+ sf_g->nls = load_nls(info->nls_name);
+ if (!sf_g->nls)
+ {
+ err = -EINVAL;
+ LogFunc(("failed to load nls %s\n", info->nls_name));
+ goto fail1;
+ }
}
}
else
{
- /* If no NLS charset specified, try to load the default one */
- if (VFSMOD_HAS_NLS(CONFIG_NLS_DEFAULT))
+#ifdef CONFIG_NLS_DEFAULT
+ /* If no NLS charset specified, try to load the default
+ * one if it's not points to UTF8. */
+ if (!_IS_UTF8(CONFIG_NLS_DEFAULT) && !_IS_EMPTY(CONFIG_NLS_DEFAULT))
sf_g->nls = load_nls_default();
else
sf_g->nls = NULL;
+#else
+ sf_g->nls = NULL;
+#endif
+
+#undef _IS_UTF8
+#undef _IS_EMPTY
}
-#undef VFSMOD_HAS_NLS
rc = vboxCallMapFolder(&client_handle, str_name, &sf_g->map);
kfree(str_name);
@@ -440,41 +455,40 @@ static int sf_remount_fs(struct super_block *sb, int *flags, char *data)
{
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4, 23)
struct sf_glob_info *sf_g;
- struct vbsf_mount_info_new *info;
struct sf_inode_info *sf_i;
struct inode *iroot;
SHFLFSOBJINFO fsinfo;
int err;
- printk(KERN_DEBUG "ENTER: sf_remount_fs\n");
sf_g = GET_GLOB_INFO(sb);
BUG_ON(!sf_g);
- BUG_ON(data[0] != 0);
- info = (struct vbsf_mount_info_new *)data;
- BUG_ON( info->signature[0] != VBSF_MOUNT_SIGNATURE_BYTE_0
- || info->signature[1] != VBSF_MOUNT_SIGNATURE_BYTE_1
- || info->signature[2] != VBSF_MOUNT_SIGNATURE_BYTE_2);
-
- sf_g->uid = info->uid;
- sf_g->gid = info->gid;
- sf_g->ttl = info->ttl;
- sf_g->dmode = info->dmode;
- sf_g->fmode = info->fmode;
- sf_g->dmask = info->dmask;
- sf_g->fmask = info->fmask;
+ if (data && data[0] != 0)
+ {
+ struct vbsf_mount_info_new *info =
+ (struct vbsf_mount_info_new *)data;
+ if ( info->signature[0] == VBSF_MOUNT_SIGNATURE_BYTE_0
+ && info->signature[1] == VBSF_MOUNT_SIGNATURE_BYTE_1
+ && info->signature[2] == VBSF_MOUNT_SIGNATURE_BYTE_2)
+ {
+ sf_g->uid = info->uid;
+ sf_g->gid = info->gid;
+ sf_g->ttl = info->ttl;
+ sf_g->dmode = info->dmode;
+ sf_g->fmode = info->fmode;
+ sf_g->dmask = info->dmask;
+ sf_g->fmask = info->fmask;
+ }
+ }
iroot = ilookup(sb, 0);
if (!iroot)
- {
- printk(KERN_DEBUG "can't find root inode\n");
return -ENOSYS;
- }
+
sf_i = GET_INODE_INFO(iroot);
err = sf_stat(__func__, sf_g, sf_i->path, &fsinfo, 0);
BUG_ON(err != 0);
sf_init_inode(sf_g, iroot, &fsinfo);
/*unlock_new_inode(iroot);*/
- printk(KERN_DEBUG "LEAVE: sf_remount_fs\n");
return 0;
#else
return -ENOSYS;