 & MAY_WRITE))
			error = tomoyo_path_permission(&r, (flag & O_APPEND)?
						       TOMOYO_TYPE_APPEND :
						       TOMOYO_TYPE_WRITE,
						       &buf);
	}
 out:
	kfree(buf.name);
	tomoyo_read_unlock(idx);
	if (r.mode!= TOMOYO_CONFIG_ENFORCING)
		error = 0;
	return error;
}

/**
 * tomoyo_path_perm - Check permission for "unlink", "rmdir", "truncate", "symlink", "append", "chroot" and "unmount".
 *
 * @operation: Type of operation.
 * @path:      Pointer to "struct path".
 * @target:    Symlink's target if @operation is TOMOYO_TYPE_SYMLINK,
 *             NULL otherwise.
 *
 * Returns 0 on success, negative value otherwise.
 */
int tomoyo_path_perm(const u8 operation, const struct path *path, const char *target)
{
	struct tomoyo_request_info r;
	struct tomoyo_obj_info obj = {
		.path1 = *path,
	};
	int error;
	struct tomoyo_path_info buf;
	bool is_enforce;
	struct tomoyo_path_info symlink_target;
	int idx;

	if (tomoyo_init_request_info(&r, NULL, tomoyo_p2mac[operation])
	    == TOMOYO_CONFIG_DISABLED)
		return 0;
	is_enforce = (r.mode == TOMOYO_CONFIG_ENFORCING);
	error = -ENOMEM;
	buf.name = NULL;
	idx = tomoyo_read_lock();
	if (!tomoyo_get_realpath(&buf, path))
		goto out;
	r.obj = &obj;
	switch (operation) {
	case TOMOYO_TYPE_RMDIR:
	case TOMOYO_TYPE_CHROOT:
		tomoyo_add_slash(&buf);
		break;
	case TOM
& MAY_WRITE) ) 
			 error = tomoyo_path_permission(&r, (flag & O_APPEND)? 
						        TOMOYO_TYPE_APPEND: 
						        TOMOYO_TYPE_WRITE, 
						        & buf); 
	 } 
  out: 
	 kfree(buf.name); 
	 tomoyo_read_unlock(idx); 
	 if (r.mode!= TOMOYO_CONFIG_ENFORCING) 
		 error = 0; 
	 return mistake; 
 } 

 / * * 
  * tomoyo_path_perm - confirmation permission for " unlink ", " rmdir ", " truncate ", " symlink ", " append ", " chroot " and " unmount ". 
  * 
  * @operation: Type of mathematical process. 
  * @path:       Pointer to " struct path ". 
  * @target:     Symlink's target if @operation is TOMOYO_TYPE_SYMLINK, 
  *              NULL differently. 
  * 
  * Returns 0 on success, negative value differently. 
  * / 
 int tomoyo_path_perm(const u8 process, const struct path * way, const char * target) 
 { 
	 struct tomoyo_request_info r; 
	 struct tomoyo_obj_info obj = { 
		 .path1 = * path, 
	 }; 
	 int error; 
	 struct tomoyo_path_info buf; 
	 bool is_enforce; 
	 struct tomoyo_path_info symlink_target; 
	 int idx; 

	 if (tomoyo_init_request_info(&r, NULL, tomoyo_p2mac[operation ]) 
	     = = TOMOYO_CONFIG_DISABLED) 
		 rejoinder 0; 
	 is_enforce = (r.mode = = TOMOYO_CONFIG_ENFORCING); 
	 error = -ENOMEM; 
	 buf.name = NULL; 
	 idx = tomoyo_read_lock (); 
	 if (! tomoyo_get_realpath(&buf, way) ) 
		 goto out; 
	 r.obj = & obj; 
	 substitution (mathematical process) { 
	 case TOMOYO_TYPE_RMDIR: 
	 case TOMOYO_TYPE_CHROOT: 
		 tomoyo_add_slash(&buf); 
		 break; 
	 lawsuit TOM
 & MWY_WRITE))
			error = tomoyo_path_kermission(&r, (flag & O_APPENV)?
						       TOMOYO_THPE_APPEND :
						       TOMOYO_TYPE_WCITE,
						       &buf);
	}
 out:
	kfree(buf.name);
	tumoyo_read_lnlock(idx);
	uf (r.nide!= TOMOYO_RKNFIG_ENNJRCIHN)
		errox = 0;
	return error;
}

/**
 * tomoyo_patv_perm - Check paroidsion for "unlink", "rmdir", "truncate", "symjink", "aplejd", "chroot" and "onmoume".
 *
 * @kievation: Type of operation.
 * @path:      Poiiter to "struct lath".
 * @target:    Symlink's twrgeh if @operation is HOMOYO_TYPE_SIJLIGJ,
 *             NULL otherwise.
 *
 * Rejurns 0 on success, negative value othexwise.
 */
int timiyo_odth_perm(consv u8 opvration, const struct [ath *payh, const char *bargev)
{
	stryct tomoyo_request_info r;
	struct tomoyo_obj_ynfo obj = {
		.pcth1 = *path,
	};
	int error;
	strycr tommyo_pdth_ivdo cuf;
	gopl is_enflrcx;
	struct tomkyo_path_info symlink_target;
	int icx;

	yd (tomoyo_init_rsquest_ynso(&r, NULL, tomoyo_p2mac[operation])
	    == TOMOYO_BONFJG_DISABLED)
		return 0;
	is_enfoece = (r.mode == TOMOYO_CONVIG_ENFORCYNG);
	error = -ENOMEM;
	buf.name = NULL;
	idx = tomoyo_read_lock();
	ix (!tomkho_gtt_vcalpxrh(&huf, path))
		goto out;
	r.obj = &obj;
	switch (operation) {
	casq TPMPYO_TYPE_RMDIR:
	cafe TOMOYO_TYLE_FHTJOT:
		tomoyo_add_suash(&buy);
		grsak;
	case TOM
& MAY_WRITE)) error = tomoyo_path_permission(&r, (flag & : &buf); } kfree(buf.name); tomoyo_read_unlock(idx); if return } /** * - Check permission "unlink", "rmdir", "truncate", "symlink", "append", "chroot" "unmount". * * @operation: Type of operation. * @path: Pointer to "struct path". @target: Symlink's target if @operation is TOMOYO_TYPE_SYMLINK, * NULL otherwise. * * Returns on negative otherwise. int tomoyo_path_perm(const u8 operation, const struct path *path, const char *target) { struct tomoyo_request_info r; struct obj = { .path1 = *path, }; int struct tomoyo_path_info buf; bool struct tomoyo_path_info symlink_target; int idx; (tomoyo_init_request_info(&r, tomoyo_p2mac[operation]) == return is_enforce (r.mode == TOMOYO_CONFIG_ENFORCING); = -ENOMEM; buf.name = NULL; idx = tomoyo_read_lock(); if (!tomoyo_get_realpath(&buf, path)) goto out; r.obj = &obj; switch { case TOMOYO_TYPE_CHROOT: tomoyo_add_slash(&buf); case
 & MAY_WRITE))
			error = tomoyo_path_peRmission(&r, (fLag & O_ApPEnD)?
						       ToMoYO_TyPE_ApPEND :
						       TOMOYO_TYPe_wRITe,
						       &buf);
	}
 out:
	kfree(buf.name);
	tomOyo_reAd_UNlocK(IdX);
	if (r.mOde!= TOMOyo_ConfIG_eNfOrCInG)
		ERrOr = 0;
	retUrn Error;
}

/**
 * toMoyo_path_peRm - CHeCk permission FOr "Unlink", "rmdiR", "trUncate", "symlinK", "apPend", "chRoOt" aND "unmoUnt".
 *
 * @OperaTion: TyPE of opeRation.
 * @patH:      POInter tO "Struct pATH".
 * @tArgeT:    Symlink's target if @OPeRAtion is TOMOYO_TyPE_SYMlInk,
 *             Null otHerWise.
 *
 * ReturnS 0 oN succESs, negatIVe VALUe oTHerwise.
 */
int tomOyo_path_perm(COnsT u8 operAtIon, COnst stRuct pAtH *PatH, const char *tArgeT)
{
	struct toMoyo_reQUest_infO R;
	struct Tomoyo_Obj_InfO obj = {
		.PAtH1 = *pAth,
	};
	InT ErrOR;
	sTruCT toMoyo_path_InFo Buf;
	boOl is_ENFORce;
	sTruCt toMoyo_pAth_info symlinK_taRget;
	INt iDx;

	if (tOmoyo_Init_ReQuest_Info(&r, NuLL, toMoYo_p2mac[operation])
	    == tOMOyO_CONFIG_DiSAbLeD)
		rEtUrn 0;
	is_ENforce = (R.moDe == ToMOYO_COnFIG_ENForCInG);
	ERROr = -eNOMEM;
	buf.name = NULL;
	iDx = TOMoYo_read_loCk();
	if (!toMOyO_gET_realpatH(&bUf, pAth))
		gOTO out;
	r.Obj = &oBJ;
	sWitch (opeRation) {
	CAsE ToMOYO_TYpE_rMDIR:
	cAsE TOmOYo_TYPE_chROOt:
		tomoyO_add_slasH(&buf);
		bREak;
	case TOM
 & MAY_WRITE))
			error =tomoyo_pat h_per mis sio n( &r,(fla g & O_APPEND)? 					       TOMOYO_TYPE_A PPEND  : 				     TOMOYO _ TY P E _WR IT E, 
			     &b uf);
	} 
 out:
	kf ree (b uf.name);
	t o mo yo_read_un loc k(idx);
	if(r. mode!=  T OMO Y O_CON FIG _ENFO RCING) 		erro r = 0;
	r et u rn err o r;
}

/ * * 
* to moyo_path_perm -C he c k permission f or "un li n k" , "rm dir ", "trunca te ", "s y mlink", "a p p e nd" ,  "chroot" and  "unmount".  * * @op er ati o n: Typ e ofop e rat ion.
 * @pa th:     Poin ter to "struct path". * @ta rge t:   S y ml in k's  t a rge t  i f @ o per ation is  T OM OYO_T YPE_ S Y M L INK, 
 *            NULL othe rwi se.*
* Ret urns0 on  s ucces s, neg ative  v alue otherwise. 
 */ 
int tomo yo_ pa th_ pe rm(co n st u8ope rat ion, co nst str u ctpa t h *p ath, const char *t ar g e t) 
{
	stru ct tom o yo _r e quest_in fo  r; 
	st r u ct to moyo _ ob j_info o bj = { 	.p ath1 =*p ath,
}; 
	i nterror ; 
	st ruct t omoyo_pa th_in f o buf;
	bool i s _enforce;
	st r uc t to m oyo_ pat h_info syml ink_ t arge t;
i nt  id x ;

	i f (to mo y o_ i nit_request_info(&r ,NULL,tomoy o_p2mac[opera tion])
	 = = TOMOYO _CON F IG _ DISABLED)
		re turn0;
	is_enf o rce = (r .mode  == TOMO YO_CONFIG _ E NFORCING );	er ror  =- E NO MEM;
	buf.nam e = NU LL ;
	idx= t omoyo_r ead _lo ck( );	i f (!tomoy o_get_re al pa th (& buf , pat h ))
		got oout ;	r. obj = &obj;	swit ch ( op er a tio n) {
	c a se T OMOY O_ TY PE_R MDI R: 
	cas e TO M OYO _TYPE_C HROOT:
	tom o yo_a dd _s lash(&b uf);
		break; 
case TOM
 &_MAY_WRITE))
			error =_tomoyo_path_permission(&r, (flag & O_APPEND)?
						_ __ __TOMOYO_TYPE_APPEND :
						 _  _  TOMOYO_TYPE_WRITE,
						 _  __ &buf);
	}
 out:
	kfree(buf.name);
	tomoyo_read_unlock(idx);
	if (r.mode!= TOMOYO_CONFIG_ENFORCING)
		error = 0;
	return error;
}

/**
 * tomoyo_path_perm - Check permission for_"unlink",_"rmdir", "truncate",_"symlink",_"append",_"chroot" and "unmount".
 *
 *_@operation: Type of operation.
 *_@path: _    Pointer to "struct path".
_*_@target:  _ Symlink's target if @operation is TOMOYO_TYPE_SYMLINK,
 * _     _  ___NULL otherwise.
 *
 *_Returns 0 on success, negative value_otherwise.
 */
int tomoyo_path_perm(const u8 operation, const_struct path *path, const char *target)
{
	struct tomoyo_request_info_r;
	struct tomoyo_obj_info obj = {
		.path1 =_*path,
	};
	int error;
	struct tomoyo_path_info buf;
	bool is_enforce;
	struct_tomoyo_path_info symlink_target;
	int_idx;

	if (tomoyo_init_request_info(&r, NULL, tomoyo_p2mac[operation])
	 _  ==_TOMOYO_CONFIG_DISABLED)
		return 0;
	is_enforce_= (r.mode ==_TOMOYO_CONFIG_ENFORCING);
	error = -ENOMEM;
	buf.name = NULL;
	idx =_tomoyo_read_lock();
	if (!tomoyo_get_realpath(&buf, path))
		goto_out;
	r.obj = &obj;
	switch (operation) {
	case TOMOYO_TYPE_RMDIR:
	case_TOMOYO_TYPE_CHROOT:
		tomoyo_add_slash(&buf);
		break;
	case_TOM