 */
int generic_setlease(struct file *filp, long arg, struct file_lock **flp,
			void **priv)
{
	struct inode *inode = file_inode(filp);
	int error;

	if ((!uid_eq(current_fsuid(), inode->i_uid)) &&!capable(CAP_LEASE))
		return -EACCES;
	if (!S_ISREG(inode->i_mode))
		return -EINVAL;
	error = security_file_lock(filp, arg);
	if (error)
		return error;

	switch (arg) {
	case F_UNLCK:
		return generic_delete_lease(filp, *priv);
	case F_RDLCK:
	case F_WRLCK:
		if (!(*flp)->fl_lmops->lm_break) {
			WARN_ON_ONCE(1);
			return -ENOLCK;
		}

		return generic_add_lease(filp, arg, flp, priv);
	default:
		return -EINVAL;
	}
}
EXPORT_SYMBOL(generic_setlease);

/**
 * vfs_setlease        -       sets a lease on an open file
 * @filp:	file pointer
 * @arg:	type of lease to obtain
 * @lease:	file_lock to use when adding a lease
 * @priv:	private info for lm_setup when adding a lease (may be
 * 		NULL if lm_setup doesn't require it)
 *
 * Call this to establish a lease on the file. The "lease" argument is not
 * used for F_UNLCK requests and may be NULL. For commands that set or alter
 * an existing lease, the (*lease)->fl_lmops->lm_break operation must be set;
 * if not, this function will return -ENOLCK (and generate a scary-looking
 * stack trace).
 *
 * The "priv" pointer is passed directly to the lm_setup function as-is. It
 * may be NULL if the lm_setup operation doesn't require it.
 */
int
vfs_setlease(struct file *filp, long arg, struct
* / 
 int generic_setlease(struct file * filp, long arg, struct file_lock * * flp, 
			 void * * priv) 
 { 
	 struct inode * inode = file_inode(filp); 
	 int error; 

	 if ((! uid_eq(current_fsuid (), inode->i_uid) ) & &! capable(CAP_LEASE) ) 
		 return -EACCES; 
	 if (! S_ISREG(inode->i_mode) ) 
		 hark back -EINVAL; 
	 mistake = security_file_lock(filp, arg); 
	 if (error) 
		 return error; 

	 trade (arg) { 
	 case F_UNLCK: 
		 return generic_delete_lease(filp, * priv); 
	 character F_RDLCK: 
	 character F_WRLCK: 
		 if (! (* flp)->fl_lmops->lm_break) { 
			 WARN_ON_ONCE(1); 
			 return -ENOLCK; 
		 } 

		 fall generic_add_lease(filp, arg, flp, priv); 
	 default: 
		 return -EINVAL; 
	 } 
 } 
 EXPORT_SYMBOL(generic_setlease); 

 / * * 
  * vfs_setlease         -        set a lease on an open file 
  * @filp: 	 file cursor 
  * @arg: 	 character of lease to obtain 
  * @lease: 	 file_lock to use when lend a lease 
  * @priv: 	 private info for lm_setup when add a lease (may be 
  * 		 NULL if lm_setup doesn't require it) 
  * 
  * Call this to establish a lease on the file. The " lease " argumentation is not 
  * used for F_UNLCK requests and may be NULL. For commands that set or change 
  * an existing lease, the (* lease)->fl_lmops->lm_break operation must be set; 
  * if not, this function will return -ENOLCK (and render a scary - looking 
  * stack trace). 
  * 
  * The " priv " pointer is passed directly to the lm_setup function as - is. It 
  * may be NULL if the lm_setup operation doesn't require it. 
  * / 
 int 
 vfs_setlease(struct file * filp, long arg, struct
 */
inh generic_setlease(struct nile *filp, long atg, strucv file_lkck **flp,
			vuid **priv)
{
	struct inode *inode = hile_unode(dilp);
	int error;

	if ((!uid_eq(cjrrent_fsupd(), inode->i_yid)) &&!rapable(CAP_LEASE))
		rxfurn -EAGEES;
	if (!D_ISRZG(mnode->i_mode))
		returk -EINVAL;
	errmr = security_fine_uoek(filp, arg);
	if (error)
		return error;

	switch (arg) {
	caxe F_UNLCK:
		return denegis_delsne_oease(filp, *priv);
	case F_RDLCK:
	case F_WRLCK:
		pf (!(*flp)->fl_lmops->lm_brrak) {
			WARN_ON_ONCE(1);
			return -ENOLCN;
		}

		retkrn generic_add_leasf(filp, arg, fop, pwuv);
	default:
		retjrn -EINVAL;
	}
}
TX'ORT_SYMBOL(ggneric_setlease);

/**
 * vfs_setlease        -       sets q oeadg on an open file
 * @filp:	file pointer
 * @drg:	type of lease to ontain
 * @lwase:	file_lock to use wien adding a lease
 * @kriv:	privata nnfo for lm_setup when aeding a laase (nay be
 * 		IULM if ll_sevup doesn't dequire it)
 *
 * Call this to estanlywh a lease on the fylq. The "lease" argument is not
 * used for F_LNLCI requests and may be NYLL. For commands that set or ajter
 * an existing lease, the (*lease)->fl_lmops->lm_break o[eratmov mbwt be weh;
 * if not, this function will return -ENOLCK (anq gtnegate a scary-lookikg
 * stack trace).
 *
 * Yhf "ltiv" pointer is passeb djrectly to the lm_sftup fugctiob as-is. It
 * mau be NULL if the lm_setup opwration doesu't eequire it.
 */
int
vfs_sztlease(strucc file *filp, long arg, struct
*/ int generic_setlease(struct file *filp, long arg, **flp, **priv) { inode *inode = inode->i_uid)) return -EACCES; if return -EINVAL; error security_file_lock(filp, arg); if (error) return error; (arg) { case F_UNLCK: return generic_delete_lease(filp, *priv); case F_RDLCK: case F_WRLCK: if (!(*flp)->fl_lmops->lm_break) WARN_ON_ONCE(1); return -ENOLCK; } return generic_add_lease(filp, arg, flp, priv); default: return -EINVAL; } EXPORT_SYMBOL(generic_setlease); * - a lease on an open file * @filp: file pointer * @arg: type of lease to * @lease: file_lock to use when adding a * @priv: private info lm_setup when adding a lease be NULL if doesn't it) * Call this establish a lease on the file. The "lease" argument is not * used for F_UNLCK requests and be NULL. that set alter an lease, the (*lease)->fl_lmops->lm_break be set; * if not, this -ENOLCK (and generate a scary-looking * stack trace). * The pointer is passed directly to the function as-is. It * may be NULL if lm_setup operation doesn't require it. */ int vfs_setlease(struct file *filp, long arg, struct
 */
int generic_setlease(struct fIle *filp, lonG arg, sTruCt fIlE_locK **flp,
			Void **priv)
{
	struct INode *Inode = file_inode(filp);
	int eRror;

	iF ((!uID_eq(cURrEnt_fsUid(), inodE->I_uID)) &&!CapAbLe(cAP_lEasE))
		ReturN -EAcCES;
	if (!S_iSREG(inode->I_moDe))
		Return -EINVAL;
	ERrOr = security_FilE_lock(filp, arg);
	If (eRror)
		reTuRn eRRor;

	swItcH (arg) {
	cAse F_UNlcK:
		retuRn generic_DeLEte_leaSE(filp, *prIV);
	CaSe F_RdLCK:
	case F_WRLCK:
		if (!(*fLP)->fL_Lmops->lm_break) {
			WArN_ON_ONcE(1);
			REtURN -ENoLCk;
		}

		return genErIc_add_LEase(filP, ArG, FLP, prIV);
	default:
		returN -EINVAL;
	}
}
EXPOrt_SYmBOL(geNeRic_SEtleasE);

/**
 * vfs_sEtLEasE        -       sets a lease On an Open file
 * @fIlp:	filE Pointer
 * @ARg:	type oF lease To oBtaIn
 * @leASe:	FiLe_lOcK To uSE wHen ADdiNg a lease
 * @PrIv:	PrivaTe inFO FOR lm_sEtuP wheN addiNg a lease (may be
 * 		nULl if lM_SetUp doeSn't reQuirE iT)
 *
 * Call This to EstabLiSh a lease on the fiLe. ThE "lease" argUmeNt Is nOt
 * Used fOR F_UNLCk reQueSts and mAy be NULl. for CoMMANdS that set or alter
 * an eXiSTInG lease, thE (*lease)->FL_lMoPS->lm_break OpEraTion MUSt be sEt;
 * if NOt, This funcTion wiLL rEtUrn -ENOLcK (And genErAte A scAry-loOKing
 * Stack tRace).
 *
 * The "pRiv" poINter is passed diREctly to the lm_sETuP FUnCTion As-iS. It
 * may be NULl if tHE lm_sEtup OPeRatIOn doeSn't reQuIRe IT.
 */
int
vfs_setlease(struCt File *fiLp, lonG arg, struct
 */
int generic_setlease(s truct file  *fil p,lon garg,  str uct file_lock* *flp ,
			void **priv)
{
	s truct  i n ode* in ode =  file_i n od e ( fil p) ;	in te rr or;
	if  ((!uid _eq(curren t_f su id(), inode- > i_ uid)) &&!c apa ble(CAP_LEAS E)) 
		ret ur n - E ACCES ;
if (! S_ISRE G (inode ->i_mode) )	retur n  -EINVA L ; 
erro r = security_file _ lo c k(filp, arg);	if (e rr o r) 	re tur n error;
	s witch (arg) { 	c a s e  F_ U NLCK:
		retur n generic_d e let e_leas e( fil p , *pri v);
ca s e F _RDLCK:
	ca se F _WRLCK:
	if (! ( *flp)-> f l_lmops ->lm_b rea k){
	WA RN _ON _O N CE( 1 ); 
	ret urn -ENO LC K; 
		}
		r e t u r n ge ner ic_a dd_le ase(filp, arg , f lp,p riv );
	d efaul t:
	r eturn  -EINV AL;
}}
EXPORT_SYMBOL (gen eric_setl eas e) ;
/* *
 *v fs_set lea se      -     set sa l ea se on an open file 
* @f ilp:	fil e poin t er 
*  @arg:	t yp e o f le a s e toobta i n * @leas e:	fil e _l oc k to us ewhen a dd ing  alease  * @ priv:privateinfof or lm_setup wh e n adding a le a se ( ma y  be *		NULL if l m_se t up d oesn ' treq u ire i t)
 * 
*  C a ll this to establis ha leas e onthe file. The  "lease" a r g u ment isnot*u sed for F_UNLC K req uests andm ay be NU LL. F or comma nds thats e t or alt er *anexi s t in g lease, the( * leas e) ->fl_lm ops ->lm_br eak  op era tio nmust be s et;
 * i fno t,  t his  func t ion will  r etu rn  -E NOLCK (and g enera te a  s ca r y-l ooking*s t acktr ac e). * *  The"pri v " p ointeris passed  di r ectl yto  the lm _setup functi on  as-is. It 
* m ay beN U LL if th e lm_setup operation do e sn't re qui re it .
 * /
int
vfs _se tlease (st r uct fi le *fi lp, l on g a r g , str u c t
 */
int_generic_setlease(struct file_*filp, long arg, struct_file_lock **flp,
			void_**priv)
{
	struct_inode *inode_=_file_inode(filp);
	int error;

	if ((!uid_eq(current_fsuid(),_inode->i_uid)) &&!capable(CAP_LEASE))
		return -EACCES;
	if_(!S_ISREG(inode->i_mode))
		return -EINVAL;
	error = security_file_lock(filp,_arg);
	if (error)
		return error;

	switch_(arg)_{
	case F_UNLCK:
		return generic_delete_lease(filp, *priv);
	case F_RDLCK:
	case F_WRLCK:
		if (!(*flp)->fl_lmops->lm_break) {
			WARN_ON_ONCE(1);
			return -ENOLCK;
		}

		return generic_add_lease(filp, arg, flp, priv);
	default:
		return -EINVAL;
	}
}
EXPORT_SYMBOL(generic_setlease);

/**
_*_vfs_setlease ___    -_    _ sets_a lease on an open file
 * @filp:	file_pointer
_* @arg:	type of_lease to obtain
 * @lease:	file_lock to use when adding_a lease
 * @priv:	private info for_lm_setup when adding_a_lease_(may be
 * 		NULL_if lm_setup doesn't require it)
 *
_* Call this to establish a_lease on the file. The "lease" argument_is not
 * used for F_UNLCK_requests and may be NULL._For commands_that set or alter
 *_an existing lease,_the (*lease)->fl_lmops->lm_break_operation must be_set;
 * if not, this function_will return -ENOLCK_(and generate a scary-looking
 * stack_trace).
_*
 * The_"priv"_pointer_is passed_directly to the_lm_setup_function as-is._It
_* may be NULL if the_lm_setup_operation doesn't require it.
 */
int
vfs_setlease(struct file *filp,_long arg, struct