+#if defined(CONFIG_BLK_DEV_VROOT) || defined(CONFIG_BLK_DEV_VROOT_MODULE)
+
+#include <linux/vroot.h>
+#include <linux/major.h>
+#include <linux/module.h>
+#include <linux/kallsyms.h>
+#include <linux/vserver/debug.h>
+
+static vroot_grb_func *vroot_get_real_bdev = NULL;
+
+static spinlock_t vroot_grb_lock = SPIN_LOCK_UNLOCKED;
+
+int register_vroot_grb(vroot_grb_func *func) {
+ int ret = -EBUSY;
+
+ spin_lock(&vroot_grb_lock);
+ if (!vroot_get_real_bdev) {
+ vroot_get_real_bdev = func;
+ ret = 0;
+ }
+ spin_unlock(&vroot_grb_lock);
+ return ret;
+}
+EXPORT_SYMBOL(register_vroot_grb);
+
+int unregister_vroot_grb(vroot_grb_func *func) {
+ int ret = -EINVAL;
+
+ spin_lock(&vroot_grb_lock);
+ if (vroot_get_real_bdev) {
+ vroot_get_real_bdev = NULL;
+ ret = 0;
+ }
+ spin_unlock(&vroot_grb_lock);
+ return ret;
+}
+EXPORT_SYMBOL(unregister_vroot_grb);
+
+#endif
+
+/*
+ * look up a superblock on which quota ops will be performed
+ * - use the name of a block device to find the superblock thereon
+ */
+static inline struct super_block *quotactl_block(const char __user *special)
+{
+#ifdef CONFIG_BLOCK
+ struct block_device *bdev;
+ struct super_block *sb;
+ char *tmp = getname(special);
+
+ if (IS_ERR(tmp))
+ return ERR_PTR(PTR_ERR(tmp));
+ bdev = lookup_bdev(tmp);
+ putname(tmp);
+ if (IS_ERR(bdev))
+ return ERR_PTR(PTR_ERR(bdev));
+#if defined(CONFIG_BLK_DEV_VROOT) || defined(CONFIG_BLK_DEV_VROOT_MODULE)
+ if (bdev && bdev->bd_inode &&
+ imajor(bdev->bd_inode) == VROOT_MAJOR) {
+ struct block_device *bdnew = (void *)-EINVAL;
+
+ if (vroot_get_real_bdev)
+ bdnew = vroot_get_real_bdev(bdev);
+ else
+ vxdprintk(VXD_CBIT(misc, 0),
+ "vroot_get_real_bdev not set");
+ bdput(bdev);
+ if (IS_ERR(bdnew))
+ return ERR_PTR(PTR_ERR(bdnew));
+ bdev = bdnew;
+ }
+#endif
+ sb = get_super(bdev);
+ bdput(bdev);
+ if (!sb)
+ return ERR_PTR(-ENODEV);
+
+ return sb;
+#else
+ return ERR_PTR(-ENODEV);
+#endif
+}
+