Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758808AbYAHKsj (ORCPT ); Tue, 8 Jan 2008 05:48:39 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754832AbYAHKpR (ORCPT ); Tue, 8 Jan 2008 05:45:17 -0500 Received: from ms0.nttdata.co.jp ([163.135.193.231]:42773 "EHLO ms0.nttdata.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754294AbYAHKov (ORCPT ); Tue, 8 Jan 2008 05:44:51 -0500 Message-Id: <20080108095001.626164600@nttdata.co.jp> References: <20080108094903.484613061@nttdata.co.jp> User-Agent: quilt/0.46-1 Date: Tue, 08 Jan 2008 18:49:14 +0900 From: Kentaro Takeda To: akpm@linux-foundation.org Cc: linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org, Kentaro Takeda , Tetsuo Handa Subject: [TOMOYO #6 11/21] File access control functions. X-OriginalArrivalTime: 08 Jan 2008 09:50:01.0881 (UTC) FILETIME=[D6855890:01C851DB] MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="boundary-1" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 52354 Lines: 687 --boundary-1 Content-Disposition: inline; filename="tomoyo-file.patch" Content-Type: application/octect-stream Content-Transfer-Encoding: base64 VE9NT1lPIExpbnV4IGNoZWNrcyBwZXJtaXNzaW9uIGluDQpvcGVuL2NyZWF0L3VubGluay90cnVu Y2F0ZS9mdHJ1bmNhdGUvbWtub2QvbWtkaXIvDQpybWRpci9zeW1saW5rL2xpbmsvcmVuYW1lL3Vz ZWxpYi9zeXNjdGwgLg0KDQpFYWNoIHBlcm1pc3Npb24gY2FuIGJlIGF1dG9tYXRpY2FsbHkgYWNj dW11bGF0ZWQgaW50bw0KdGhlIHBvbGljeSBvZiBlYWNoIGRvbWFpbiB1c2luZyAnbGVhcm5pbmcg bW9kZScuDQoNClNpZ25lZC1vZmYtYnk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uYW1lLA0KKwkJCQkgICAgc3RydWN0IGRv bWFpbl9pbmZvICogY29uc3QgZG9tYWluLA0KKwkJCQkgICAgY29uc3Qgc3RydWN0IGNvbmRpdGlv bl9saXN0ICpjb25kLA0KKwkJCQkgICAgY29uc3QgYm9vbCBpc19kZWxldGUpOw0KKw0KKy8qKioq KioqKioqKioqKioqKioqKioqKioqICBBVURJVCBGVU5DVElPTlMgICoqKioqKioqKioqKioqKioq KioqKioqKiovDQorDQorc3RhdGljIGludCB0bXlfYXVkaXRfZmlsZV9sb2coY29uc3Qgc3RydWN0 IHBhdGhfaW5mbyAqZmlsZW5hbWUsDQorCQkJICAgICAgY29uc3QgdTggcGVybSwNCisJCQkgICAg ICBjb25zdCBib29sIGlzX2dyYW50ZWQsDQorCQkJICAgICAgY29uc3QgdTggcHJvZmlsZSwNCisJ CQkgICAgICBjb25zdCB1bnNpZ25lZCBpbnQgbW9kZSkNCit7DQorCWNoYXIgKmJ1ZjsNCisJaW50 IGxlbjsNCisNCisJaWYgKGlzX2dyYW50ZWQpIHsNCisJCWlmICghdG15X2F1ZGl0X2dyYW50KCkp DQorCQkJcmV0dXJuIDA7DQorCX0gZWxzZSB7DQorCQlpZiAoIXRteV9hdWRpdF9yZWplY3QoKSkN CisJCQlyZXR1cm4gMDsNCisJfQ0KKw0KKwlsZW4gPSBmaWxlbmFtZS0+dG90YWxfbGVuICsgODsN CisJYnVmID0gdG15X2luaXRfYXVkaXRfbG9nKCZsZW4sIHByb2ZpbGUsIG1vZGUpOw0KKw0KKwlp ZiAoIWJ1ZikNCisJCXJldHVybiAtRU5PTUVNOw0KKw0KKwl0bXlfc25jYXRwcmludGYoYnVmLCBs ZW4gLSAxLCAiJWQgJXNcbiIsIHBlcm0sIGZpbGVuYW1lLT5uYW1lKTsNCisNCisJcmV0dXJuIHRt eV93cml0ZV9hdWRpdF9sb2coYnVmLCBpc19ncmFudGVkKTsNCit9DQorDQorc3RhdGljIGludCB0 bXlfYXVkaXRfd3JpdGVf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lpZiAoIWVycm9yKQ0K KwkJZ290byBvdXQ7DQorDQorCWlmICh0bXlfZmxhZ3MoVE1ZX1ZFUkJPU0UpKQ0KKwkJdG15X2F1 ZGl0KCJUT01PWU8tJXM6IEFjY2VzcyAnJXMgJXMgJXMnIGRlbmllZCBmb3IgJXNcbiIsDQorCQkJ ICB0bXlfZ2V0bXNnKGlzX2VuZm9yY2UpLA0KKwkJCSAgdG15X2FjbHR5cGUya2V5d29yZChvcGVy YXRpb24pLA0KKwkJCSAgYnVmMS0+bmFtZSwgYnVmMi0+bmFtZSwgdG15X2xhc3RuYW1lKGRvbWFp bikpOw0KKw0KKwlpZiAoaXNfZW5mb3JjZSkNCisJCWVycm9yID0gdG15X3N1cGVydmlzb3IoIiVz XG5hbGxvd18lcyAlcyAlc1xuIiwNCisJCQkJICAgICAgIGRvbWFpbi0+ZG9tYWlubmFtZS0+bmFt ZSwNCisJCQkJICAgICAgIHRteV9hY2x0eXBlMmtleXdvcmQob3BlcmF0aW9uKSwNCisJCQkJICAg ICAgIGJ1ZjEtPm5hbWUsIGJ1ZjItPm5hbWUpOw0KKwllbHNlIGlmIChtb2RlID09IDEgJiYgdG15 X3F1b3RhKCkpDQorCQl0bXlfYWRkX2RvdWJsZV93cml0ZV9hY2wob3BlcmF0aW9uLA0KKwkJCQkJ IHRteV9nZXRfcGF0dGVybihidWYxKS0+bmFtZSwNCisJCQkJCSB0bXlfZ2V0X3BhdHRlcm4oYnVm MiktPm5hbWUsDQorCQkJCQkgZG9tYWluLCBOVUxMLCAwKTsNCisNCitvdXQ6IDsNCisJdG15X2Zy ZWUoYnVmMSk7DQorCXRteV9mcmVlKGJ1ZjIpOw0KKwlpZiAoIWlzX2VuZm9yY2UpDQorCQllcnJv ciA9IDA7DQorCXJldHVybiBlcnJvcjsNCit9DQoNCi0tIA0K --boundary-1-- -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/