/fs/hostfs/

ss='main'>index : litmus-rt.git
The LITMUS^RT kernel.Bjoern Brandenburg
aboutsummaryrefslogblamecommitdiffstats
path: root/fs/ioctl.c
blob: 5612880fcbe7d7436f3579c7c1add7360170e407 (plain) (tree)
1
2
3
4
5
6
7
8
9





                                            


                           
                             



                           
                          

                              
                         
 

                       


                                                                         

                                                     


                                                   

                                                                         
                                                                         



                                         

                                                          










                                                                   
                                       
                              

                                                                       






                                












                                                         
                                                   


                                





















































































































































                                                                                   

                   


                                                                     

                                                                      









                                                                                



                                                                          
   



                                                                         





                                            
                                                  





                                                                  
                                                                


                               















                                                                            














                                                                                



                                                                           
                                               






                                                                                
                                                                             
                                                    
                                      
                        


























                                                                                















                                                                               


                                                                               
                           



                                                                        



                               





                                                                      























                                                                            

                                    

                            






























                                                                             


                                                          
                                                           


                                          
                    
                                             

                                                                     


                                                  

         
                                         

 













                                                             
                                 



                                       
                                   















                                                             
                                                     
                                                            
                                                                 
                    

                                        
                                     

 




































                                                                                



                                                                     
                                                                              

                                                                

                                                                      
 

                                             

                      


                                         
 


                                         
 
                     
                                                  


                      
                                                       












                                                                              








                                             









                                                                   



                                                                  
                                                          
                      



                     
                                                                               
 
                          










                                                    
                                                 




                                      
/*
 *  linux/fs/ioctl.c
 *
 *  Copyright (C) 1991, 1992  Linus Torvalds
 */

#include <linux/syscalls.h>
#include <linux/mm.h>
#include <linux/smp_lock.h>
#include <linux/capability.h>
#include <linux/file.h>
#include <linux/fs.h>
#include <linux/security.h>
#include <linux/module.h>
#include <linux/uaccess.h>
#include <linux/writeback.h>
#include <linux/buffer_head.h>
#include <linux/falloc.h>

#include <asm/ioctls.h>

/* So that the fiemap access checks can't overflow on 32 bit machines. */
#define FIEMAP_MAX_EXTENTS	(UINT_MAX / sizeof(struct fiemap_extent))

/**
 * vfs_ioctl - call filesystem specific ioctl methods
 * @filp:	open file to invoke ioctl method on
 * @cmd:	ioctl command to execute
 * @arg:	command-specific argument for ioctl
 *
 * Invokes filesystem specific ->unlocked_ioctl, if one exists; otherwise
 * invokes filesystem specific ->ioctl method.  If neither method exists,
 * returns -ENOTTY.
 *
 * Returns 0 on success, -errno on error.
 */
static long vfs_ioctl(struct file *filp, unsigned int cmd,
		      unsigned long arg)
{
	int error = -ENOTTY;

	if (!filp->f_op)
		goto out;

	if (filp->f_op->unlocked_ioctl) {
		error = filp->f_op->unlocked_ioctl(filp, cmd, arg);
		if (error == -ENOIOCTLCMD)
			error = -EINVAL;
		goto out;
	} else if (filp->f_op->ioctl) {
		lock_kernel();
		error = filp->f_op->ioctl(filp->f_path.dentry->d_inode,
					  filp, cmd, arg);
		unlock_kernel();
	}

 out:
	return error;
}

static int ioctl_fibmap(struct file *filp, int __user *p)
{
	struct address_space *mapping = filp->f_mapping;
	int res, block;

	/* do we support this mess? */
	if (!mapping->a_ops->bmap)
		return -EINVAL;
	if (!capable(CAP_SYS_RAWIO))
		return -EPERM;
	res = get_user(block, p);
	if (res)
		return res;
	res = mapping->a_ops->bmap(mapping, block);
	return put_user(res, p);