1 /*
2 * fs/sdcardfs/sdcardfs.h
3 *
4 * The sdcardfs v2.0
5 * This file system replaces the sdcard daemon on Android
6 * On version 2.0, some of the daemon functions have been ported
7 * to support the multi-user concepts of Android 4.4
8 *
9 * Copyright (c) 2013 Samsung Electronics Co. Ltd
10 * Authors: Daeho Jeong, Woojoong Lee, Seunghwan Hyun,
11 * Sunghwan Yun, Sungjong Seo
12 *
13 * This program has been developed as a stackable file system based on
14 * the WrapFS which written by
15 *
16 * Copyright (c) 1998-2011 Erez Zadok
17 * Copyright (c) 2009 Shrikar Archak
18 * Copyright (c) 2003-2011 Stony Brook University
19 * Copyright (c) 2003-2011 The Research Foundation of SUNY
20 *
21 * This file is dual licensed. It may be redistributed and/or modified
22 * under the terms of the Apache 2.0 License OR version 2 of the GNU
23 * General Public License.
24 */
25
26 #ifndef _SDCARDFS_H_
27 #define _SDCARDFS_H_
28
29 #include <linux/dcache.h>
30 #include <linux/file.h>
31 #include <linux/fs.h>
32 #include <linux/aio.h>
33 #include <linux/kref.h>
34 #include <linux/mm.h>
35 #include <linux/mount.h>
36 #include <linux/namei.h>
37 #include <linux/seq_file.h>
38 #include <linux/statfs.h>
39 #include <linux/fs_stack.h>
40 #include <linux/magic.h>
41 #include <linux/uaccess.h>
42 #include <linux/slab.h>
43 #include <linux/sched.h>
44 #include <linux/types.h>
45 #include <linux/security.h>
46 #include <linux/string.h>
47 #include <linux/list.h>
48 #include <linux/iversion.h>
49 #include <uapi/linux/mount.h>
50 #include "multiuser.h"
51
52 /* the file system name */
53 #define SDCARDFS_NAME "sdcardfs"
54
55 /* sdcardfs root inode number */
56 #define SDCARDFS_ROOT_INO 1
57
58 /* useful for tracking code reachability */
59 #define UDBG pr_default("DBG:%s:%s:%d\n", __FILE__, __func__, __LINE__)
60
61 #define SDCARDFS_DIRENT_SIZE 256
62
63 /* temporary static uid settings for development */
64 #define AID_ROOT 0 /* uid for accessing /mnt/sdcard & extSdcard */
65 #define AID_MEDIA_RW 1023 /* internal media storage write access */
66
67 #define AID_SDCARD_RW 1015 /* external storage write access */
68 #define AID_SDCARD_R 1028 /* external storage read access */
69 #define AID_SDCARD_PICS 1033 /* external storage photos access */
70 #define AID_SDCARD_AV 1034 /* external storage audio/video access */
71 #define AID_SDCARD_ALL 1035 /* access all users external storage */
72 #define AID_MEDIA_OBB 1059 /* obb files */
73
74 #define AID_SDCARD_IMAGE 1057
75
76 #define AID_PACKAGE_INFO 1027
77
78
79 /*
80 * Permissions are handled by our permission function.
81 * We don't want anyone who happens to look at our inode value to prematurely
82 * block access, so store more permissive values. These are probably never
83 * used.
84 */
85 #define fixup_tmp_permissions(x) \
86 do { \
87 (x)->i_uid = make_kuid(&init_user_ns, \
88 SDCARDFS_I(x)->data->d_uid); \
89 (x)->i_gid = make_kgid(&init_user_ns, AID_SDCARD_RW); \
90 (x)->i_mode = ((x)->i_mode & S_IFMT) | 0775;\
91 } while (0)
92
93 /* Android 5.0 support */
94
95 /* Permission mode for a specific node. Controls how file permissions
96 * are derived for children nodes.
97 */
98 typedef enum {
99 /* Nothing special; this node should just inherit from its parent. */
100 PERM_INHERIT,
101 /* This node is one level above a normal root; used for legacy layouts
102 * which use the first level to represent user_id.
103 */
104 PERM_PRE_ROOT,
105 /* This node is "/" */
106 PERM_ROOT,
107 /* This node is "/Android" */
108 PERM_ANDROID,
109 /* This node is "/Android/data" */
110 PERM_ANDROID_DATA,
111 /* This node is "/Android/obb" */
112 PERM_ANDROID_OBB,
113 /* This node is "/Android/media" */
114 PERM_ANDROID_MEDIA,
115 /* This node is "/Android/[data|media|obb]/[package]" */
116 PERM_ANDROID_PACKAGE,
117 /* This node is "/Android/[data|media|obb]/[package]/cache" */
118 PERM_ANDROID_PACKAGE_CACHE,
119 } perm_t;
120
121 struct sdcardfs_sb_info;
122 struct sdcardfs_mount_options;
123 struct sdcardfs_inode_info;
124 struct sdcardfs_inode_data;
125
126 /* Do not directly use this function. Use OVERRIDE_CRED() instead. */
127 const struct cred *override_fsids(struct sdcardfs_sb_info *sbi,
128 struct sdcardfs_inode_data *data);
129 /* Do not directly use this function, use REVERT_CRED() instead. */
130 void revert_fsids(const struct cred *old_cred);
131
132 /* operations vectors defined in specific files */
133 extern const struct file_operations sdcardfs_main_fops;
134 extern const struct file_operations sdcardfs_dir_fops;
135 extern const struct inode_operations sdcardfs_main_iops;
136 extern const struct inode_operations sdcardfs_dir_iops;
137 extern const struct inode_operations sdcardfs_symlink_iops;
138 extern const struct super_operations sdcardfs_sops;
139 extern const struct dentry_operations sdcardfs_ci_dops;
140 extern const struct address_space_operations sdcardfs_aops, sdcardfs_dummy_aops;
141 extern const struct vm_operations_struct sdcardfs_vm_ops;
142
143 extern int sdcardfs_init_inode_cache(void);
144 extern void sdcardfs_destroy_inode_cache(void);
145 extern int sdcardfs_init_dentry_cache(void);
146 extern void sdcardfs_destroy_dentry_cache(void);
147 extern int new_dentry_private_data(struct dentry *dentry);
148 extern void free_dentry_private_data(struct dentry *dentry);
149 extern struct dentry *sdcardfs_lookup(struct inode *dir, struct dentry *dentry,
150 unsigned int flags);
151 extern struct inode *sdcardfs_iget(struct super_block *sb,
152 struct inode *lower_inode, userid_t id);
153 extern int sdcardfs_interpose(struct dentry *dentry, struct super_block *sb,
154 struct path *lower_path, userid_t id);
155 extern int sdcardfs_on_fscrypt_key_removed(struct notifier_block *nb,
156 unsigned long action, void *data);
157
158 /* file private data */
159 struct sdcardfs_file_info {
160 struct file *lower_file;
161 const struct vm_operations_struct *lower_vm_ops;
162 };
163
164 struct sdcardfs_inode_data {
165 struct kref refcount;
166 bool abandoned;
167
168 perm_t perm;
169 userid_t userid;
170 uid_t d_uid;
171 bool under_android;
172 bool under_cache;
173 bool under_obb;
174 };
175
176 /* sdcardfs inode data in memory */
177 struct sdcardfs_inode_info {
178 struct inode *lower_inode;
179 /* state derived based on current position in hierarchy */
180 struct sdcardfs_inode_data *data;
181
182 /* top folder for ownership */
183 spinlock_t top_lock;
184 struct sdcardfs_inode_data *top_data;
185
186 struct inode vfs_inode;
187 };
188
189
190 /* sdcardfs dentry data in memory */
191 struct sdcardfs_dentry_info {
192 spinlock_t lock; /* protects lower_path */
193 struct path lower_path;
194 struct path orig_path;
195 };
196
197 struct sdcardfs_mount_options {
198 uid_t fs_low_uid;
199 gid_t fs_low_gid;
200 userid_t fs_user_id;
201 bool multiuser;
202 bool gid_derivation;
203 bool default_normal;
204 bool unshared_obb;
205 unsigned int reserved_mb;
206 bool nocache;
207 bool debug;
208 };
209
210 struct sdcardfs_vfsmount_options {
211 gid_t gid;
212 mode_t mask;
213 };
214
215 struct sdcardfs_context_options {
216 struct sdcardfs_mount_options opts;
217 struct sdcardfs_vfsmount_options vfsopts;
218 };
219
220 extern int parse_options_remount(struct super_block *sb, char *options, int silent,
221 struct sdcardfs_vfsmount_options *vfsopts);
222
223 /* sdcardfs super-block data in memory */
224 struct sdcardfs_sb_info {
225 struct super_block *sb;
226 struct super_block *lower_sb;
227 /* derived perm policy : some of options have been added
228 * to sdcardfs_mount_options (Android 4.4 support)
229 */
230 struct sdcardfs_mount_options options;
231 spinlock_t lock; /* protects obbpath */
232 char *obbpath_s;
233 struct path obbpath;
234 void *pkgl_id;
235 struct list_head list;
236 struct notifier_block fscrypt_nb;
237 };
238
239 /*
240 * inode to private data
241 *
242 * Since we use containers and the struct inode is _inside_ the
243 * sdcardfs_inode_info structure, SDCARDFS_I will always (given a non-NULL
244 * inode pointer), return a valid non-NULL pointer.
245 */
SDCARDFS_I(const struct inode * inode)246 static inline struct sdcardfs_inode_info *SDCARDFS_I(const struct inode *inode)
247 {
248 return container_of(inode, struct sdcardfs_inode_info, vfs_inode);
249 }
250
251 /* dentry to private data */
252 #define SDCARDFS_D(dent) ((struct sdcardfs_dentry_info *)(dent)->d_fsdata)
253
254 /* superblock to private data */
255 #define SDCARDFS_SB(super) ((struct sdcardfs_sb_info *)(super)->s_fs_info)
256
257 /* file to private Data */
258 #define SDCARDFS_F(file) ((struct sdcardfs_file_info *)((file)->private_data))
259
260 /* file to lower file */
sdcardfs_lower_file(const struct file * f)261 static inline struct file *sdcardfs_lower_file(const struct file *f)
262 {
263 return SDCARDFS_F(f)->lower_file;
264 }
265
sdcardfs_set_lower_file(struct file * f,struct file * val)266 static inline void sdcardfs_set_lower_file(struct file *f, struct file *val)
267 {
268 SDCARDFS_F(f)->lower_file = val;
269 }
270
271 /* inode to lower inode. */
sdcardfs_lower_inode(const struct inode * i)272 static inline struct inode *sdcardfs_lower_inode(const struct inode *i)
273 {
274 return SDCARDFS_I(i)->lower_inode;
275 }
276
sdcardfs_set_lower_inode(struct inode * i,struct inode * val)277 static inline void sdcardfs_set_lower_inode(struct inode *i, struct inode *val)
278 {
279 SDCARDFS_I(i)->lower_inode = val;
280 }
281
282 /* superblock to lower superblock */
sdcardfs_lower_super(const struct super_block * sb)283 static inline struct super_block *sdcardfs_lower_super(
284 const struct super_block *sb)
285 {
286 return SDCARDFS_SB(sb)->lower_sb;
287 }
288
sdcardfs_set_lower_super(struct super_block * sb,struct super_block * val)289 static inline void sdcardfs_set_lower_super(struct super_block *sb,
290 struct super_block *val)
291 {
292 SDCARDFS_SB(sb)->lower_sb = val;
293 }
294
295 /* path based (dentry/mnt) macros */
pathcpy(struct path * dst,const struct path * src)296 static inline void pathcpy(struct path *dst, const struct path *src)
297 {
298 dst->dentry = src->dentry;
299 dst->mnt = src->mnt;
300 }
301
302 /* sdcardfs_get_pname functions calls path_get()
303 * therefore, the caller must call "proper" path_put functions
304 */
305 #define SDCARDFS_DENT_FUNC(pname) \
306 static inline void sdcardfs_get_##pname(const struct dentry *dent, \
307 struct path *pname) \
308 { \
309 spin_lock(&SDCARDFS_D(dent)->lock); \
310 pathcpy(pname, &SDCARDFS_D(dent)->pname); \
311 path_get(pname); \
312 spin_unlock(&SDCARDFS_D(dent)->lock); \
313 return; \
314 } \
315 static inline void sdcardfs_put_##pname(const struct dentry *dent, \
316 struct path *pname) \
317 { \
318 path_put(pname); \
319 return; \
320 } \
321 static inline void sdcardfs_set_##pname(const struct dentry *dent, \
322 struct path *pname) \
323 { \
324 spin_lock(&SDCARDFS_D(dent)->lock); \
325 pathcpy(&SDCARDFS_D(dent)->pname, pname); \
326 spin_unlock(&SDCARDFS_D(dent)->lock); \
327 return; \
328 } \
329 static inline void sdcardfs_reset_##pname(const struct dentry *dent) \
330 { \
331 spin_lock(&SDCARDFS_D(dent)->lock); \
332 SDCARDFS_D(dent)->pname.dentry = NULL; \
333 SDCARDFS_D(dent)->pname.mnt = NULL; \
334 spin_unlock(&SDCARDFS_D(dent)->lock); \
335 return; \
336 } \
337 static inline void sdcardfs_put_reset_##pname(const struct dentry *dent) \
338 { \
339 struct path pname; \
340 spin_lock(&SDCARDFS_D(dent)->lock); \
341 if (SDCARDFS_D(dent)->pname.dentry) { \
342 pathcpy(&pname, &SDCARDFS_D(dent)->pname); \
343 SDCARDFS_D(dent)->pname.dentry = NULL; \
344 SDCARDFS_D(dent)->pname.mnt = NULL; \
345 spin_unlock(&SDCARDFS_D(dent)->lock); \
346 path_put(&pname); \
347 } else \
348 spin_unlock(&SDCARDFS_D(dent)->lock); \
349 return; \
350 }
351
352 SDCARDFS_DENT_FUNC(lower_path)
SDCARDFS_DENT_FUNC(orig_path)353 SDCARDFS_DENT_FUNC(orig_path)
354
355 static inline bool sbinfo_has_sdcard_magic(struct sdcardfs_sb_info *sbinfo)
356 {
357 return sbinfo && sbinfo->sb
358 && sbinfo->sb->s_magic == SDCARDFS_SUPER_MAGIC;
359 }
360
data_get(struct sdcardfs_inode_data * data)361 static inline struct sdcardfs_inode_data *data_get(
362 struct sdcardfs_inode_data *data)
363 {
364 if (data)
365 kref_get(&data->refcount);
366 return data;
367 }
368
top_data_get(struct sdcardfs_inode_info * info)369 static inline struct sdcardfs_inode_data *top_data_get(
370 struct sdcardfs_inode_info *info)
371 {
372 struct sdcardfs_inode_data *top_data;
373
374 spin_lock(&info->top_lock);
375 top_data = data_get(info->top_data);
376 spin_unlock(&info->top_lock);
377 return top_data;
378 }
379
380 extern void data_release(struct kref *ref);
381
data_put(struct sdcardfs_inode_data * data)382 static inline void data_put(struct sdcardfs_inode_data *data)
383 {
384 kref_put(&data->refcount, data_release);
385 }
386
release_own_data(struct sdcardfs_inode_info * info)387 static inline void release_own_data(struct sdcardfs_inode_info *info)
388 {
389 /*
390 * This happens exactly once per inode. At this point, the inode that
391 * originally held this data is about to be freed, and all references
392 * to it are held as a top value, and will likely be released soon.
393 */
394 info->data->abandoned = true;
395 data_put(info->data);
396 }
397
set_top(struct sdcardfs_inode_info * info,struct sdcardfs_inode_info * top_owner)398 static inline void set_top(struct sdcardfs_inode_info *info,
399 struct sdcardfs_inode_info *top_owner)
400 {
401 struct sdcardfs_inode_data *old_top;
402 struct sdcardfs_inode_data *new_top = NULL;
403
404 if (top_owner)
405 new_top = top_data_get(top_owner);
406
407 spin_lock(&info->top_lock);
408 old_top = info->top_data;
409 info->top_data = new_top;
410 if (old_top)
411 data_put(old_top);
412 spin_unlock(&info->top_lock);
413 }
414
get_gid(struct vfsmount * mnt,struct super_block * sb,struct sdcardfs_inode_data * data)415 static inline int get_gid(struct vfsmount *mnt,
416 struct super_block *sb,
417 struct sdcardfs_inode_data *data)
418 {
419 struct sdcardfs_vfsmount_options *vfsopts = mnt->data;
420 struct sdcardfs_sb_info *sbi = SDCARDFS_SB(sb);
421
422 if (vfsopts->gid == AID_SDCARD_RW && !sbi->options.default_normal)
423 /* As an optimization, certain trusted system components only run
424 * as owner but operate across all users. Since we're now handing
425 * out the sdcard_rw GID only to trusted apps, we're okay relaxing
426 * the user boundary enforcement for the default view. The UIDs
427 * assigned to app directories are still multiuser aware.
428 */
429 return AID_SDCARD_RW;
430 else
431 return multiuser_get_uid(data->userid, vfsopts->gid);
432 }
433
get_mode(struct vfsmount * mnt,struct sdcardfs_inode_info * info,struct sdcardfs_inode_data * data)434 static inline int get_mode(struct vfsmount *mnt,
435 struct sdcardfs_inode_info *info,
436 struct sdcardfs_inode_data *data)
437 {
438 int owner_mode;
439 int filtered_mode;
440 struct sdcardfs_vfsmount_options *opts = mnt->data;
441 int visible_mode = 0775 & ~opts->mask;
442
443
444 if (data->perm == PERM_PRE_ROOT) {
445 /* Top of multi-user view should always be visible to ensure
446 * secondary users can traverse inside.
447 */
448 visible_mode = 0711;
449 } else if (data->under_android) {
450 /* Block "other" access to Android directories, since only apps
451 * belonging to a specific user should be in there; we still
452 * leave +x open for the default view.
453 */
454 if (opts->gid == AID_SDCARD_RW)
455 visible_mode = visible_mode & ~0006;
456 else
457 visible_mode = visible_mode & ~0007;
458 }
459 owner_mode = info->lower_inode->i_mode & 0700;
460 filtered_mode = visible_mode & (owner_mode | (owner_mode >> 3) | (owner_mode >> 6));
461 return filtered_mode;
462 }
463
has_graft_path(const struct dentry * dent)464 static inline int has_graft_path(const struct dentry *dent)
465 {
466 int ret = 0;
467
468 spin_lock(&SDCARDFS_D(dent)->lock);
469 if (SDCARDFS_D(dent)->orig_path.dentry != NULL)
470 ret = 1;
471 spin_unlock(&SDCARDFS_D(dent)->lock);
472
473 return ret;
474 }
475
sdcardfs_get_real_lower(const struct dentry * dent,struct path * real_lower)476 static inline void sdcardfs_get_real_lower(const struct dentry *dent,
477 struct path *real_lower)
478 {
479 /* in case of a local obb dentry
480 * the orig_path should be returned
481 */
482 if (has_graft_path(dent))
483 sdcardfs_get_orig_path(dent, real_lower);
484 else
485 sdcardfs_get_lower_path(dent, real_lower);
486 }
487
sdcardfs_put_real_lower(const struct dentry * dent,struct path * real_lower)488 static inline void sdcardfs_put_real_lower(const struct dentry *dent,
489 struct path *real_lower)
490 {
491 if (has_graft_path(dent))
492 sdcardfs_put_orig_path(dent, real_lower);
493 else
494 sdcardfs_put_lower_path(dent, real_lower);
495 }
496
497 extern struct mutex sdcardfs_super_list_lock;
498 extern struct list_head sdcardfs_super_list;
499
500 /* for packagelist.c */
501 extern appid_t get_appid(const char *app_name);
502 extern appid_t get_ext_gid(const char *app_name);
503 extern appid_t is_excluded(const char *app_name, userid_t userid);
504 extern int check_caller_access_to_name(struct inode *parent_node, const struct qstr *name);
505 extern int packagelist_init(void);
506 extern void packagelist_exit(void);
507
508 /* for derived_perm.c */
509 #define BY_NAME (1 << 0)
510 #define BY_USERID (1 << 1)
511 struct limit_search {
512 unsigned int flags;
513 struct qstr name;
514 userid_t userid;
515 };
516
517 extern void setup_derived_state(struct inode *inode, perm_t perm,
518 userid_t userid, uid_t uid);
519 extern void get_derived_permission(struct dentry *parent, struct dentry *dentry);
520 extern void get_derived_permission_new(struct dentry *parent, struct dentry *dentry, const struct qstr *name);
521 extern void fixup_perms_recursive(struct dentry *dentry, struct limit_search *limit);
522
523 extern void update_derived_permission_lock(struct dentry *dentry);
524 void fixup_lower_ownership(struct dentry *dentry, const char *name);
525 extern int need_graft_path(struct dentry *dentry);
526 extern int is_base_obbpath(struct dentry *dentry);
527 extern int is_obbpath_invalid(struct dentry *dentry);
528 extern int setup_obb_dentry(struct dentry *dentry, struct path *lower_path);
529
530 /* locking helpers */
lock_parent(struct dentry * dentry)531 static inline struct dentry *lock_parent(struct dentry *dentry)
532 {
533 struct dentry *dir = dget_parent(dentry);
534
535 inode_lock_nested(d_inode(dir), I_MUTEX_PARENT);
536 return dir;
537 }
538
unlock_dir(struct dentry * dir)539 static inline void unlock_dir(struct dentry *dir)
540 {
541 inode_unlock(d_inode(dir));
542 dput(dir);
543 }
544
prepare_dir(const char * path_s,uid_t uid,gid_t gid,mode_t mode)545 static inline int prepare_dir(const char *path_s, uid_t uid, gid_t gid, mode_t mode)
546 {
547 int err;
548 struct dentry *dent;
549 struct iattr attrs;
550 struct path parent;
551
552 dent = kern_path_locked(path_s, &parent);
553 if (IS_ERR(dent)) {
554 err = PTR_ERR(dent);
555 if (err == -EEXIST)
556 err = 0;
557 goto out_unlock;
558 }
559
560 err = vfs_mkdir2(parent.mnt, d_inode(parent.dentry), dent, mode);
561 if (err) {
562 if (err == -EEXIST)
563 err = 0;
564 goto out_dput;
565 }
566
567 attrs.ia_uid = make_kuid(&init_user_ns, uid);
568 attrs.ia_gid = make_kgid(&init_user_ns, gid);
569 attrs.ia_valid = ATTR_UID | ATTR_GID;
570 inode_lock(d_inode(dent));
571 notify_change2(parent.mnt, dent, &attrs, NULL);
572 inode_unlock(d_inode(dent));
573
574 out_dput:
575 dput(dent);
576
577 out_unlock:
578 /* parent dentry locked by lookup_create */
579 inode_unlock(d_inode(parent.dentry));
580 path_put(&parent);
581 return err;
582 }
583
584 /*
585 * Return 1, if a disk has enough free space, otherwise 0.
586 * We assume that any files can not be overwritten.
587 */
check_min_free_space(struct dentry * dentry,size_t size,int dir)588 static inline int check_min_free_space(struct dentry *dentry, size_t size, int dir)
589 {
590 int err;
591 struct path lower_path;
592 struct kstatfs statfs;
593 u64 avail;
594 struct sdcardfs_sb_info *sbi = SDCARDFS_SB(dentry->d_sb);
595
596 if (sbi->options.reserved_mb) {
597 /* Get fs stat of lower filesystem. */
598 sdcardfs_get_lower_path(dentry, &lower_path);
599 err = vfs_statfs(&lower_path, &statfs);
600 sdcardfs_put_lower_path(dentry, &lower_path);
601
602 if (unlikely(err))
603 return 0;
604
605 /* Invalid statfs informations. */
606 if (unlikely(statfs.f_bsize == 0))
607 return 0;
608
609 /* if you are checking directory, set size to f_bsize. */
610 if (unlikely(dir))
611 size = statfs.f_bsize;
612
613 /* available size */
614 avail = statfs.f_bavail * statfs.f_bsize;
615
616 /* not enough space */
617 if ((u64)size > avail)
618 return 0;
619
620 /* enough space */
621 if ((avail - size) > (sbi->options.reserved_mb * 1024 * 1024))
622 return 1;
623
624 return 0;
625 } else
626 return 1;
627 }
628
629 /*
630 * Copies attrs and maintains sdcardfs managed attrs
631 * Since our permission check handles all special permissions, set those to be open
632 */
sdcardfs_copy_and_fix_attrs(struct inode * dest,const struct inode * src)633 static inline void sdcardfs_copy_and_fix_attrs(struct inode *dest, const struct inode *src)
634 {
635 dest->i_mode = (src->i_mode & S_IFMT) | S_IRWXU | S_IRWXG |
636 S_IROTH | S_IXOTH; /* 0775 */
637 dest->i_uid = make_kuid(&init_user_ns, SDCARDFS_I(dest)->data->d_uid);
638 dest->i_gid = make_kgid(&init_user_ns, AID_SDCARD_RW);
639 dest->i_rdev = src->i_rdev;
640 dest->i_atime = src->i_atime;
641 dest->i_mtime = src->i_mtime;
642 dest->i_ctime = src->i_ctime;
643 dest->i_blkbits = src->i_blkbits;
644 dest->i_flags = src->i_flags;
645 set_nlink(dest, src->i_nlink);
646 }
647
str_case_eq(const char * s1,const char * s2)648 static inline bool str_case_eq(const char *s1, const char *s2)
649 {
650 return !strcasecmp(s1, s2);
651 }
652
str_n_case_eq(const char * s1,const char * s2,size_t len)653 static inline bool str_n_case_eq(const char *s1, const char *s2, size_t len)
654 {
655 return !strncasecmp(s1, s2, len);
656 }
657
qstr_case_eq(const struct qstr * q1,const struct qstr * q2)658 static inline bool qstr_case_eq(const struct qstr *q1, const struct qstr *q2)
659 {
660 return q1->len == q2->len && str_n_case_eq(q1->name, q2->name, q2->len);
661 }
662
663 #define QSTR_LITERAL(string) QSTR_INIT(string, sizeof(string)-1)
664
665 #endif /* not _SDCARDFS_H_ */
666