/* This function is called from hpux_utssys(); HP-UX implements * ustat() as an option to utssys(). * * Now, struct ustat on HP-UX is exactly the same as on Linux, except * that it contains one addition field on the end, int32_t f_blksize. * So, we could have written this function to just call the Linux * sys_ustat(), (defined in linux/fs/super.c), and then just * added this additional field to the user's structure. But I figure * if we're gonna be digging through filesystem structures to get * this, we might as well just do the whole enchilada all in one go. * * So, most of this function is almost identical to sys_ustat(). * I have placed comments at the few lines changed or added, to * aid in porting forward if and when sys_ustat() is changed from * its form in kernel 2.2.5. */ static int hpux_ustat(dev_t dev, struct hpux_ustat __user *ubuf) { struct super_block *s; struct hpux_ustat tmp; /* Changed to hpux_ustat */ struct kstatfs sbuf; int err = -EINVAL; s = user_get_super(dev); if (s == NULL) goto out; err = vfs_statfs(s, &sbuf); drop_super(s); if (err) goto out; memset(&tmp,0,sizeof(tmp)); tmp.f_tfree = (int32_t)sbuf.f_bfree; tmp.f_tinode = (u_int32_t)sbuf.f_ffree; tmp.f_blksize = (u_int32_t)sbuf.f_bsize; /* Added this line */ err = copy_to_user(ubuf, &tmp, sizeof(tmp)) ? -EFAULT : 0; out: return err; }
int vfs_ustat(dev_t dev, struct kstatfs *sbuf) { struct super_block *s = user_get_super(dev); int err; if (!s) return -EINVAL; err = statfs_by_dentry(s->s_root, sbuf); drop_super(s); return err; }
/* * This is the system call interface. This communicates with * the user-level programs. Currently this only supports diskquota * calls. Maybe we need to add the process quotas etc. in the future, * but we probably should use rlimits for that. */ SYSCALL_DEFINE4(quotactl, unsigned int, cmd, const char __user *, special, qid_t, id, void __user *, addr) { uint cmds, type; struct super_block *sb = NULL; struct path path, *pathp = NULL; int ret; cmds = cmd >> SUBCMDSHIFT; type = cmd & SUBCMDMASK; /* * As a special case Q_SYNC can be called without a specific device. * It will iterate all superblocks that have quota enabled and call * the sync action on each of them. */ if (!special) { if (cmds == Q_SYNC) return quota_sync_all(type); return -ENODEV; } /* * Path for quotaon has to be resolved before grabbing superblock * because that gets s_umount sem which is also possibly needed by path * resolution (think about autofs) and thus deadlocks could arise. */ if (cmds == Q_QUOTAON) { ret = user_path_at(AT_FDCWD, addr, LOOKUP_FOLLOW|LOOKUP_AUTOMOUNT, &path); if (ret) pathp = ERR_PTR(ret); else pathp = &path; } sb = quotactl_block(special, cmds); if (IS_ERR(sb)) { ret = PTR_ERR(sb); goto out; } ret = do_quotactl(sb, type, cmds, id, addr, pathp); drop_super(sb); out: if (pathp && !IS_ERR(pathp)) path_put(pathp); return ret; }
static struct super_block *procinfo_prologue( kdev_t dev ) { struct super_block *result; /* get super-block by device */ result = get_super( dev ); if( result != NULL ) { if( !reiserfs_is_super( result ) ) { printk( KERN_DEBUG "reiserfs: procfs-52: " "non-reiserfs super found\n" ); drop_super( result ); result = NULL; } } else printk( KERN_DEBUG "reiserfs: procfs-74: " "race between procinfo and umount\n" ); return result; }
SYSCALL_DEFINE2(ustat, unsigned, dev, struct ustat __user *, ubuf) { struct super_block *s; struct ustat tmp; struct kstatfs sbuf; int err; s = user_get_super(new_decode_dev(dev)); if (!s) return -EINVAL; err = statfs_by_dentry(s->s_root, &sbuf); drop_super(s); if (err) return err; memset(&tmp,0,sizeof(struct ustat)); tmp.f_tfree = sbuf.f_bfree; tmp.f_tinode = sbuf.f_ffree; return copy_to_user(ubuf, &tmp, sizeof(struct ustat)) ? -EFAULT : 0; }
/* * This is a copy of sys_ustat, just dealing with a structure layout. * Given how simple this syscall is that apporach is more maintainable * than the various conversion hacks. */ asmlinkage long compat_sys_ustat(unsigned dev, struct compat_ustat __user *u) { struct super_block *sb; struct compat_ustat tmp; struct kstatfs sbuf; int err; sb = user_get_super(new_decode_dev(dev)); if (!sb) return -EINVAL; err = statfs_by_dentry(sb->s_root, &sbuf); drop_super(sb); if (err) return err; memset(&tmp, 0, sizeof(struct compat_ustat)); tmp.f_tfree = sbuf.f_bfree; tmp.f_tinode = sbuf.f_ffree; if (copy_to_user(u, &tmp, sizeof(struct compat_ustat))) return -EFAULT; return 0; }
/* * This is the system call interface. This communicates with * the user-level programs. Currently this only supports diskquota * calls. Maybe we need to add the process quotas etc. in the future, * but we probably should use rlimits for that. */ asmlinkage long sys_quotactl(unsigned int cmd, const char *special, qid_t id, caddr_t addr) { uint cmds, type; struct super_block *sb = NULL; int ret = -EINVAL; lock_kernel(); cmds = cmd >> SUBCMDSHIFT; type = cmd & SUBCMDMASK; #ifdef CONFIG_QIFACE_COMPAT if (cmds != Q_V1_GETSTATS && cmds != Q_V2_GETSTATS && IS_ERR(sb = resolve_dev(special))) { ret = PTR_ERR(sb); sb = NULL; goto out; } if (!NEW_COMMAND(cmds) && !XQM_COMMAND(cmds)) { if ((ret = check_compat_quotactl_valid(sb, type, cmds, id)) < 0) goto out; ret = do_compat_quotactl(sb, type, cmds, id, addr); goto out; } #else if (IS_ERR(sb = resolve_dev(special))) { ret = PTR_ERR(sb); sb = NULL; goto out; } #endif if ((ret = check_quotactl_valid(sb, type, cmds, id)) < 0) goto out; ret = do_quotactl(sb, type, cmds, id, addr); out: if (sb) drop_super(sb); unlock_kernel(); return ret; }
int procinfo_epilogue( struct super_block *super ) { drop_super( super ); return 0; }