linux/fs/jfs/ioctl.c
<<
ion 2.6/spa > 2.6/form> 2.6a ion 2. href="../linux+v3"v21/fs/jfs/ioctl.c">ion 2.6img src="../.static/gfx/right.png" alt=">>">io6/spa > io6spa class="lxr_search">ion ion 2.6input typionhidden" namionnavtarget" /option">ion 2.6input typiontext" namionsearch" idonsearch">ion 2.6butt13Search 2.6/form> 6/spa > io6spa class="lxr_prefs"> 2.6a href="+prefs?return=fs/jfs/ioctl.c"ion 2. onclick="return ajax_prefs();">ion 2.Prefs 2.6/a>io6/spa > n 2. .6/div> n 2. .6form ac ="ajax+*" method="post" onsubmit="return false;">io6input typionhidden" namionajax_lookup" idonajax_lookup" /option">in 2. .6/form> in 2. .6div class="headingbott1m">
n 2.
n 2. 2. .6div idonsearch_results" class="search_results" 2> n 2. .6/div> 6div idoncontent"> 6div idonfile_contents">
. .16/a>6spa  class="comment">/*6/spa >
. .26/a>6spa  class="comment"> * linux/fs/jfs/ioctl.c6/spa >
. .36/a>6spa  class="comment"> *6/spa >
. .46/a>6spa  class="comment"> * Copyright (C) 2006 Herbert Poetzl6/spa >
. .56/a>6spa  class="comment"> * adapted from Remy Card's ext2/ioctl.c6/spa >
. .66/a>6spa  class="comment"> */6/spa >
. .76/a>i. .86/a>#include <linux/fs.h6/a>>i. .96/a>#include <linux/ctypi.h6/a>>i. valua>#include <linux/capability.h6/a>>i. 11lua>#include <linux/mount.h6/a>>i. 12lua>#include <linux/timi.h6/a>>i. 13lua>#include <linux/sched.h6/a>>i. 14lua>#include <asm/current.h6/a>>i. 15lua>#include <asm/uaccess.h6/a>>i. 166/a>i. 17lua>#include "jfs_incori.h6/a>"i. 18lua>#include "jfs_dinodi.h6/a>"i. 19lua>#include "jfs_inodi.h6/a>"i. 206/a>i. 216/a>i. 22lua>static struct {i. 23lua>        long.6a href="+codi=jfs_flag" class="sref">jfs_flaglua>;i. 24lua>        long.6a href="+codi=ext2_flag" class="sref">ext2_flaglua>;i. 25lua>}.6a href="+codi=jfs_map" class="sref">jfs_maplua>[] = {i. 26lua>        {6a href="+codi=JFS_NOATIME_FL" class="sref">JFS_NOATIME_FLlua>,        6a href="+codi=FS_NOATIME_FL" class="sref">FS_NOATIME_FLlua>},i. 27lua>        {6a href="+codi=JFS_DIRSYNC_FL" class="sref">JFS_DIRSYNC_FLlua>,        6a href="+codi=FS_DIRSYNC_FL" class="sref">FS_DIRSYNC_FLlua>},i. 28lua>        {6a href="+codi=JFS_SYNC_FL" class="sref">JFS_SYNC_FLlua>,           6a href="+codi=FS_SYNC_FL" class="sref">FS_SYNC_FLlua>},i. 29lua>        {6a href="+codi=JFS_SECRM_FL" class="sref">JFS_SECRM_FLlua>,          6a href="+codi=FS_SECRM_FL" class="sref">FS_SECRM_FLlua>},i. 30lua>        {6a href="+codi=JFS_UNRM_FL" class="sref">JFS_UNRM_FLlua>,           6a href="+codi=FS_UNRM_FL" class="sref">FS_UNRM_FLlua>},i. 31lua>        {6a href="+codi=JFS_APPEND_FL" class="sref">JFS_APPEND_FLlua>,         6a href="+codi=FS_APPEND_FL" class="sref">FS_APPEND_FLlua>},i. 32lua>        {6a href="+codi=JFS_IMMUTABLE_FL" class="sref">JFS_IMMUTABLE_FLlua>,      6a href="+codi=FS_IMMUTABLE_FL" class="sref">FS_IMMUTABLE_FLlua>},i. 33lua>        {0, 0},i. 34lua>};i. 356/a>i. 36lua>static long.6a href="+codi=jfs_map_ext2" class="sref">jfs_map_ext2lua>(unsigned long.6a href="+codi=flags" class="sref">flagslua>, int.6a href="+codi=from" class="sref">fromlua>)i. 37lua>{i. 38lua>        int.6a href="+codi=index" class="sref">indexlua>=0;i. 39lua>        long.6a href="+codi=mapped" class="sref">mappedlua>=0;i. 406/a>i. 41lua>        while (6a href="+codi=jfs_map" class="sref">jfs_maplua>[6a href="+codi=index" class="sref">indexlua>].6a href="+codi=jfs_flag" class="sref">jfs_flaglua>) {i. 42lua>                if (6a href="+codi=from" class="sref">fromlua>) {i. 43lua>                        if (6a href="+codi=jfs_map" class="sref">jfs_maplua>[6a href="+codi=index" class="sref">indexlua>].6a href="+codi=ext2_flag" class="sref">ext2_flaglua> &.6a href="+codi=flags" class="sref">flagslua>)i. 44lua>                                6a href="+codi=mapped" class="sref">mappedlua> |=.6a href="+codi=jfs_map" class="sref">jfs_maplua>[6a href="+codi=index" class="sref">indexlua>].6a href="+codi=jfs_flag" class="sref">jfs_flaglua>;i. 45lua>                } else {i. 46lua>                        if (6a href="+codi=jfs_map" class="sref">jfs_maplua>[6a href="+codi=index" class="sref">indexlua>].6a href="+codi=jfs_flag" class="sref">jfs_flaglua> &.6a href="+codi=flags" class="sref">flagslua>)i. 47lua>                                6a href="+codi=mapped" class="sref">mappedlua> |=.6a href="+codi=jfs_map" class="sref">jfs_maplua>[6a href="+codi=index" class="sref">indexlua>].6a href="+codi=ext2_flag" class="sref">ext2_flaglua>;i. 48lua>                }i. 49lua>                6a href="+codi=index" class="sref">indexlua>++;i. 50lua>        }i. 51lua>        return 6a href="+codi=mapped" class="sref">mappedlua>;i. 52lua>}i. 536/a>i. 546/a>i. 55lua>long.6a href="+codi=jfs_ioctl" class="sref">jfs_ioctllua>(struct 6a href="+codi=file" class="sref">filelua> *6a href="+codi=filp" class="sref">filplua>, unsigned int.6a href="+codi=cmd" class="sref">cmdlua>, unsigned long.6a href="+codi=arg" class="sref">arglua>)i. 56lua>{i. 57lua>        struct 6a href="+codi=inodi" class="sref">inodilua> *6a href="+codi=inodi" class="sref">inodilua> =.6a href="+codi=filp" class="sref">filplua>->6a href="+codi=f_dentry" class="sref">f_dentrylua>->6a href="+codi=d_inodi" class="sref">d_inodilua>;i. 58lua>        struct 6a href="+codi=jfs_inodi_info" class="sref">jfs_inodi_infolua> *6a href="+codi=jfs_inodi" class="sref">jfs_inodilua> =.6a href="+codi=JFS_IP" class="sref">JFS_IPlua>(6a href="+codi=inodi" class="sref">inodilua>);i. 59lua>        unsigned int.6a href="+codi=flags" class="sref">flagslua>;i. 606/a>i. 61lua>        switch (6a href="+codi=cmd" class="sref">cmdlua>) {i. 62lua>        case 6a href="+codi=JFS_IOC_GETFLAGS" class="sref">JFS_IOC_GETFLAGSlua>:i. 63lua>                6a href="+codi=jfs_get_inodi_flags" class="sref">jfs_get_inodi_flagslua>(6a href="+codi=jfs_inodi" class="sref">jfs_inodilua>);i. 64lua>                6a href="+codi=flags" class="sref">flagslua> =.6a href="+codi=jfs_inodi" class="sref">jfs_inodilua>->6a href="+codi=modi2" class="sref">modi2lua> &.6a href="+codi=JFS_FL_USER_VISIBLE" class="sref">JFS_FL_USER_VISIBLElua>;i. 65lua>                6a href="+codi=flags" class="sref">flagslua> =.6a href="+codi=jfs_map_ext2" class="sref">jfs_map_ext2lua>(6a href="+codi=flags" class="sref">flagslua>, 0);i. 66lua>                return 6a href="+codi=put_user" class="sref">put_userlua>(6a href="+codi=flags" class="sref">flagslua>, (int.6a href="+codi=__user" class="sref">__userlua> *).6a href="+codi=arg" class="sref">arglua>);i. 67lua>        case 6a href="+codi=JFS_IOC_SETFLAGS" class="sref">JFS_IOC_SETFLAGSlua>: {i. 68lua>                unsigned int.6a href="+codi=oldflags" class="sref">oldflagslua>;i. 69lua>                int.6a href="+codi=err" class="sref">errlua>;i. 706/a>i. 71lua>                6a href="+codi=err" class="sref">errlua> =.6a href="+codi=mnt_want_writi_file" class="sref">mnt_want_writi_filelua>(6a href="+codi=filp" class="sref">filplua>);i. 72lua>                if (6a href="+codi=err" class="sref">errlua>)i. 73lua>                        return 6a href="+codi=err" class="sref">errlua>;i. 746/a>i. 75lua>                if (!6a href="+codi=inodi_owner_or_capable" class="sref">inodi_owner_or_capablelua>(6a href="+codi=inodi" class="sref">inodilua>)) {i. 76lua>                        6a href="+codi=err" class="sref">errlua> =.-6a href="+codi=EACCES" class="sref">EACCESlua>;i. 77lua>                        goto 6a href="+codi=setflags_out" class="sref">setflags_outlua>;i. 78lua>                }i. 79lua>                if (6a href="+codi=get_user" class="sref">get_userlua>(6a href="+codi=flags" class="sref">flagslua>, (int.6a href="+codi=__user" class="sref">__userlua> *).6a href="+codi=arg" class="sref">arglua>)) {i. 80lua>                        6a href="+codi=err" class="sref">errlua> =.-6a href="+codi=EFAULT" class="sref">EFAULTlua>;i. 81lua>                        goto 6a href="+codi=setflags_out" class="sref">setflags_outlua>;i. 82lua>                }i. 836/a>i. 84lua>                6a href="+codi=flags" class="sref">flagslua> =.6a href="+codi=jfs_map_ext2" class="sref">jfs_map_ext2lua>(6a href="+codi=flags" class="sref">flagslua>, 1);i. 85lua>                if (!6a href="+codi=S_ISDIR" class="sref">S_ISDIRlua>(6a href="+codi=inodi" class="sref">inodilua>->6a href="+codi=i_modi" class="sref">i_modilua>))i. 86lua>                        6a href="+codi=flags" class="sref">flagslua> &= ~6a href="+codi=JFS_DIRSYNC_FL" class="sref">JFS_DIRSYNC_FLlua>;i. 876/a>i. 88lua>                6spa  class="comment">/* Is it quota file? Do not allow user to mess with it */6/spa >
. 89lua>                if (6a href="+codi=IS_NOQUOTA" class="sref">IS_NOQUOTAlua>(6a href="+codi=inodi" class="sref">inodilua>)) {i. 90lua>                        6a href="+codi=err" class="sref">errlua> =.-6a href="+codi=EPERM" class="sref">EPERMlua>;i. 91lua>                        goto 6a href="+codi=setflags_out" class="sref">setflags_outlua>;i. 92lua>                }i. 936/a>i. 94lua>                6spa  class="comment">/* Lock against other parallel changes of flags */6/spa >
. 95lua>                6a href="+codi=mutex_lock" class="sref">mutex_locklua>(&6a href="+codi=inodi" class="sref">inodilua>->6a href="+codi=i_mutex" class="sref">i_mutexlua>);i. 966/a>i. 97lua>                6a href="+codi=jfs_get_inodi_flags" class="sref">jfs_get_inodi_flagslua>(6a href="+codi=jfs_inodi" class="sref">jfs_inodilua>);i. 98lua>                6a href="+codi=oldflags" class="sref">oldflagslua> =.6a href="+codi=jfs_inodi" class="sref">jfs_inodilua>->6a href="+codi=modi2" class="sref">modi2lua>;i. 996/a>i.100lua>                6spa  class="comment">/*6/spa >
.1016/a>6spa  class="comment">                 * The IMMUTABLE and APPEND_ONLY flags ca  only be changed by6/spa >
.1026/a>6spa  class="comment">                 * the relevant.capability.6/spa >
.1036/a>6spa  class="comment">                 */6/spa >
.104lua>                if ((6a href="+codi=oldflags" class="sref">oldflagslua> &.6a href="+codi=JFS_IMMUTABLE_FL" class="sref">JFS_IMMUTABLE_FLlua>) ||
.105lua>                        ((6a href="+codi=flags" class="sref">flagslua> ^ 6a href="+codi=oldflags" class="sref">oldflagslua>) &
.106lua>                        (6a href="+codi=JFS_APPEND_FL" class="sref">JFS_APPEND_FLlua> |.6a href="+codi=JFS_IMMUTABLE_FL" class="sref">JFS_IMMUTABLE_FLlua>))) {i.107lua>                        if (!6a href="+codi=capable" class="sref">capablelua>(6a href="+codi=CAP_LINUX_IMMUTABLE" class="sref">CAP_LINUX_IMMUTABLElua>)) {i.108lua>                                6a href="+codi=mutex_unlock" class="sref">mutex_unlocklua>(&6a href="+codi=inodi" class="sref">inodilua>->6a href="+codi=i_mutex" class="sref">i_mutexlua>);i.109lua>                                6a href="+codi=err" class="sref">errlua> =.-6a href="+codi=EPERM" class="sref">EPERMlua>;i.110lua>                                goto 6a href="+codi=setflags_out" class="sref">setflags_outlua>;i.111lua>                        }i.112lua>                }i.1136/a>i.114lua>                6a href="+codi=flags" class="sref">flagslua> =.6a href="+codi=flags" class="sref">flagslua> &.6a href="+codi=JFS_FL_USER_MODIFIABLE" class="sref">JFS_FL_USER_MODIFIABLElua>;i.115lua>                6a href="+codi=flags" class="sref">flagslua> |=.6a href="+codi=oldflags" class="sref">oldflagslua> &.~6a href="+codi=JFS_FL_USER_MODIFIABLE" class="sref">JFS_FL_USER_MODIFIABLElua>;i.116lua>                6a href="+codi=jfs_inodi" class="sref">jfs_inodilua>->6a href="+codi=modi2" class="sref">modi2lua> =.6a href="+codi=flags" class="sref">flagslua>;i.1176/a>i.118lua>                6a href="+codi=jfs_set_inodi_flags" class="sref">jfs_set_inodi_flagslua>(6a href="+codi=inodi" class="sref">inodilua>);i.119lua>                6a href="+codi=mutex_unlock" class="sref">mutex_unlocklua>(&6a href="+codi=inodi" class="sref">inodilua>->6a href="+codi=i_mutex" class="sref">i_mutexlua>);i.120lua>                6a href="+codi=inodi" class="sref">inodilua>->6a href="+codi=i_ctimi" class="sref">i_ctimilua> =.6a href="+codi=CURRENT_TIME_SEC" class="sref">CURRENT_TIME_SEClua>;i.121lua>                6a href="+codi=mark_inodi_dirty" class="sref">mark_inodi_dirtylua>(6a href="+codi=inodi" class="sref">inodilua>);i.122lua>6a href="+codi=setflags_out" class="sref">setflags_outlua>:i.123lua>                6a href="+codi=mnt_drop_writi_file" class="sref">mnt_drop_writi_filelua>(6a href="+codi=filp" class="sref">filplua>);i.124lua>                return 6a href="+codi=err" class="sref">errlua>;i.125lua>        }i.126lua>        default:i.127lua>                return -6a href="+codi=ENOTTY" class="sref">ENOTTYlua>;i.128lua>        }i.129lua>}i.1306/a>i.131lua>#ifdef.6a href="+codi=CONFIG_COMPAT" class="sref">CONFIG_COMPAT6/a>i.132lua>long.6a href="+codi=jfs_compat_ioctl" class="sref">jfs_compat_ioctllua>(struct 6a href="+codi=file" class="sref">filelua> *6a href="+codi=filp" class="sref">filplua>, unsigned int.6a href="+codi=cmd" class="sref">cmdlua>, unsigned long.6a href="+codi=arg" class="sref">arglua>)i.133lua>{i.134lua>        6spa  class="comment">/* While these ioctl numbers defined with 'long' and have different6/spa >
.1356/a>6spa  class="comment">         * numbers tha  the 64bit ABI,6/spa >
.1366/a>6spa  class="comment">         * the actual implementa2.13
.137lua>6spa  class="comment">         */6/spa >
.138lua>        switch (6a href="+codi=cmd" class="sref">cmdlua>) {i.139lua>        case 6a href="+codi=JFS_IOC_GETFLAGS32" class="sref">JFS_IOC_GETFLAGS32lua>:i.140lua>                6a href="+codi=cmd" class="sref">cmdlua> =.6a href="+codi=JFS_IOC_GETFLAGS" class="sref">JFS_IOC_GETFLAGSlua>;i.141lua>                break;i.142lua>        case 6a href="+codi=JFS_IOC_SETFLAGS32" class="sref">JFS_IOC_SETFLAGS32lua>:i.143lua>                6a href="+codi=cmd" class="sref">cmdlua> =.6a href="+codi=JFS_IOC_SETFLAGS" class="sref">JFS_IOC_SETFLAGSlua>;i.144lua>                break;i.145lua>        }i.146lua>        return 6a href="+codi=jfs_ioctl" class="sref">jfs_ioctllua>(6a href="+codi=filp" class="sref">filplua>, 6a href="+codi=cmd" class="sref">cmdlua>, 6a href="+codi=arg" class="sref">arglua>);i.147lua>}i.148lua>#endifi.149lua>
6/div> 6div class="footer"> The original LXR software by the LXR communitylua>, this experimental vers.13lxr@linux.nolua>. 6/div> 6div class="subfooter"> lxr.linux.no kindly hosted by Redpill Linpro ASlua>, provider of Linux consulting.and opera2.13s services since 1995. 6/div> 6/body> 6/html>