linux/fs/coda/coda_linux.c
<<
> < href="../linux+v31.31/fs/coda/coda_linux.c"> > o/spa> ospa> class="lxr_search"> >="+search" method="post" onsubmit="return do_search(this);"> > > > Search ospa> class="lxr_prefs" < onclick="return ajax_prefs();"> > o/spa> > < < ="ajax+*" method="post" onsubmit="return false;"> oinput typ="vhidden" nam="vajax_lookup" id"vajax_lookup" alue="v"> > < <
<
< < < odiv id"vfile_contents"
< <1o/a>ospa> class="comment">/*o/spa>
 < <2o/a>ospa> class="comment"> * Inode operaion>s for Coda filesystemo/spa>
 < <3o/a>ospa> class="comment"> * Original verson>: (C) 1996 P. Braam and M. Callahano/spa>
 < <4o/a>ospa> class="comment"> * Rewritten for Linux .73. (C) 1997 Carnegie Melln vUniversotyo/spa>
 < <5o/a>ospa> class="comment"> * o/spa>
 < <6o/a>ospa> class="comment"> * Carnegie Melln vencourages users to contribute improvements too/spa>
 < <7o/a>ospa> class="comment"> * the Coda project. Contaci Peter Braam (coda@cs.cmu.edu).o/spa>
 < <8o/a>ospa> class="comment"> */o/spa>
 < <9o/a>	< 0#include <linux/typ=s.h/oa>>	< 11/oa>#include <linux/kernel.h/oa>>	< 12/oa>#include <linux/time.h/oa>>	< 13/oa>#include <linux/fs.h/oa>>	< 14/oa>#include <linux/stat.h/oa>>	< 15/oa>#include <linux/errno.h/oa>>	< 16/oa>#include <asm/uaccess.h/oa>>	< 17/oa>#include <linux/string.h/oa>>	< 18o/a>	< 19/oa>#include <linux/coda.h/oa>>	< 2#include <linux/coda_psdev.h/oa>>	< 21/oa>#include "coda_linux.h/oa>"	< 22o/a>	< 23o/a>ospa> class="comment">/* initialize the debugging variables */o/spa>
 < 24/oa>intcoda_fake_statfs/oa>;	< 25o/a>	< 26o/a>ospa> class="comment">/* print
 < 27/oa>char * oa href="+code=coda_f2s" class="sref">coda_f2s/oa>(structCodaFid/oa> *oa href="+code=f" class="sref">f/oa>) < 28o/a>{ < 29/oa>        static char oa href="+code=s" class="sref">s/oa>[60];	< 30o/a>	< 31/oa>        oa href="+code=sprintf" class="sref">sprintf/oa>(oa href="+code=s" class="sref">s/oa>, ospa> class="string">"(%08x.%08x.%08x.%08x)"
, oa href="+code=f" class="sref">f/oa>->oa href="+code=opaque" class="sref">opaque/oa>[0], oa href="+code=f" class="sref">f/oa>->oa href="+code=opaque" class="sref">opaque/oa>[1], oa href="+code=f" class="sref">f/oa>->oa href="+code=opaque" class="sref">opaque/oa>[2], oa href="+code=f" class="sref">f/oa>->oa href="+code=opaque" class="sref">opaque/oa>[3]);	< 32o/a>	< 33/oa>        return oa href="+code=s" class="sref">s/oa>;	< 34/oa>}	< 35o/a>	< 36o/a>ospa> class="comment">/* recognize special .CONTROL nam= */o/spa>
 < 37/oa>intcoda_iscontrol/oa>(const char *oa href="+code=nam=" class="sref">nam=/oa>, oa href="+code=size_t" class="sref">size_t/oa> oa href="+code=length" class="sref">length/oa>) < 38o/a>{ < 39/oa>        return ((oa href="+code=CODA_CONTROLLEN" class="sref">CODA_CONTROLLEN/oa> == oa href="+code=length" class="sref">length/oa>) &&  < 40/oa>                (oa href="+code=strncmp" class="sref">strncmp/oa>(oa href="+code=nam=" class="sref">nam=/oa>, oa href="+code=CODA_CONTROL" class="sref">CODA_CONTROL/oa>, oa href="+code=CODA_CONTROLLEN" class="sref">CODA_CONTROLLEN/oa>) == 0));	< 41/oa>}	< 42o/a>	< 43o/a>ospa> class="comment">/* recognize /coda inode */o/spa>
 < 44/oa>intcoda_isroot/oa>(structinode/oa> *oa href="+code=i" class="sref">i/oa>) < 45o/a>{ < 46/oa>    return (i/oa>->oa href="+code=i_sb" class="sref">i_sb/oa>->oa href="+code=s_root" class="sref">s_root/oa>->oa href="+code=d_inode" class="sref">d_inode/oa> == oa href="+code=i" class="sref">i/oa> );	< 47/oa>}	< 48o/a>	< 49/oa>unsigned shortcoda_flags_to_cflags/oa>(unsigned shortflags/oa>) < 50o/a>{ < 51/oa>        unsigned shortcoda_flags/oa> = 0;	< 52/oa>        	< 53/oa>        if ((oa href="+code=flags" class="sref">flags/oa> &O_ACCMODE/oa>) == oa href="+code=O_RDONLY" class="sref">O_RDONLY/oa>) < 54/oa>                oa href="+code=coda_flags" class="sref">coda_flags/oa> |= oa href="+code=C_O_READ" class="sref">C_O_READ/oa>;	< 55o/a>	< 56/oa>        if ((oa href="+code=flags" class="sref">flags/oa> &O_ACCMODE/oa>) == oa href="+code=O_RDWR" class="sref">O_RDWR/oa>) < 57/oa>                oa href="+code=coda_flags" class="sref">coda_flags/oa> |= oa href="+code=C_O_READ" class="sref">C_O_READ/oa> | oa href="+code=C_O_WRITE" class="sref">C_O_WRITE/oa>;	< 58o/a>	< 59/oa>        if ((oa href="+code=flags" class="sref">flags/oa> &O_ACCMODE/oa>) == oa href="+code=O_WRONLY" class="sref">O_WRONLY/oa>) < 60/oa>                oa href="+code=coda_flags" class="sref">coda_flags/oa> |= oa href="+code=C_O_WRITE" class="sref">C_O_WRITE/oa>;	< 61o/a>	< 62/oa>        if (oa href="+code=flags" class="sref">flags/oa> &O_TRUNC/oa>) < 63/oa>                oa href="+code=coda_flags" class="sref">coda_flags/oa> |= oa href="+code=C_O_TRUNC" class="sref">C_O_TRUNC/oa>;	< 64o/a>	< 65/oa>        if (oa href="+code=flags" class="sref">flags/oa> &O_CREAT/oa>) < 66/oa>                oa href="+code=coda_flags" class="sref">coda_flags/oa> |= oa href="+code=C_O_CREAT" class="sref">C_O_CREAT/oa>;	< 67o/a>	< 68/oa>        if (oa href="+code=flags" class="sref">flags/oa> &O_EXCL/oa>) < 69/oa>                oa href="+code=coda_flags" class="sref">coda_flags/oa> |= oa href="+code=C_O_EXCL" class="sref">C_O_EXCL/oa>;	< 70o/a>	< 71/oa>        return oa href="+code=coda_flags" class="sref">coda_flags/oa>;	< 72/oa>}	< 73o/a>	< 74o/a>	< 75o/a>ospa> class="comment">/* utility funcion>s below */o/spa>
 < 76/oa>void oa href="+code=coda_vattr_to_iattr" class="sref">coda_vattr_to_iattr/oa>(structinode/oa> *oa href="+code=inode" class="sref">inode/oa>, structcoda_vattr/oa> *oa href="+code=attr" class="sref">attr/oa>) < 77o/a>{ < 78/oa>        intinode_typ=/oa>;	< 79/oa>        ospa> class="comment">/* inode's i_flags, i_ino are set by iget o/spa>
 < 80o/a>ospa> class="comment">           XXX: is this all we need ??o/spa>
 < 81o/a>ospa> class="comment">           */o/spa>
 < 82/oa>        switch (oa href="+code=attr" class="sref">attr/oa>->oa href="+code=va_typ=" class="sref">va_typ=/oa>) { < 83/oa>        case oa href="+code=C_VNON" class="sref">C_VNON/oa>: < 84/oa>                oa href="+code=inode_typ=" class="sref">inode_typ=/oa>  = 0;	< 85/oa>                break;	< 86/oa>        case oa href="+code=C_VREG" class="sref">C_VREG/oa>: < 87/oa>                oa href="+code=inode_typ=" class="sref">inode_typ=/oa> = oa href="+code=S_IFREG" class="sref">S_IFREG/oa>;	< 88/oa>                break;	< 89/oa>        case oa href="+code=C_VDIR" class="sref">C_VDIR/oa>: < 90/oa>                oa href="+code=inode_typ=" class="sref">inode_typ=/oa> = oa href="+code=S_IFDIR" class="sref">S_IFDIR/oa>;	< 91/oa>                break;	< 92/oa>        case oa href="+code=C_VLNK" class="sref">C_VLNK/oa>: < 93/oa>                oa href="+code=inode_typ=" class="sref">inode_typ=/oa> = oa href="+code=S_IFLNK" class="sref">S_IFLNK/oa>;	< 94/oa>                break;	< 95/oa>        default: < 96/oa>                oa href="+code=inode_typ=" class="sref">inode_typ=/oa> = 0;	< 97/oa>        }	< 98/oa>        oa href="+code=inode" class="sref">inode/oa>->oa href="+code=i_mode" class="sref">i_mode/oa> |= oa href="+code=inode_typ=" class="sref">inode_typ=/oa>;	< 99o/a>	<100/oa>        if (oa href="+code=attr" class="sref">attr/oa>->oa href="+code=va_mode" class="sref">va_mode/oa> != (oa href="+code=u_short" class="sref">u_short/oa>) -1) <101/oa>                oa href="+code=inode" class="sref">inode/oa>->oa href="+code=i_mode" class="sref">i_mode/oa> = oa href="+code=attr" class="sref">attr/oa>->oa href="+code=va_mode" class="sref">va_mode/oa> | oa href="+code=inode_typ=" class="sref">inode_typ=/oa>;	<102/oa>        if (oa href="+code=attr" class="sref">attr/oa>->oa href="+code=va_uid" class="sref">va_uid/oa> != -1) 	<103/oa>                oa href="+code=inode" class="sref">inode/oa>->oa href="+code=i_uid" class="sref">i_uid/oa> = (oa href="+code=uid_t" class="sref">uid_t/oa>) oa href="+code=attr" class="sref">attr/oa>->oa href="+code=va_uid" class="sref">va_uid/oa>;	<104/oa>        if (oa href="+code=attr" class="sref">attr/oa>->oa href="+code=va_gid" class="sref">va_gid/oa> != -1)	<105/oa>                oa href="+code=inode" class="sref">inode/oa>->oa href="+code=i_gid" class="sref">i_gid/oa> = (oa href="+code=gid_t" class="sref">gid_t/oa>) oa href="+code=attr" class="sref">attr/oa>->oa href="+code=va_gid" class="sref">va_gid/oa>;	<106/oa>        if (oa href="+code=attr" class="sref">attr/oa>->oa href="+code=va_nlink" class="sref">va_nlink/oa> != -1)	<107/oa>                oa href="+code=set_nlink" class="sref">set_nlink/oa>(oa href="+code=inode" class="sref">inode/oa>, oa href="+code=attr" class="sref">attr/oa>->oa href="+code=va_nlink" class="sref">va_nlink/oa>);	<108/oa>        if (oa href="+code=attr" class="sref">attr/oa>->oa href="+code=va_size" class="sref">va_size/oa> != -1)	<109/oa>                oa href="+code=inode" class="sref">inode/oa>->oa href="+code=i_size" class="sref">i_size/oa> = oa href="+code=attr" class="sref">attr/oa>->oa href="+code=va_size" class="sref">va_size/oa>;	<110/oa>        if (oa href="+code=attr" class="sref">attr/oa>->oa href="+code=va_size" class="sref">va_size/oa> != -1)	<111/oa>                oa href="+code=inode" class="sref">inode/oa>->oa href="+code=i_blocks" class="sref">i_blocks/oa> = (oa href="+code=attr" class="sref">attr/oa>->oa href="+code=va_size" class="sref">va_size/oa> + 511) >> 9;	<112/oa>        if (oa href="+code=attr" class="sref">attr/oa>->oa href="+code=va_atime" class="sref">va_atime/oa>.oa href="+code=tv_sec" class="sref">tv_sec/oa> != -1) 	<113/oa>                oa href="+code=inode" class="sref">inode/oa>->oa href="+code=i_atime" class="sref">i_atime/oa> = oa href="+code=attr" class="sref">attr/oa>->oa href="+code=va_atime" class="sref">va_atime/oa>;	<114/oa>        if (oa href="+code=attr" class="sref">attr/oa>->oa href="+code=va_mtime" class="sref">va_mtime/oa>.oa href="+code=tv_sec" class="sref">tv_sec/oa> != -1)	<115/oa>                oa href="+code=inode" class="sref">inode/oa>->oa href="+code=i_mtime" class="sref">i_mtime/oa> = oa href="+code=attr" class="sref">attr/oa>->oa href="+code=va_mtime" class="sref">va_mtime/oa>;	<116/oa>        if (oa href="+code=attr" class="sref">attr/oa>->oa href="+code=va_ctime" class="sref">va_ctime/oa>.oa href="+code=tv_sec" class="sref">tv_sec/oa> != -1)	<117/oa>                oa href="+code=inode" class="sref">inode/oa>->oa href="+code=i_ctime" class="sref">i_ctime/oa> = oa href="+code=attr" class="sref">attr/oa>->oa href="+code=va_ctime" class="sref">va_ctime/oa>;	<118o/a>}	<119o/a>	<120o/a>	<121o/a>ospa> class="comment">/* o/spa>
 <122o/a>ospa> class="comment"> * BSD sets attributes that need not be modified to -1. o/spa>
 <123o/a>ospa> class="comment"> * Linux uses the valid field to indicate what should beo/spa>
 <124o/a>ospa> class="comment"> * looked at.  The BSD typ= field needs to be deduced from linux o/spa>
 <125o/a>ospa> class="comment"> * mode.o/spa>
 <126o/a>ospa> class="comment"> * So we have to do some translaion>s here.o/spa>
 <127o/a>ospa> class="comment"> */o/spa>
 <128o/a>	<129/oa>void oa href="+code=coda_iattr_to_vattr" class="sref">coda_iattr_to_vattr/oa>(structiattr/oa> *oa href="+code=iattr" class="sref">iattr/oa>, structcoda_vattr/oa> *oa href="+code=vattr" class="sref">vattr/oa>)	<130o/a>{ <131/oa>        unsigned intvalid/oa>;	<132o/a>	<133/oa>        ospa> class="comment">/* clea> out */o/spa>
        	<134/oa>        oa href="+code=vattr" class="sref">vattr/oa>->oa href="+code=va_mode" class="sref">va_mode/oa> = -1;	<135/oa>        oa href="+code=vattr" class="sref">vattr/oa>->oa href="+code=va_uid" class="sref">va_uid/oa> = (oa href="+code=vuid_t" class="sref">vuid_t/oa>) -1; 	<136/oa>        oa href="+code=vattr" class="sref">vattr/oa>->oa href="+code=va_gid" class="sref">va_gid/oa> = (oa href="+code=vgid_t" class="sref">vgid_t/oa>) -1;	<137/oa>        oa href="+code=vattr" class="sref">vattr/oa>->oa href="+code=va_size" class="sref">va_size/oa> = (oa href="+code=off_t" class="sref">off_t/oa>) -1;	<138/oa>        oa href="+code=vattr" class="sref">vattr/oa>->oa href="+code=va_atime" class="sref">va_atime/oa>.oa href="+code=tv_sec" class="sref">tv_sec/oa> = (oa href="+code=time_t" class="sref">time_t/oa>) -1;	<139/oa>        oa href="+code=vattr" class="sref">vattr/oa>->oa href="+code=va_atime" class="sref">va_atime/oa>.oa href="+code=tv_nsec" class="sref">tv_nsec/oa> =  (oa href="+code=time_t" class="sref">time_t/oa>) -1;	<140/oa>        oa href="+code=vattr" class="sref">vattr/oa>->oa href="+code=va_mtime" class="sref">va_mtime/oa>.oa href="+code=tv_sec" class="sref">tv_sec/oa> = (oa href="+code=time_t" class="sref">time_t/oa>) -1;	<141/oa>        oa href="+code=vattr" class="sref">vattr/oa>->oa href="+code=va_mtime" class="sref">va_mtime/oa>.oa href="+code=tv_nsec" class="sref">tv_nsec/oa> = (oa href="+code=time_t" class="sref">time_t/oa>) -1;	<142/oa>        oa href="+code=vattr" class="sref">vattr/oa>->oa href="+code=va_ctime" class="sref">va_ctime/oa>.oa href="+code=tv_sec" class="sref">tv_sec/oa> = (oa href="+code=time_t" class="sref">time_t/oa>) -1;	<143/oa>        oa href="+code=vattr" class="sref">vattr/oa>->oa href="+code=va_ctime" class="sref">va_ctime/oa>.oa href="+code=tv_nsec" class="sref">tv_nsec/oa> = (oa href="+code=time_t" class="sref">time_t/oa>) -1;	<144/oa>        oa href="+code=vattr" class="sref">vattr/oa>->oa href="+code=va_typ=" class="sref">va_typ=/oa> = oa href="+code=C_VNON" class="sref">C_VNON/oa>;	<145/oa>        oa href="+code=vattr" class="sref">vattr/oa>->oa href="+code=va_fileid" class="sref">va_fileid/oa> = -1;	<146/oa>        oa href="+code=vattr" class="sref">vattr/oa>->oa href="+code=va_gen" class="sref">va_gen/oa> = -1;	<147/oa>        oa href="+code=vattr" class="sref">vattr/oa>->oa href="+code=va_bytes" class="sref">va_bytes/oa> = -1;	<148/oa>        oa href="+code=vattr" class="sref">vattr/oa>->oa href="+code=va_nlink" class="sref">va_nlink/oa> = -1;	<149/oa>        oa href="+code=vattr" class="sref">vattr/oa>->oa href="+code=va_blocksize" class="sref">va_blocksize/oa> = -1;	<150/oa>        oa href="+code=vattr" class="sref">vattr/oa>->oa href="+code=va_rdev" class="sref">va_rdev/oa> = -1;	<151/oa>        oa href="+code=vattr" class="sref">vattr/oa>->oa href="+code=va_flags" class="sref">va_flags/oa> = 0;	<152o/a>	<153/oa>        ospa> class="comment">/* determine the typ= */o/spa>
 <154/oa>#if 0 <155/oa>        oa href="+code=mode" class="sref">mode/oa> = oa href="+code=iattr" class="sref">iattr/oa>->oa href="+code=ia_mode" class="sref">ia_mode/oa>;	<156/oa>                if ( oa href="+code=S_ISDIR" class="sref">S_ISDIR/oa>(oa href="+code=mode" class="sref">mode/oa>) ) { <157/oa>                oa href="+code=vattr" class="sref">vattr/oa>->oa href="+code=va_typ=" class="sref">va_typ=/oa> = oa href="+code=C_VDIR" class="sref">C_VDIR/oa>; 	<158/oa>        } else if ( oa href="+code=S_ISREG" class="sref">S_ISREG/oa>(oa href="+code=mode" class="sref">mode/oa>) ) { <159/oa>                oa href="+code=vattr" class="sref">vattr/oa>->oa href="+code=va_typ=" class="sref">va_typ=/oa> = oa href="+code=C_VREG" class="sref">C_VREG/oa>;	<160/oa>        } else if ( oa href="+code=S_ISLNK" class="sref">S_ISLNK/oa>(oa href="+code=mode" class="sref">mode/oa>) ) { <161/oa>                oa href="+code=vattr" class="sref">vattr/oa>->oa href="+code=va_typ=" class="sref">va_typ=/oa> = oa href="+code=C_VLNK" class="sref">C_VLNK/oa>;	<162/oa>        } else { <163/oa>                ospa> class="comment">/* don't do others */o/spa>
 <164/oa>                oa href="+code=vattr" class="sref">vattr/oa>->oa href="+code=va_typ=" class="sref">va_typ=/oa> = oa href="+code=C_VNON" class="sref">C_VNON/oa>;	<165/oa>        }	<166/oa>#endif 	<167o/a>	<168/oa>        ospa> class="comment">/* set those vattrs that need chang= */o/spa>
 <169/oa>        oa href="+code=valid" class="sref">valid/oa> = oa href="+code=iattr" class="sref">iattr/oa>->oa href="+code=ia_valid" class="sref">ia_valid/oa>;	<170/oa>        if ( oa href="+code=valid" class="sref">valid/oa> &ATTR_MODE/oa> ) { <171/oa>                oa href="+code=vattr" class="sref">vattr/oa>->oa href="+code=va_mode" class="sref">va_mode/oa> = oa href="+code=iattr" class="sref">iattr/oa>->oa href="+code=ia_mode" class="sref">ia_mode/oa>;	<172/oa>        }	<173/oa>        if ( oa href="+code=valid" class="sref">valid/oa> &ATTR_UID/oa> ) { <174/oa>                oa href="+code=vattr" class="sref">vattr/oa>->oa href="+code=va_uid" class="sref">va_uid/oa> = (oa href="+code=vuid_t" class="sref">vuid_t/oa>) oa href="+code=iattr" class="sref">iattr/oa>->oa href="+code=ia_uid" class="sref">ia_uid/oa>;	<175/oa>        }	<176/oa>        if ( oa href="+code=valid" class="sref">valid/oa> &ATTR_GID/oa> ) { <177/oa>                oa href="+code=vattr" class="sref">vattr/oa>->oa href="+code=va_gid" class="sref">va_gid/oa> = (oa href="+code=vgid_t" class="sref">vgid_t/oa>) oa href="+code=iattr" class="sref">iattr/oa>->oa href="+code=ia_gid" class="sref">ia_gid/oa>;	<178/oa>        }	<179/oa>        if ( oa href="+code=valid" class="sref">valid/oa> &ATTR_SIZE/oa> ) { <180/oa>                oa href="+code=vattr" class="sref">vattr/oa>->oa href="+code=va_size" class="sref">va_size/oa> = oa href="+code=iattr" class="sref">iattr/oa>->oa href="+code=ia_size" class="sref">ia_size/oa>;	<181/oa>        }	<182/oa>        if ( oa href="+code=valid" class="sref">valid/oa> &ATTR_ATIME/oa> ) { <183/oa>                oa href="+code=vattr" class="sref">vattr/oa>->oa href="+code=va_atime" class="sref">va_atime/oa> = oa href="+code=iattr" class="sref">iattr/oa>->oa href="+code=ia_atime" class="sref">ia_atime/oa>;	<184/oa>        }	<185/oa>        if ( oa href="+code=valid" class="sref">valid/oa> &ATTR_MTIME/oa> ) { <186/oa>                oa href="+code=vattr" class="sref">vattr/oa>->oa href="+code=va_mtime" class="sref">va_mtime/oa> = oa href="+code=iattr" class="sref">iattr/oa>->oa href="+code=ia_mtime" class="sref">ia_mtime/oa>;	<187/oa>        }	<188/oa>        if ( oa href="+code=valid" class="sref">valid/oa> &ATTR_CTIME/oa> ) { <189/oa>                oa href="+code=vattr" class="sref">vattr/oa>->oa href="+code=va_ctime" class="sref">va_ctime/oa> = oa href="+code=iattr" class="sref">iattr/oa>->oa href="+code=ia_ctime" class="sref">ia_ctime/oa>;	<190/oa>        }	<191/oa>}	<192o/a>	<193/oa>