Whamcloud - gitweb
LU-6158 mdt: always shrink_capsule in getxattr_all
[fs/lustre-release.git] / lustre / llite / xattr.c
1 /*
2  * GPL HEADER START
3  *
4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 only,
8  * as published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * General Public License version 2 for more details (a copy is included
14  * in the LICENSE file that accompanied this code).
15  *
16  * You should have received a copy of the GNU General Public License
17  * version 2 along with this program; If not, see
18  * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
19  *
20  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
21  * CA 95054 USA or visit www.sun.com if you need additional information or
22  * have any questions.
23  *
24  * GPL HEADER END
25  */
26 /*
27  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
28  * Use is subject to license terms.
29  *
30  * Copyright (c) 2011, 2014, Intel Corporation.
31  */
32 /*
33  * This file is part of Lustre, http://www.lustre.org/
34  * Lustre is a trademark of Sun Microsystems, Inc.
35  */
36
37 #include <linux/fs.h>
38 #include <linux/sched.h>
39 #include <linux/mm.h>
40 #include <linux/selinux.h>
41
42 #define DEBUG_SUBSYSTEM S_LLITE
43
44 #include <obd_support.h>
45 #include <lustre_dlm.h>
46 #include <lustre_ver.h>
47 #include <lustre_eacl.h>
48
49 #include "llite_internal.h"
50
51 #define XATTR_USER_T            (1)
52 #define XATTR_TRUSTED_T         (2)
53 #define XATTR_SECURITY_T        (3)
54 #define XATTR_ACL_ACCESS_T      (4)
55 #define XATTR_ACL_DEFAULT_T     (5)
56 #define XATTR_LUSTRE_T          (6)
57 #define XATTR_OTHER_T           (7)
58
59 static
60 int get_xattr_type(const char *name)
61 {
62         if (!strcmp(name, POSIX_ACL_XATTR_ACCESS))
63                 return XATTR_ACL_ACCESS_T;
64
65         if (!strcmp(name, POSIX_ACL_XATTR_DEFAULT))
66                 return XATTR_ACL_DEFAULT_T;
67
68         if (!strncmp(name, XATTR_USER_PREFIX,
69                      sizeof(XATTR_USER_PREFIX) - 1))
70                 return XATTR_USER_T;
71
72         if (!strncmp(name, XATTR_TRUSTED_PREFIX,
73                      sizeof(XATTR_TRUSTED_PREFIX) - 1))
74                 return XATTR_TRUSTED_T;
75
76         if (!strncmp(name, XATTR_SECURITY_PREFIX,
77                      sizeof(XATTR_SECURITY_PREFIX) - 1))
78                 return XATTR_SECURITY_T;
79
80         if (!strncmp(name, XATTR_LUSTRE_PREFIX,
81                      sizeof(XATTR_LUSTRE_PREFIX) - 1))
82                 return XATTR_LUSTRE_T;
83
84         return XATTR_OTHER_T;
85 }
86
87 static
88 int xattr_type_filter(struct ll_sb_info *sbi, int xattr_type)
89 {
90         if ((xattr_type == XATTR_ACL_ACCESS_T ||
91              xattr_type == XATTR_ACL_DEFAULT_T) &&
92            !(sbi->ll_flags & LL_SBI_ACL))
93                 return -EOPNOTSUPP;
94
95         if (xattr_type == XATTR_USER_T && !(sbi->ll_flags & LL_SBI_USER_XATTR))
96                 return -EOPNOTSUPP;
97         if (xattr_type == XATTR_TRUSTED_T && !cfs_capable(CFS_CAP_SYS_ADMIN))
98                 return -EPERM;
99         if (xattr_type == XATTR_OTHER_T)
100                 return -EOPNOTSUPP;
101
102         return 0;
103 }
104
105 /* xattr related to IMA(Integrity Measurement Architecture) */
106 #ifndef XATTR_NAME_IMA
107 #define XATTR_NAME_IMA          "security.ima"
108 #define XATTR_NAME_EVM          "security.evm"
109 #endif
110
111 static
112 int ll_setxattr_common(struct inode *inode, const char *name,
113                        const void *value, size_t size,
114                        int flags, __u64 valid)
115 {
116         struct ll_sb_info *sbi = ll_i2sbi(inode);
117         struct ptlrpc_request *req = NULL;
118         int xattr_type, rc;
119         posix_acl_xattr_header *new_value = NULL;
120         struct rmtacl_ctl_entry *rce = NULL;
121         ext_acl_xattr_header *acl = NULL;
122         const char *pv = value;
123         ENTRY;
124
125         /*FIXME: enable IMA when the conditions are ready */
126         if (strncmp(name, XATTR_NAME_IMA,
127                     sizeof(XATTR_NAME_IMA)) == 0 ||
128             strncmp(name, XATTR_NAME_EVM,
129                     sizeof(XATTR_NAME_EVM)) == 0)
130                 return -EOPNOTSUPP;
131
132         xattr_type = get_xattr_type(name);
133         rc = xattr_type_filter(sbi, xattr_type);
134         if (rc)
135                 RETURN(rc);
136
137         if ((xattr_type == XATTR_ACL_ACCESS_T ||
138              xattr_type == XATTR_ACL_DEFAULT_T) &&
139 #ifdef HAVE_INODE_OWNER_OR_CAPABLE
140             !inode_owner_or_capable(inode))
141 #else
142             !is_owner_or_cap(inode))
143 #endif
144                 return -EPERM;
145
146         /* b10667: ignore lustre special xattr for now */
147         if ((xattr_type == XATTR_TRUSTED_T && strcmp(name, "trusted.lov") == 0) ||
148             (xattr_type == XATTR_LUSTRE_T && strcmp(name, "lustre.lov") == 0))
149                 RETURN(0);
150
151         /* b15587: ignore security.capability xattr for now */
152         if ((xattr_type == XATTR_SECURITY_T &&
153             strcmp(name, "security.capability") == 0))
154                 RETURN(0);
155
156         /* LU-549:  Disable security.selinux when selinux is disabled */
157         if (xattr_type == XATTR_SECURITY_T && !selinux_is_enabled() &&
158             strcmp(name, "security.selinux") == 0)
159                 RETURN(-EOPNOTSUPP);
160
161 #ifdef CONFIG_FS_POSIX_ACL
162         if (sbi->ll_flags & LL_SBI_RMT_CLIENT &&
163             (xattr_type == XATTR_ACL_ACCESS_T ||
164             xattr_type == XATTR_ACL_DEFAULT_T)) {
165                 rce = rct_search(&sbi->ll_rct, current_pid());
166                 if (rce == NULL ||
167                     (rce->rce_ops != RMT_LSETFACL &&
168                     rce->rce_ops != RMT_RSETFACL))
169                         RETURN(-EOPNOTSUPP);
170
171                 if (rce->rce_ops == RMT_LSETFACL) {
172                         struct eacl_entry *ee;
173
174                         ee = et_search_del(&sbi->ll_et, current_pid(),
175                                            ll_inode2fid(inode), xattr_type);
176                         LASSERT(ee != NULL);
177                         if (valid & OBD_MD_FLXATTR) {
178                                 acl = lustre_acl_xattr_merge2ext(
179                                                 (posix_acl_xattr_header *)value,
180                                                 size, ee->ee_acl);
181                                 if (IS_ERR(acl)) {
182                                         ee_free(ee);
183                                         RETURN(PTR_ERR(acl));
184                                 }
185                                 size =  CFS_ACL_XATTR_SIZE(\
186                                                 le32_to_cpu(acl->a_count), \
187                                                 ext_acl_xattr);
188                                 pv = (const char *)acl;
189                         }
190                         ee_free(ee);
191                 } else if (rce->rce_ops == RMT_RSETFACL) {
192                         int acl_size = lustre_posix_acl_xattr_filter(
193                                                 (posix_acl_xattr_header *)value,
194                                                 size, &new_value);
195                         if (unlikely(acl_size < 0))
196                                 RETURN(acl_size);
197                         size = acl_size;
198
199                         pv = (const char *)new_value;
200                 } else
201                         RETURN(-EOPNOTSUPP);
202
203                 valid |= rce_ops2valid(rce->rce_ops);
204         }
205 #endif
206         rc = md_setxattr(sbi->ll_md_exp, ll_inode2fid(inode), valid, name, pv,
207                          size, 0, flags, ll_i2suppgid(inode), &req);
208
209 #ifdef CONFIG_FS_POSIX_ACL
210         if (new_value != NULL)
211                 lustre_posix_acl_xattr_free(new_value, size);
212         if (acl != NULL)
213                 lustre_ext_acl_xattr_free(acl);
214 #endif
215         if (rc) {
216                 if (rc == -EOPNOTSUPP && xattr_type == XATTR_USER_T) {
217                         LCONSOLE_INFO("Disabling user_xattr feature because "
218                                       "it is not supported on the server\n");
219                         sbi->ll_flags &= ~LL_SBI_USER_XATTR;
220                 }
221                 RETURN(rc);
222         }
223
224         ptlrpc_req_finished(req);
225         RETURN(0);
226 }
227
228 int ll_setxattr(struct dentry *dentry, const char *name,
229                 const void *value, size_t size, int flags)
230 {
231         struct inode *inode = dentry->d_inode;
232
233         LASSERT(inode);
234         LASSERT(name);
235
236         CDEBUG(D_VFSTRACE, "VFS Op:inode="DFID"(%p), xattr %s\n",
237                PFID(ll_inode2fid(inode)), inode, name);
238
239         ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_SETXATTR, 1);
240
241         if ((strncmp(name, XATTR_TRUSTED_PREFIX,
242                      sizeof(XATTR_TRUSTED_PREFIX) - 1) == 0 &&
243              strcmp(name + sizeof(XATTR_TRUSTED_PREFIX) - 1, "lov") == 0) ||
244             (strncmp(name, XATTR_LUSTRE_PREFIX,
245                      sizeof(XATTR_LUSTRE_PREFIX) - 1) == 0 &&
246              strcmp(name + sizeof(XATTR_LUSTRE_PREFIX) - 1, "lov") == 0)) {
247                 struct lov_user_md *lump = (struct lov_user_md *)value;
248                 int                 rc = 0;
249
250                 /* Attributes that are saved via getxattr will always have
251                  * the stripe_offset as 0.  Instead, the MDS should be
252                  * allowed to pick the starting OST index.   b=17846 */
253                 if (lump != NULL && lump->lmm_stripe_offset == 0)
254                         lump->lmm_stripe_offset = -1;
255
256                 if (lump != NULL && S_ISREG(inode->i_mode)) {
257                         struct file     f;
258                         __u64           it_flags = FMODE_WRITE;
259                         int             lum_size;
260
261                         lum_size = ll_lov_user_md_size(lump);
262                         if (lum_size < 0 || size < lum_size)
263                                 return 0; /* b=10667: ignore error */
264
265                         memset(&f, 0, sizeof(f)); /* f.f_flags is used below */
266                         f.f_path.dentry = dentry;
267                         rc = ll_lov_setstripe_ea_info(inode, &f, it_flags, lump,
268                                                       lum_size);
269                         /* b=10667: rc always be 0 here for now */
270                         rc = 0;
271                 } else if (S_ISDIR(inode->i_mode)) {
272                         rc = ll_dir_setstripe(inode, lump, 0);
273                 }
274
275                 return rc;
276
277         } else if (strcmp(name, XATTR_NAME_LMA) == 0 ||
278                    strcmp(name, XATTR_NAME_LINK) == 0)
279                 return 0;
280
281         return ll_setxattr_common(inode, name, value, size, flags,
282                                   OBD_MD_FLXATTR);
283 }
284
285 int ll_removexattr(struct dentry *dentry, const char *name)
286 {
287         struct inode *inode = dentry->d_inode;
288
289         LASSERT(inode);
290         LASSERT(name);
291
292         CDEBUG(D_VFSTRACE, "VFS Op:inode="DFID"(%p), xattr %s\n",
293                PFID(ll_inode2fid(inode)), inode, name);
294
295         ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_REMOVEXATTR, 1);
296         return ll_setxattr_common(inode, name, NULL, 0, 0,
297                                   OBD_MD_FLXATTRRM);
298 }
299
300 int ll_getxattr_common(struct inode *inode, const char *name,
301                        void *buffer, size_t size, __u64 valid)
302 {
303         struct ll_sb_info *sbi = ll_i2sbi(inode);
304         struct ptlrpc_request *req = NULL;
305         struct mdt_body *body;
306         int xattr_type, rc;
307         void *xdata;
308         struct rmtacl_ctl_entry *rce = NULL;
309         struct ll_inode_info *lli = ll_i2info(inode);
310         ENTRY;
311
312         CDEBUG(D_VFSTRACE, "VFS Op:inode="DFID"(%p)\n",
313                PFID(ll_inode2fid(inode)), inode);
314
315         /* listxattr have slightly different behavior from of ext3:
316          * without 'user_xattr' ext3 will list all xattr names but
317          * filtered out "^user..*"; we list them all for simplicity.
318          */
319         if (!name) {
320                 xattr_type = XATTR_OTHER_T;
321                 goto do_getxattr;
322         }
323
324         xattr_type = get_xattr_type(name);
325         rc = xattr_type_filter(sbi, xattr_type);
326         if (rc)
327                 RETURN(rc);
328
329         /* b15587: ignore security.capability xattr for now */
330         if ((xattr_type == XATTR_SECURITY_T &&
331             strcmp(name, "security.capability") == 0))
332                 RETURN(-ENODATA);
333
334         /* LU-549:  Disable security.selinux when selinux is disabled */
335         if (xattr_type == XATTR_SECURITY_T && !selinux_is_enabled() &&
336             strcmp(name, "security.selinux") == 0)
337                 RETURN(-EOPNOTSUPP);
338
339 #ifdef CONFIG_FS_POSIX_ACL
340         if (sbi->ll_flags & LL_SBI_RMT_CLIENT &&
341             (xattr_type == XATTR_ACL_ACCESS_T ||
342             xattr_type == XATTR_ACL_DEFAULT_T)) {
343                 rce = rct_search(&sbi->ll_rct, current_pid());
344                 if (rce == NULL ||
345                     (rce->rce_ops != RMT_LSETFACL &&
346                     rce->rce_ops != RMT_LGETFACL &&
347                     rce->rce_ops != RMT_RSETFACL &&
348                     rce->rce_ops != RMT_RGETFACL))
349                         RETURN(-EOPNOTSUPP);
350         }
351
352         /* posix acl is under protection of LOOKUP lock. when calling to this,
353          * we just have path resolution to the target inode, so we have great
354          * chance that cached ACL is uptodate.
355          */
356         if (xattr_type == XATTR_ACL_ACCESS_T &&
357             !(sbi->ll_flags & LL_SBI_RMT_CLIENT)) {
358
359                 struct posix_acl *acl;
360
361                 spin_lock(&lli->lli_lock);
362                 acl = posix_acl_dup(lli->lli_posix_acl);
363                 spin_unlock(&lli->lli_lock);
364
365                 if (!acl)
366                         RETURN(-ENODATA);
367
368                 rc = posix_acl_to_xattr(&init_user_ns, acl, buffer, size);
369                 posix_acl_release(acl);
370                 RETURN(rc);
371         }
372         if (xattr_type == XATTR_ACL_DEFAULT_T && !S_ISDIR(inode->i_mode))
373                 RETURN(-ENODATA);
374 #endif
375
376 do_getxattr:
377         if (sbi->ll_xattr_cache_enabled &&
378             xattr_type != XATTR_ACL_ACCESS_T &&
379             (xattr_type != XATTR_SECURITY_T ||
380                 strcmp(name, "security.selinux") != 0)) {
381                 rc = ll_xattr_cache_get(inode, name, buffer, size, valid);
382                 if (rc == -EAGAIN)
383                         goto getxattr_nocache;
384                 if (rc < 0)
385                         GOTO(out_xattr, rc);
386
387                 /* Add "system.posix_acl_access" to the list */
388                 if (lli->lli_posix_acl != NULL && valid & OBD_MD_FLXATTRLS) {
389                         if (size == 0) {
390                                 rc += sizeof(XATTR_NAME_ACL_ACCESS);
391                         } else if (size - rc >= sizeof(XATTR_NAME_ACL_ACCESS)) {
392                                 memcpy(buffer + rc, XATTR_NAME_ACL_ACCESS,
393                                        sizeof(XATTR_NAME_ACL_ACCESS));
394                                 rc += sizeof(XATTR_NAME_ACL_ACCESS);
395                         } else {
396                                 GOTO(out_xattr, rc = -ERANGE);
397                         }
398                 }
399         } else {
400 getxattr_nocache:
401                 rc = md_getxattr(sbi->ll_md_exp, ll_inode2fid(inode),
402                                 valid | (rce ? rce_ops2valid(rce->rce_ops) : 0),
403                                 name, NULL, 0, size, 0, &req);
404
405                 if (rc < 0)
406                         GOTO(out_xattr, rc);
407
408                 body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY);
409                 LASSERT(body);
410
411                 /* only detect the xattr size */
412                 if (size == 0)
413                         GOTO(out, rc = body->mbo_eadatasize);
414
415                 if (size < body->mbo_eadatasize) {
416                         CERROR("server bug: replied size %u > %u\n",
417                                 body->mbo_eadatasize, (int)size);
418                         GOTO(out, rc = -ERANGE);
419                 }
420
421                 if (body->mbo_eadatasize == 0)
422                         GOTO(out, rc = -ENODATA);
423
424                 /* do not need swab xattr data */
425                 xdata = req_capsule_server_sized_get(&req->rq_pill, &RMF_EADATA,
426                                                         body->mbo_eadatasize);
427                 if (!xdata)
428                         GOTO(out, rc = -EFAULT);
429
430                 memcpy(buffer, xdata, body->mbo_eadatasize);
431                 rc = body->mbo_eadatasize;
432         }
433
434 #ifdef CONFIG_FS_POSIX_ACL
435         if (rce != NULL && rce->rce_ops == RMT_LSETFACL) {
436                 ext_acl_xattr_header *acl;
437
438                 acl = lustre_posix_acl_xattr_2ext(buffer, rc);
439                 if (IS_ERR(acl))
440                         GOTO(out, rc = PTR_ERR(acl));
441
442                 rc = ee_add(&sbi->ll_et, current_pid(), ll_inode2fid(inode),
443                             xattr_type, acl);
444                 if (unlikely(rc < 0)) {
445                         lustre_ext_acl_xattr_free(acl);
446                         GOTO(out, rc);
447                 }
448         }
449 #endif
450         EXIT;
451
452 out_xattr:
453         if (rc == -EOPNOTSUPP && xattr_type == XATTR_USER_T) {
454                 LCONSOLE_INFO("%s: disabling user_xattr feature because "
455                                 "it is not supported on the server: rc = %d\n",
456                                 ll_get_fsname(inode->i_sb, NULL, 0), rc);
457                 sbi->ll_flags &= ~LL_SBI_USER_XATTR;
458         }
459 out:
460         ptlrpc_req_finished(req);
461         return rc;
462 }
463
464 static ssize_t ll_getxattr_lov(struct inode *inode, void *buf, size_t buf_size)
465 {
466         ssize_t rc;
467
468         if (S_ISREG(inode->i_mode)) {
469                 struct cl_object *obj = ll_i2info(inode)->lli_clob;
470                 struct lu_env *env;
471                 struct cl_layout cl = {
472                         .cl_buf.lb_buf = buf,
473                         .cl_buf.lb_len = buf_size,
474                 };
475                 int refcheck;
476
477                 if (obj == NULL)
478                         RETURN(-ENODATA);
479
480                 env = cl_env_get(&refcheck);
481                 if (IS_ERR(env))
482                         RETURN(PTR_ERR(env));
483
484                 rc = cl_object_layout_get(env, obj, &cl);
485                 if (rc < 0)
486                         GOTO(out_env, rc);
487
488                 if (cl.cl_size == 0)
489                         GOTO(out_env, rc = -ENODATA);
490
491                 rc = cl.cl_size;
492
493                 if (buf_size == 0)
494                         GOTO(out_env, rc);
495
496                 LASSERT(buf != NULL && rc <= buf_size);
497
498                 /* Do not return layout gen for getxattr() since
499                  * otherwise it would confuse tar --xattr by
500                  * recognizing layout gen as stripe offset when the
501                  * file is restored. See LU-2809. */
502                 ((struct lov_mds_md *)buf)->lmm_layout_gen = 0;
503 out_env:
504                 cl_env_put(env, &refcheck);
505
506                 RETURN(rc);
507         } else if (S_ISDIR(inode->i_mode)) {
508                 struct lov_mds_md *lmm = NULL;
509                 int lmm_size = 0;
510                 struct ptlrpc_request *req = NULL;
511
512                 rc = ll_dir_getstripe(inode, (void **)&lmm, &lmm_size,
513                                       &req, 0);
514                 if (rc < 0)
515                         GOTO(out_req, rc);
516
517                 if (buf_size == 0)
518                         GOTO(out_req, rc = lmm_size);
519
520                 if (buf_size < lmm_size)
521                         GOTO(out_req, rc = -ERANGE);
522
523                 memcpy(buf, lmm, lmm_size);
524                 GOTO(out_req, rc = lmm_size);
525 out_req:
526                 if (req != NULL)
527                         ptlrpc_req_finished(req);
528
529                 return rc;
530         } else {
531                 RETURN(-ENODATA);
532         }
533 }
534
535 ssize_t ll_getxattr(struct dentry *dentry, const char *name, void *buf,
536                     size_t buf_size)
537 {
538         struct inode *inode = dentry->d_inode;
539
540         LASSERT(inode);
541         LASSERT(name);
542
543         CDEBUG(D_VFSTRACE, "VFS Op:inode="DFID"(%p), xattr %s\n",
544                PFID(ll_inode2fid(inode)), inode, name);
545
546         ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_GETXATTR, 1);
547
548         if (strcmp(name, XATTR_LUSTRE_LOV) == 0 ||
549             strcmp(name, XATTR_NAME_LOV) == 0)
550                 return ll_getxattr_lov(inode, buf, buf_size);
551         else
552                 return ll_getxattr_common(inode, name, buf, buf_size,
553                                           OBD_MD_FLXATTR);
554 }
555
556 ssize_t ll_listxattr(struct dentry *dentry, char *buf, size_t buf_size)
557 {
558         struct inode *inode = dentry->d_inode;
559         struct ll_sb_info *sbi = ll_i2sbi(inode);
560         char *xattr_name;
561         ssize_t rc, rc2;
562         size_t len, rem;
563
564         CDEBUG(D_VFSTRACE, "VFS Op:inode="DFID"(%p)\n",
565                PFID(ll_inode2fid(inode)), inode);
566
567         ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_LISTXATTR, 1);
568
569         rc = ll_getxattr_common(inode, NULL, buf, buf_size, OBD_MD_FLXATTRLS);
570         if (rc < 0)
571                 RETURN(rc);
572
573         /* If we're being called to get the size of the xattr list
574          * (buf_size == 0) then just assume that a lustre.lov xattr
575          * exists. */
576         if (buf_size == 0)
577                 RETURN(rc + sizeof(XATTR_LUSTRE_LOV));
578
579         xattr_name = buf;
580         rem = rc;
581
582         while (rem > 0) {
583                 len = strnlen(xattr_name, rem - 1) + 1;
584                 rem -= len;
585                 if (xattr_type_filter(sbi, get_xattr_type(xattr_name)) == 0) {
586                         /* Skip OK xattr type, leave it in buffer. */
587                         xattr_name += len;
588                         continue;
589                 }
590
591                 /* Move up remaining xattrs in buffer removing the
592                  * xattr that is not OK. */
593                 memmove(xattr_name, xattr_name + len, rem);
594                 rc -= len;
595         }
596
597         rc2 = ll_getxattr_lov(inode, NULL, 0);
598         if (rc2 == -ENODATA)
599                 RETURN(rc);
600
601         if (rc2 < 0)
602                 RETURN(rc2);
603
604         if (buf_size < rc + sizeof(XATTR_LUSTRE_LOV))
605                 RETURN(-ERANGE);
606
607         memcpy(buf + rc, XATTR_LUSTRE_LOV, sizeof(XATTR_LUSTRE_LOV));
608
609         RETURN(rc + sizeof(XATTR_LUSTRE_LOV));
610 }