• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 Institute of Parallel And Distributed Systems (IPADS), Shanghai Jiao Tong University (SJTU)
3  * Licensed under the Mulan PSL v2.
4  * You can use this software according to the terms and conditions of the Mulan PSL v2.
5  * You may obtain a copy of Mulan PSL v2 at:
6  *     http://license.coscl.org.cn/MulanPSL2
7  * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
8  * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
9  * PURPOSE.
10  * See the Mulan PSL v2 for more details.
11  */
12 #ifndef TMPFS_NAMEI_H
13 #define TMPFS_NAMEI_H
14 
15 #include "defs.h"
16 
17 #define MAX_STACK_SIZE 3 /* Maximum number of nested symlinks */
18 #define MAX_SYM_CNT    10 /* Maximum number of symlinks in a lookup */
19 
20 /* nd->flags flags */
21 #define ND_FOLLOW         0x0001 /* follow links at the end */
22 #define ND_DIRECTORY      0x0002 /* require a directory */
23 #define ND_EMPTY          0x0004 /* accept empty path */
24 #define ND_NO_SYMLINKS    0x0008 /* no symlinks during the walk */
25 #define ND_TRAILING_SLASH 0x0010 /* the path ends with one or more slashes */
26 
27 struct nameidata {
28     struct dentry *current;
29     struct string last;
30     unsigned int flags;
31     int last_type; /* LAST_NORM, LAST_DOT, LAST_DOTDOT */
32     unsigned depth;
33     int total_link_count;
34     const char *stack[MAX_STACK_SIZE]; /* saved pathname when handling
35                                           symlinks */
36 };
37 
38 int path_parentat(struct nameidata *nd, const char *name, unsigned flags,
39                   struct dentry **parent);
40 int path_lookupat(struct nameidata *nd, const char *name, unsigned flags,
41                   struct dentry **dentry);
42 int path_openat(struct nameidata *nd, const char *name, unsigned open_flags,
43                 unsigned flags, struct dentry **dentry);
44 
45 #endif /* TMPFS_NAMEI_H */