Merge branch 'linux-linaro-lsk-v4.4' into linux-linaro-lsk-v4.4-android
[firefly-linux-kernel-4.4.55.git] / fs / sdcardfs / multiuser.h
1 /*
2  * fs/sdcardfs/multiuser.h
3  *
4  * Copyright (c) 2013 Samsung Electronics Co. Ltd
5  *   Authors: Daeho Jeong, Woojoong Lee, Seunghwan Hyun,
6  *               Sunghwan Yun, Sungjong Seo
7  *
8  * This program has been developed as a stackable file system based on
9  * the WrapFS which written by
10  *
11  * Copyright (c) 1998-2011 Erez Zadok
12  * Copyright (c) 2009     Shrikar Archak
13  * Copyright (c) 2003-2011 Stony Brook University
14  * Copyright (c) 2003-2011 The Research Foundation of SUNY
15  *
16  * This file is dual licensed.  It may be redistributed and/or modified
17  * under the terms of the Apache 2.0 License OR version 2 of the GNU
18  * General Public License.
19  */
20
21 #define MULTIUSER_APP_PER_USER_RANGE 100000
22
23 typedef uid_t userid_t;
24 typedef uid_t appid_t;
25
26 static inline userid_t multiuser_get_user_id(uid_t uid) {
27     return uid / MULTIUSER_APP_PER_USER_RANGE;
28 }
29
30 static inline appid_t multiuser_get_app_id(uid_t uid) {
31     return uid % MULTIUSER_APP_PER_USER_RANGE;
32 }
33
34 static inline uid_t multiuser_get_uid(userid_t userId, appid_t appId) {
35     return userId * MULTIUSER_APP_PER_USER_RANGE + (appId % MULTIUSER_APP_PER_USER_RANGE);
36 }
37