Getname flags

(버전 사이의 차이)
이동: 둘러보기, 찾기
(새 문서: * http://lxr.free-electrons.com/source/fs/namei.c#L133 <source lang="c"> 132 static struct filename * 133 getname_flags(const char __user *filename, int flags, int *empty) 134 { 135 ...)
 
10번째 줄: 10번째 줄:
 
138        char *kname;
 
138        char *kname;
 
139  
 
139  
140        result = audit_reusename(filename);
+
140        result = audit_reusename(filename); //fill out filename with info from existing entry
 
141        if (result)
 
141        if (result)
 
142                return result;
 
142                return result;

2014년 4월 30일 (수) 18:27 판

132 static struct filename *
133 getname_flags(const char __user *filename, int flags, int *empty)
134 {
135         struct filename *result, *err;
136         int len;
137         long max;
138         char *kname;
139 
140         result = audit_reusename(filename);  //fill out filename with info from existing entry
141         if (result)
142                 return result;
143 
144         result = __getname();
145         if (unlikely(!result))
146                 return ERR_PTR(-ENOMEM);
147 
148         /*
149          * First, try to embed the struct filename inside the names_cache
150          * allocation
151          */
152         kname = (char *)result + sizeof(*result);
153         result->name = kname;
154         result->separate = false;
155         max = EMBEDDED_NAME_MAX;
156 
157 recopy:
158         len = strncpy_from_user(kname, filename, max);
159         if (unlikely(len < 0)) {
160                 err = ERR_PTR(len);
161                 goto error;
162         }
163 
164         /*
165          * Uh-oh. We have a name that's approaching PATH_MAX. Allocate a
166          * separate struct filename so we can dedicate the entire
167          * names_cache allocation for the pathname, and re-do the copy from
168          * userland.
169          */
170         if (len == EMBEDDED_NAME_MAX && max == EMBEDDED_NAME_MAX) {
171                 kname = (char *)result;
172 
173                 result = kzalloc(sizeof(*result), GFP_KERNEL);
174                 if (!result) {
175                         err = ERR_PTR(-ENOMEM);
176                         result = (struct filename *)kname;
177                         goto error;
178                 }
179                 result->name = kname;
180                 result->separate = true;
181                 max = PATH_MAX;
182                 goto recopy;
183         }
184 
185         /* The empty path is special. */
186         if (unlikely(!len)) {
187                 if (empty)
188                         *empty = 1;
189                 err = ERR_PTR(-ENOENT);
190                 if (!(flags & LOOKUP_EMPTY))
191                         goto error;
192         }
193 
194         err = ERR_PTR(-ENAMETOOLONG);
195         if (unlikely(len >= PATH_MAX))
196                 goto error;
197 
198         result->uptr = filename;
199         result->aname = NULL;
200         audit_getname(result);
201         return result;
202 
203 error:
204         final_putname(result);
205         return err;
206 }
개인 도구
이름공간
변수
행위
둘러보기
구성원
연구
연구실
기타
도구모음
인쇄/내보내기