+static void update_special(struct dentry *special)
+{
+ special->d_inode->i_uid = listuid;
+ special->d_inode->i_gid = listgid;
+ special->d_inode->i_mode = S_IFREG | listmode;
+}
+
+static void update_dev(struct dentry *dev)
+{
+ dev->d_inode->i_uid = devuid;
+ dev->d_inode->i_gid = devgid;
+ dev->d_inode->i_mode = S_IFREG | devmode;
+}
+
+static void update_bus(struct dentry *bus)
+{
+ struct dentry *dev = NULL;
+
+ bus->d_inode->i_uid = busuid;
+ bus->d_inode->i_gid = busgid;
+ bus->d_inode->i_mode = S_IFDIR | busmode;
+
+ mutex_lock(&bus->d_inode->i_mutex);
+
+ list_for_each_entry(dev, &bus->d_subdirs, d_u.d_child)
+ if (dev->d_inode)
+ update_dev(dev);
+
+ mutex_unlock(&bus->d_inode->i_mutex);
+}
+
+static void update_sb(struct super_block *sb)
+{
+ struct dentry *root = sb->s_root;
+ struct dentry *bus = NULL;
+
+ if (!root)
+ return;
+
+ mutex_lock_nested(&root->d_inode->i_mutex, I_MUTEX_PARENT);
+
+ list_for_each_entry(bus, &root->d_subdirs, d_u.d_child) {
+ if (bus->d_inode) {
+ switch (S_IFMT & bus->d_inode->i_mode) {
+ case S_IFDIR:
+ update_bus(bus);
+ break;
+ case S_IFREG:
+ update_special(bus);
+ break;
+ default:
+ warn("Unknown node %s mode %x found on remount!\n",bus->d_name.name,bus->d_inode->i_mode);
+ break;
+ }
+ }
+ }
+
+ mutex_unlock(&root->d_inode->i_mutex);
+}
+
+static int remount(struct super_block *sb, int *flags, char *data)
+{
+ /* If this is not a real mount,
+ * i.e. it's a simple_pin_fs from create_special_files,
+ * then ignore it.
+ */
+ if (ignore_mount)
+ return 0;
+
+ if (parse_options(sb, data)) {
+ warn("usbfs: mount parameter error:");
+ return -EINVAL;
+ }
+
+ if (usbfs_mount && usbfs_mount->mnt_sb)
+ update_sb(usbfs_mount->mnt_sb);
+
+ return 0;
+}
+