]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/ufs/ufs/ufs_extattr.c
MFH
[FreeBSD/FreeBSD.git] / sys / ufs / ufs / ufs_extattr.c
1 /*-
2  * Copyright (c) 1999-2002 Robert N. M. Watson
3  * Copyright (c) 2002-2003 Networks Associates Technology, Inc.
4  * All rights reserved.
5  *
6  * This software was developed by Robert Watson for the TrustedBSD Project.
7  *
8  * This software was developed for the FreeBSD Project in part by Network
9  * Associates Laboratories, the Security Research Division of Network
10  * Associates, Inc. under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"),
11  * as part of the DARPA CHATS research program.
12  *
13  * Redistribution and use in source and binary forms, with or without
14  * modification, are permitted provided that the following conditions
15  * are met:
16  * 1. Redistributions of source code must retain the above copyright
17  *    notice, this list of conditions and the following disclaimer.
18  * 2. Redistributions in binary form must reproduce the above copyright
19  *    notice, this list of conditions and the following disclaimer in the
20  *    documentation and/or other materials provided with the distribution.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
23  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
26  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32  * SUCH DAMAGE.
33  *
34  */
35
36 /*
37  * Support for filesystem extended attribute: UFS-specific support functions.
38  */
39
40 #include <sys/cdefs.h>
41 __FBSDID("$FreeBSD$");
42
43 #include "opt_ufs.h"
44
45 #include <sys/param.h>
46 #include <sys/systm.h>
47 #include <sys/kernel.h>
48 #include <sys/namei.h>
49 #include <sys/malloc.h>
50 #include <sys/fcntl.h>
51 #include <sys/priv.h>
52 #include <sys/proc.h>
53 #include <sys/vnode.h>
54 #include <sys/mount.h>
55 #include <sys/lock.h>
56 #include <sys/dirent.h>
57 #include <sys/extattr.h>
58 #include <sys/sx.h>
59 #include <sys/sysctl.h>
60
61 #include <vm/uma.h>
62
63 #include <ufs/ufs/dir.h>
64 #include <ufs/ufs/extattr.h>
65 #include <ufs/ufs/quota.h>
66 #include <ufs/ufs/ufsmount.h>
67 #include <ufs/ufs/inode.h>
68 #include <ufs/ufs/ufs_extern.h>
69
70 #ifdef UFS_EXTATTR
71
72 static MALLOC_DEFINE(M_UFS_EXTATTR, "ufs_extattr", "ufs extended attribute");
73
74 static int ufs_extattr_sync = 0;
75 SYSCTL_INT(_debug, OID_AUTO, ufs_extattr_sync, CTLFLAG_RW, &ufs_extattr_sync,
76     0, "");
77
78 static int      ufs_extattr_valid_attrname(int attrnamespace,
79                     const char *attrname);
80 static int      ufs_extattr_enable_with_open(struct ufsmount *ump,
81                     struct vnode *vp, int attrnamespace, const char *attrname,
82                     struct thread *td);
83 static int      ufs_extattr_enable(struct ufsmount *ump, int attrnamespace,
84                     const char *attrname, struct vnode *backing_vnode,
85                     struct thread *td);
86 static int      ufs_extattr_disable(struct ufsmount *ump, int attrnamespace,
87                     const char *attrname, struct thread *td);
88 static int      ufs_extattr_get(struct vnode *vp, int attrnamespace,
89                     const char *name, struct uio *uio, size_t *size,
90                     struct ucred *cred, struct thread *td);
91 static int      ufs_extattr_set(struct vnode *vp, int attrnamespace,
92                     const char *name, struct uio *uio, struct ucred *cred,
93                     struct thread *td);
94 static int      ufs_extattr_rm(struct vnode *vp, int attrnamespace,
95                     const char *name, struct ucred *cred, struct thread *td);
96 #ifdef UFS_EXTATTR_AUTOSTART
97 static int      ufs_extattr_autostart_locked(struct mount *mp,
98                     struct thread *td);
99 #endif
100 static int      ufs_extattr_start_locked(struct ufsmount *ump,
101                     struct thread *td);
102
103 /*
104  * Per-FS attribute lock protecting attribute operations.
105  *
106  * XXXRW: Perhaps something more fine-grained would be appropriate, but at
107  * the end of the day we're going to contend on the vnode lock for the
108  * backing file anyway.
109  */
110 static void
111 ufs_extattr_uepm_lock(struct ufsmount *ump)
112 {
113
114         sx_xlock(&ump->um_extattr.uepm_lock);
115 }
116
117 static void
118 ufs_extattr_uepm_unlock(struct ufsmount *ump)
119 {
120
121         sx_xunlock(&ump->um_extattr.uepm_lock);
122 }
123
124 /*-
125  * Determine whether the name passed is a valid name for an actual
126  * attribute.
127  *
128  * Invalid currently consists of:
129  *       NULL pointer for attrname
130  *       zero-length attrname (used to retrieve application attribute list)
131  */
132 static int
133 ufs_extattr_valid_attrname(int attrnamespace, const char *attrname)
134 {
135
136         if (attrname == NULL)
137                 return (0);
138         if (strlen(attrname) == 0)
139                 return (0);
140         return (1);
141 }
142
143 /*
144  * Locate an attribute given a name and mountpoint.
145  * Must be holding uepm lock for the mount point.
146  */
147 static struct ufs_extattr_list_entry *
148 ufs_extattr_find_attr(struct ufsmount *ump, int attrnamespace,
149     const char *attrname)
150 {
151         struct ufs_extattr_list_entry *search_attribute;
152
153         sx_assert(&ump->um_extattr.uepm_lock, SA_XLOCKED);
154
155         for (search_attribute = LIST_FIRST(&ump->um_extattr.uepm_list);
156             search_attribute != NULL;
157             search_attribute = LIST_NEXT(search_attribute, uele_entries)) {
158                 if (!(strncmp(attrname, search_attribute->uele_attrname,
159                     UFS_EXTATTR_MAXEXTATTRNAME)) &&
160                     (attrnamespace == search_attribute->uele_attrnamespace)) {
161                         return (search_attribute);
162                 }
163         }
164
165         return (0);
166 }
167
168 /*
169  * Initialize per-FS structures supporting extended attributes.  Do not
170  * start extended attributes yet.
171  */
172 void
173 ufs_extattr_uepm_init(struct ufs_extattr_per_mount *uepm)
174 {
175
176         uepm->uepm_flags = 0;
177         LIST_INIT(&uepm->uepm_list);
178         sx_init(&uepm->uepm_lock, "ufs_extattr_sx");
179         uepm->uepm_flags |= UFS_EXTATTR_UEPM_INITIALIZED;
180 }
181
182 /*
183  * Destroy per-FS structures supporting extended attributes.  Assumes
184  * that EAs have already been stopped, and will panic if not.
185  */
186 void
187 ufs_extattr_uepm_destroy(struct ufs_extattr_per_mount *uepm)
188 {
189
190         if (!(uepm->uepm_flags & UFS_EXTATTR_UEPM_INITIALIZED))
191                 panic("ufs_extattr_uepm_destroy: not initialized");
192
193         if ((uepm->uepm_flags & UFS_EXTATTR_UEPM_STARTED))
194                 panic("ufs_extattr_uepm_destroy: called while still started");
195
196         /*
197          * It's not clear that either order for the next two lines is
198          * ideal, and it should never be a problem if this is only called
199          * during unmount, and with vfs_busy().
200          */
201         uepm->uepm_flags &= ~UFS_EXTATTR_UEPM_INITIALIZED;
202         sx_destroy(&uepm->uepm_lock);
203 }
204
205 /*
206  * Start extended attribute support on an FS.
207  */
208 int
209 ufs_extattr_start(struct mount *mp, struct thread *td)
210 {
211         struct ufsmount *ump;
212         int error = 0;
213
214         ump = VFSTOUFS(mp);
215
216         ufs_extattr_uepm_lock(ump);
217         error = ufs_extattr_start_locked(ump, td);
218         ufs_extattr_uepm_unlock(ump);
219         return (error);
220 }
221
222 static int
223 ufs_extattr_start_locked(struct ufsmount *ump, struct thread *td)
224 {
225         if (!(ump->um_extattr.uepm_flags & UFS_EXTATTR_UEPM_INITIALIZED))
226                 return (EOPNOTSUPP);
227         if (ump->um_extattr.uepm_flags & UFS_EXTATTR_UEPM_STARTED)
228                 return (EBUSY);
229
230         ump->um_extattr.uepm_flags |= UFS_EXTATTR_UEPM_STARTED;
231         ump->um_extattr.uepm_ucred = crhold(td->td_ucred);
232         return (0);
233 }
234
235 #ifdef UFS_EXTATTR_AUTOSTART
236 /*
237  * Helper routine: given a locked parent directory and filename, return
238  * the locked vnode of the inode associated with the name.  Will not
239  * follow symlinks, may return any type of vnode.  Lock on parent will
240  * be released even in the event of a failure.  In the event that the
241  * target is the parent (i.e., "."), there will be two references and
242  * one lock, requiring the caller to possibly special-case.
243  */
244 #define UE_GETDIR_LOCKPARENT    1
245 #define UE_GETDIR_LOCKPARENT_DONT       2
246 static int
247 ufs_extattr_lookup(struct vnode *start_dvp, int lockparent, char *dirname,
248     struct vnode **vp, struct thread *td)
249 {
250         struct vop_cachedlookup_args vargs;
251         struct componentname cnp;
252         struct vnode *target_vp;
253         int error;
254
255         bzero(&cnp, sizeof(cnp));
256         cnp.cn_nameiop = LOOKUP;
257         cnp.cn_flags = ISLASTCN;
258         if (lockparent == UE_GETDIR_LOCKPARENT)
259                 cnp.cn_flags |= LOCKPARENT;
260         cnp.cn_lkflags = LK_EXCLUSIVE;
261         cnp.cn_thread = td;
262         cnp.cn_cred = td->td_ucred;
263         cnp.cn_pnbuf = uma_zalloc(namei_zone, M_WAITOK);
264         cnp.cn_nameptr = cnp.cn_pnbuf;
265         error = copystr(dirname, cnp.cn_pnbuf, MAXPATHLEN,
266             (size_t *) &cnp.cn_namelen);
267         if (error) {
268                 if (lockparent == UE_GETDIR_LOCKPARENT_DONT) {
269                         VOP_UNLOCK(start_dvp, 0);
270                 }
271                 uma_zfree(namei_zone, cnp.cn_pnbuf);
272                 printf("ufs_extattr_lookup: copystr failed\n");
273                 return (error);
274         }
275         cnp.cn_namelen--;       /* trim nul termination */
276         vargs.a_gen.a_desc = NULL;
277         vargs.a_dvp = start_dvp;
278         vargs.a_vpp = &target_vp;
279         vargs.a_cnp = &cnp;
280         error = ufs_lookup(&vargs);
281         uma_zfree(namei_zone, cnp.cn_pnbuf);
282         if (error) {
283                 /*
284                  * Error condition, may have to release the lock on the parent
285                  * if ufs_lookup() didn't.
286                  */
287                 if (lockparent == UE_GETDIR_LOCKPARENT_DONT)
288                         VOP_UNLOCK(start_dvp, 0);
289
290                 /*
291                  * Check that ufs_lookup() didn't release the lock when we
292                  * didn't want it to.
293                  */
294                 if (lockparent == UE_GETDIR_LOCKPARENT)
295                         ASSERT_VOP_LOCKED(start_dvp, "ufs_extattr_lookup");
296
297                 return (error);
298         }
299 /*
300         if (target_vp == start_dvp)
301                 panic("ufs_extattr_lookup: target_vp == start_dvp");
302 */
303
304         if (target_vp != start_dvp && lockparent == UE_GETDIR_LOCKPARENT_DONT)
305                 VOP_UNLOCK(start_dvp, 0);
306
307         if (lockparent == UE_GETDIR_LOCKPARENT)
308                 ASSERT_VOP_LOCKED(start_dvp, "ufs_extattr_lookup");
309
310         /* printf("ufs_extattr_lookup: success\n"); */
311         *vp = target_vp;
312         return (0);
313 }
314 #endif /* !UFS_EXTATTR_AUTOSTART */
315
316 /*
317  * Enable an EA using the passed filesystem, backing vnode, attribute name,
318  * namespace, and proc.  Will perform a VOP_OPEN() on the vp, so expects vp
319  * to be locked when passed in.  The vnode will be returned unlocked,
320  * regardless of success/failure of the function.  As a result, the caller
321  * will always need to vrele(), but not vput().
322  */
323 static int
324 ufs_extattr_enable_with_open(struct ufsmount *ump, struct vnode *vp,
325     int attrnamespace, const char *attrname, struct thread *td)
326 {
327         int error;
328
329         error = VOP_OPEN(vp, FREAD|FWRITE, td->td_ucred, td, NULL);
330         if (error) {
331                 printf("ufs_extattr_enable_with_open.VOP_OPEN(): failed "
332                     "with %d\n", error);
333                 VOP_UNLOCK(vp, 0);
334                 return (error);
335         }
336
337         VOP_ADD_WRITECOUNT(vp, 1);
338         CTR3(KTR_VFS, "%s: vp %p v_writecount increased to %d", __func__, vp,
339             vp->v_writecount);
340
341         vref(vp);
342
343         VOP_UNLOCK(vp, 0);
344
345         error = ufs_extattr_enable(ump, attrnamespace, attrname, vp, td);
346         if (error != 0)
347                 vn_close(vp, FREAD|FWRITE, td->td_ucred, td);
348         return (error);
349 }
350
351 #ifdef UFS_EXTATTR_AUTOSTART
352 /*
353  * Given a locked directory vnode, iterate over the names in the directory
354  * and use ufs_extattr_lookup() to retrieve locked vnodes of potential
355  * attribute files.  Then invoke ufs_extattr_enable_with_open() on each
356  * to attempt to start the attribute.  Leaves the directory locked on
357  * exit.
358  */
359 static int
360 ufs_extattr_iterate_directory(struct ufsmount *ump, struct vnode *dvp,
361     int attrnamespace, struct thread *td)
362 {
363         struct vop_readdir_args vargs;
364         struct dirent *dp, *edp;
365         struct vnode *attr_vp;
366         struct uio auio;
367         struct iovec aiov;
368         char *dirbuf;
369         int error, eofflag = 0;
370
371         if (dvp->v_type != VDIR)
372                 return (ENOTDIR);
373
374         dirbuf = malloc(DIRBLKSIZ, M_TEMP, M_WAITOK);
375
376         auio.uio_iov = &aiov;
377         auio.uio_iovcnt = 1;
378         auio.uio_rw = UIO_READ;
379         auio.uio_segflg = UIO_SYSSPACE;
380         auio.uio_td = td;
381         auio.uio_offset = 0;
382
383         vargs.a_gen.a_desc = NULL;
384         vargs.a_vp = dvp;
385         vargs.a_uio = &auio;
386         vargs.a_cred = td->td_ucred;
387         vargs.a_eofflag = &eofflag;
388         vargs.a_ncookies = NULL;
389         vargs.a_cookies = NULL;
390
391         while (!eofflag) {
392                 auio.uio_resid = DIRBLKSIZ;
393                 aiov.iov_base = dirbuf;
394                 aiov.iov_len = DIRBLKSIZ;
395                 error = ufs_readdir(&vargs);
396                 if (error) {
397                         printf("ufs_extattr_iterate_directory: ufs_readdir "
398                             "%d\n", error);
399                         return (error);
400                 }
401
402                 edp = (struct dirent *)&dirbuf[DIRBLKSIZ - auio.uio_resid];
403                 for (dp = (struct dirent *)dirbuf; dp < edp; ) {
404                         if (dp->d_reclen == 0)
405                                 break;
406                         error = ufs_extattr_lookup(dvp, UE_GETDIR_LOCKPARENT,
407                             dp->d_name, &attr_vp, td);
408                         if (error) {
409                                 printf("ufs_extattr_iterate_directory: lookup "
410                                     "%s %d\n", dp->d_name, error);
411                         } else if (attr_vp == dvp) {
412                                 vrele(attr_vp);
413                         } else if (attr_vp->v_type != VREG) {
414                                 vput(attr_vp);
415                         } else {
416                                 error = ufs_extattr_enable_with_open(ump,
417                                     attr_vp, attrnamespace, dp->d_name, td);
418                                 vrele(attr_vp);
419                                 if (error) {
420                                         printf("ufs_extattr_iterate_directory: "
421                                             "enable %s %d\n", dp->d_name,
422                                             error);
423                                 } else if (bootverbose) {
424                                         printf("UFS autostarted EA %s\n",
425                                             dp->d_name);
426                                 }
427                         }
428                         dp = (struct dirent *) ((char *)dp + dp->d_reclen);
429                         if (dp >= edp)
430                                 break;
431                 }
432         }
433         free(dirbuf, M_TEMP);
434         
435         return (0);
436 }
437
438 /*
439  * Auto-start of extended attributes, to be executed (optionally) at
440  * mount-time.
441  */
442 int
443 ufs_extattr_autostart(struct mount *mp, struct thread *td)
444 {
445         struct ufsmount *ump;
446         int error;
447
448         ump = VFSTOUFS(mp);
449         ufs_extattr_uepm_lock(ump);
450         error = ufs_extattr_autostart_locked(mp, td);
451         ufs_extattr_uepm_unlock(ump);
452         return (error);
453 }
454
455 static int
456 ufs_extattr_autostart_locked(struct mount *mp, struct thread *td)
457 {
458         struct vnode *rvp, *attr_dvp, *attr_system_dvp, *attr_user_dvp;
459         struct ufsmount *ump = VFSTOUFS(mp);
460         int error;
461
462         /*
463          * UFS_EXTATTR applies only to UFS1, as UFS2 uses native extended
464          * attributes, so don't autostart.
465          */
466         if (ump->um_fstype != UFS1)
467                 return (0);
468
469         /*
470          * Does UFS_EXTATTR_FSROOTSUBDIR exist off the filesystem root?
471          * If so, automatically start EA's.
472          */
473         error = VFS_ROOT(mp, LK_EXCLUSIVE, &rvp);
474         if (error) {
475                 printf("ufs_extattr_autostart.VFS_ROOT() returned %d\n",
476                     error);
477                 return (error);
478         }
479
480         error = ufs_extattr_lookup(rvp, UE_GETDIR_LOCKPARENT_DONT,
481             UFS_EXTATTR_FSROOTSUBDIR, &attr_dvp, td);
482         if (error) {
483                 /* rvp ref'd but now unlocked */
484                 vrele(rvp);
485                 return (error);
486         }
487         if (rvp == attr_dvp) {
488                 /* Should never happen. */
489                 vput(rvp);
490                 vrele(attr_dvp);
491                 return (EINVAL);
492         }
493         vrele(rvp);
494
495         if (attr_dvp->v_type != VDIR) {
496                 printf("ufs_extattr_autostart: %s != VDIR\n",
497                     UFS_EXTATTR_FSROOTSUBDIR);
498                 goto return_vput_attr_dvp;
499         }
500
501         error = ufs_extattr_start_locked(ump, td);
502         if (error) {
503                 printf("ufs_extattr_autostart: ufs_extattr_start failed (%d)\n",
504                     error);
505                 goto return_vput_attr_dvp;
506         }
507
508         /*
509          * Look for two subdirectories: UFS_EXTATTR_SUBDIR_SYSTEM,
510          * UFS_EXTATTR_SUBDIR_USER.  For each, iterate over the sub-directory,
511          * and start with appropriate type.  Failures in either don't
512          * result in an over-all failure.  attr_dvp is left locked to
513          * be cleaned up on exit.
514          */
515         error = ufs_extattr_lookup(attr_dvp, UE_GETDIR_LOCKPARENT,
516             UFS_EXTATTR_SUBDIR_SYSTEM, &attr_system_dvp, td);
517         if (!error) {
518                 error = ufs_extattr_iterate_directory(VFSTOUFS(mp),
519                     attr_system_dvp, EXTATTR_NAMESPACE_SYSTEM, td);
520                 if (error)
521                         printf("ufs_extattr_iterate_directory returned %d\n",
522                             error);
523                 vput(attr_system_dvp);
524         }
525
526         error = ufs_extattr_lookup(attr_dvp, UE_GETDIR_LOCKPARENT,
527             UFS_EXTATTR_SUBDIR_USER, &attr_user_dvp, td);
528         if (!error) {
529                 error = ufs_extattr_iterate_directory(VFSTOUFS(mp),
530                     attr_user_dvp, EXTATTR_NAMESPACE_USER, td);
531                 if (error)
532                         printf("ufs_extattr_iterate_directory returned %d\n",
533                             error);
534                 vput(attr_user_dvp);
535         }
536
537         /* Mask startup failures in sub-directories. */
538         error = 0;
539
540 return_vput_attr_dvp:
541         vput(attr_dvp);
542
543         return (error);
544 }
545 #endif /* !UFS_EXTATTR_AUTOSTART */
546
547 /*
548  * Stop extended attribute support on an FS.
549  */
550 int
551 ufs_extattr_stop(struct mount *mp, struct thread *td)
552 {
553         struct ufs_extattr_list_entry *uele;
554         struct ufsmount *ump = VFSTOUFS(mp);
555         int error = 0;
556
557         ufs_extattr_uepm_lock(ump);
558
559         if (!(ump->um_extattr.uepm_flags & UFS_EXTATTR_UEPM_STARTED)) {
560                 error = EOPNOTSUPP;
561                 goto unlock;
562         }
563
564         while ((uele = LIST_FIRST(&ump->um_extattr.uepm_list)) != NULL) {
565                 ufs_extattr_disable(ump, uele->uele_attrnamespace,
566                     uele->uele_attrname, td);
567         }
568
569         ump->um_extattr.uepm_flags &= ~UFS_EXTATTR_UEPM_STARTED;
570
571         crfree(ump->um_extattr.uepm_ucred);
572         ump->um_extattr.uepm_ucred = NULL;
573
574 unlock:
575         ufs_extattr_uepm_unlock(ump);
576
577         return (error);
578 }
579
580 /*
581  * Enable a named attribute on the specified filesystem; provide an
582  * unlocked backing vnode to hold the attribute data.
583  */
584 static int
585 ufs_extattr_enable(struct ufsmount *ump, int attrnamespace,
586     const char *attrname, struct vnode *backing_vnode, struct thread *td)
587 {
588         struct ufs_extattr_list_entry *attribute;
589         struct iovec aiov;
590         struct uio auio;
591         int error = 0;
592
593         if (!ufs_extattr_valid_attrname(attrnamespace, attrname))
594                 return (EINVAL);
595         if (backing_vnode->v_type != VREG)
596                 return (EINVAL);
597
598         attribute = malloc(sizeof(struct ufs_extattr_list_entry),
599             M_UFS_EXTATTR, M_WAITOK);
600
601         if (!(ump->um_extattr.uepm_flags & UFS_EXTATTR_UEPM_STARTED)) {
602                 error = EOPNOTSUPP;
603                 goto free_exit;
604         }
605
606         if (ufs_extattr_find_attr(ump, attrnamespace, attrname)) {
607                 error = EEXIST;
608                 goto free_exit;
609         }
610
611         strncpy(attribute->uele_attrname, attrname,
612             UFS_EXTATTR_MAXEXTATTRNAME);
613         attribute->uele_attrnamespace = attrnamespace;
614         bzero(&attribute->uele_fileheader,
615             sizeof(struct ufs_extattr_fileheader));
616         
617         attribute->uele_backing_vnode = backing_vnode;
618
619         auio.uio_iov = &aiov;
620         auio.uio_iovcnt = 1;
621         aiov.iov_base = (caddr_t) &attribute->uele_fileheader;
622         aiov.iov_len = sizeof(struct ufs_extattr_fileheader);
623         auio.uio_resid = sizeof(struct ufs_extattr_fileheader);
624         auio.uio_offset = (off_t) 0;
625         auio.uio_segflg = UIO_SYSSPACE;
626         auio.uio_rw = UIO_READ;
627         auio.uio_td = td;
628
629         vn_lock(backing_vnode, LK_SHARED | LK_RETRY);
630         error = VOP_READ(backing_vnode, &auio, IO_NODELOCKED,
631             ump->um_extattr.uepm_ucred);
632
633         if (error)
634                 goto unlock_free_exit;
635
636         if (auio.uio_resid != 0) {
637                 printf("ufs_extattr_enable: malformed attribute header\n");
638                 error = EINVAL;
639                 goto unlock_free_exit;
640         }
641
642         if (attribute->uele_fileheader.uef_magic != UFS_EXTATTR_MAGIC) {
643                 printf("ufs_extattr_enable: invalid attribute header magic\n");
644                 error = EINVAL;
645                 goto unlock_free_exit;
646         }
647
648         if (attribute->uele_fileheader.uef_version != UFS_EXTATTR_VERSION) {
649                 printf("ufs_extattr_enable: incorrect attribute header "
650                     "version\n");
651                 error = EINVAL;
652                 goto unlock_free_exit;
653         }
654
655         ASSERT_VOP_LOCKED(backing_vnode, "ufs_extattr_enable");
656         LIST_INSERT_HEAD(&ump->um_extattr.uepm_list, attribute,
657             uele_entries);
658
659         VOP_UNLOCK(backing_vnode, 0);
660         return (0);
661
662 unlock_free_exit:
663         VOP_UNLOCK(backing_vnode, 0);
664
665 free_exit:
666         free(attribute, M_UFS_EXTATTR);
667         return (error);
668 }
669
670 /*
671  * Disable extended attribute support on an FS.
672  */
673 static int
674 ufs_extattr_disable(struct ufsmount *ump, int attrnamespace,
675     const char *attrname, struct thread *td)
676 {
677         struct ufs_extattr_list_entry *uele;
678         int error = 0;
679
680         if (!ufs_extattr_valid_attrname(attrnamespace, attrname))
681                 return (EINVAL);
682
683         uele = ufs_extattr_find_attr(ump, attrnamespace, attrname);
684         if (!uele)
685                 return (ENOATTR);
686
687         LIST_REMOVE(uele, uele_entries);
688
689         vn_lock(uele->uele_backing_vnode, LK_SHARED | LK_RETRY);
690         ASSERT_VOP_LOCKED(uele->uele_backing_vnode, "ufs_extattr_disable");
691         VOP_UNLOCK(uele->uele_backing_vnode, 0);
692         error = vn_close(uele->uele_backing_vnode, FREAD|FWRITE,
693             td->td_ucred, td);
694
695         free(uele, M_UFS_EXTATTR);
696
697         return (error);
698 }
699
700 /*
701  * VFS call to manage extended attributes in UFS.  If filename_vp is
702  * non-NULL, it must be passed in locked, and regardless of errors in
703  * processing, will be unlocked.
704  */
705 int
706 ufs_extattrctl(struct mount *mp, int cmd, struct vnode *filename_vp,
707     int attrnamespace, const char *attrname)
708 {
709         struct ufsmount *ump = VFSTOUFS(mp);
710         struct thread *td = curthread;
711         int error;
712
713         /*
714          * Processes with privilege, but in jail, are not allowed to
715          * configure extended attributes.
716          */
717         error = priv_check(td, PRIV_UFS_EXTATTRCTL);
718         if (error) {
719                 if (filename_vp != NULL)
720                         VOP_UNLOCK(filename_vp, 0);
721                 return (error);
722         }
723
724         /*
725          * We only allow extattrctl(2) on UFS1 file systems, as UFS2 uses
726          * native extended attributes.
727          */
728         if (ump->um_fstype != UFS1) {
729                 if (filename_vp != NULL)
730                         VOP_UNLOCK(filename_vp, 0);
731                 return (EOPNOTSUPP);
732         }
733
734         switch(cmd) {
735         case UFS_EXTATTR_CMD_START:
736                 if (filename_vp != NULL) {
737                         VOP_UNLOCK(filename_vp, 0);
738                         return (EINVAL);
739                 }
740                 if (attrname != NULL)
741                         return (EINVAL);
742
743                 error = ufs_extattr_start(mp, td);
744
745                 return (error);
746                 
747         case UFS_EXTATTR_CMD_STOP:
748                 if (filename_vp != NULL) {
749                         VOP_UNLOCK(filename_vp, 0);
750                         return (EINVAL);
751                 }
752                 if (attrname != NULL)
753                         return (EINVAL);
754
755                 error = ufs_extattr_stop(mp, td);
756
757                 return (error);
758
759         case UFS_EXTATTR_CMD_ENABLE:
760
761                 if (filename_vp == NULL)
762                         return (EINVAL);
763                 if (attrname == NULL) {
764                         VOP_UNLOCK(filename_vp, 0);
765                         return (EINVAL);
766                 }
767
768                 /*
769                  * ufs_extattr_enable_with_open() will always unlock the
770                  * vnode, regardless of failure.
771                  */
772                 ufs_extattr_uepm_lock(ump);
773                 error = ufs_extattr_enable_with_open(ump, filename_vp,
774                     attrnamespace, attrname, td);
775                 ufs_extattr_uepm_unlock(ump);
776
777                 return (error);
778
779         case UFS_EXTATTR_CMD_DISABLE:
780
781                 if (filename_vp != NULL) {
782                         VOP_UNLOCK(filename_vp, 0);
783                         return (EINVAL);
784                 }
785                 if (attrname == NULL)
786                         return (EINVAL);
787
788                 ufs_extattr_uepm_lock(ump);
789                 error = ufs_extattr_disable(ump, attrnamespace, attrname,
790                     td);
791                 ufs_extattr_uepm_unlock(ump);
792
793                 return (error);
794
795         default:
796                 return (EINVAL);
797         }
798 }
799
800 /*
801  * Vnode operating to retrieve a named extended attribute.
802  */
803 int
804 ufs_getextattr(struct vop_getextattr_args *ap)
805 /*
806 vop_getextattr {
807         IN struct vnode *a_vp;
808         IN int a_attrnamespace;
809         IN const char *a_name;
810         INOUT struct uio *a_uio;
811         OUT size_t *a_size;
812         IN struct ucred *a_cred;
813         IN struct thread *a_td;
814 };
815 */
816 {
817         struct mount *mp = ap->a_vp->v_mount;
818         struct ufsmount *ump = VFSTOUFS(mp);
819         int error;
820
821         ufs_extattr_uepm_lock(ump);
822
823         error = ufs_extattr_get(ap->a_vp, ap->a_attrnamespace, ap->a_name,
824             ap->a_uio, ap->a_size, ap->a_cred, ap->a_td);
825
826         ufs_extattr_uepm_unlock(ump);
827
828         return (error);
829 }
830
831 /*
832  * Real work associated with retrieving a named attribute--assumes that
833  * the attribute lock has already been grabbed.
834  */
835 static int
836 ufs_extattr_get(struct vnode *vp, int attrnamespace, const char *name,
837     struct uio *uio, size_t *size, struct ucred *cred, struct thread *td)
838 {
839         struct ufs_extattr_list_entry *attribute;
840         struct ufs_extattr_header ueh;
841         struct iovec local_aiov;
842         struct uio local_aio;
843         struct mount *mp = vp->v_mount;
844         struct ufsmount *ump = VFSTOUFS(mp);
845         struct inode *ip = VTOI(vp);
846         off_t base_offset;
847         size_t len, old_len;
848         int error = 0;
849
850         if (!(ump->um_extattr.uepm_flags & UFS_EXTATTR_UEPM_STARTED))
851                 return (EOPNOTSUPP);
852
853         if (strlen(name) == 0)
854                 return (EINVAL);
855
856         error = extattr_check_cred(vp, attrnamespace, cred, td, VREAD);
857         if (error)
858                 return (error);
859
860         attribute = ufs_extattr_find_attr(ump, attrnamespace, name);
861         if (!attribute)
862                 return (ENOATTR);
863
864         /*
865          * Allow only offsets of zero to encourage the read/replace
866          * extended attribute semantic.  Otherwise we can't guarantee
867          * atomicity, as we don't provide locks for extended attributes.
868          */
869         if (uio != NULL && uio->uio_offset != 0)
870                 return (ENXIO);
871
872         /*
873          * Find base offset of header in file based on file header size, and
874          * data header size + maximum data size, indexed by inode number.
875          */
876         base_offset = sizeof(struct ufs_extattr_fileheader) +
877             ip->i_number * (sizeof(struct ufs_extattr_header) +
878             attribute->uele_fileheader.uef_size);
879
880         /*
881          * Read in the data header to see if the data is defined, and if so
882          * how much.
883          */
884         bzero(&ueh, sizeof(struct ufs_extattr_header));
885         local_aiov.iov_base = (caddr_t) &ueh;
886         local_aiov.iov_len = sizeof(struct ufs_extattr_header);
887         local_aio.uio_iov = &local_aiov;
888         local_aio.uio_iovcnt = 1;
889         local_aio.uio_rw = UIO_READ;
890         local_aio.uio_segflg = UIO_SYSSPACE;
891         local_aio.uio_td = td;
892         local_aio.uio_offset = base_offset;
893         local_aio.uio_resid = sizeof(struct ufs_extattr_header);
894         
895         /*
896          * Acquire locks.
897          *
898          * Don't need to get a lock on the backing file if the getattr is
899          * being applied to the backing file, as the lock is already held.
900          */
901         if (attribute->uele_backing_vnode != vp)
902                 vn_lock(attribute->uele_backing_vnode, LK_SHARED | LK_RETRY);
903
904         error = VOP_READ(attribute->uele_backing_vnode, &local_aio,
905             IO_NODELOCKED, ump->um_extattr.uepm_ucred);
906         if (error)
907                 goto vopunlock_exit;
908
909         /* Defined? */
910         if ((ueh.ueh_flags & UFS_EXTATTR_ATTR_FLAG_INUSE) == 0) {
911                 error = ENOATTR;
912                 goto vopunlock_exit;
913         }
914
915         /* Valid for the current inode generation? */
916         if (ueh.ueh_i_gen != ip->i_gen) {
917                 /*
918                  * The inode itself has a different generation number
919                  * than the attribute data.  For now, the best solution
920                  * is to coerce this to undefined, and let it get cleaned
921                  * up by the next write or extattrctl clean.
922                  */
923                 printf("ufs_extattr_get (%s): inode number inconsistency (%d, %ju)\n",
924                     mp->mnt_stat.f_mntonname, ueh.ueh_i_gen, (uintmax_t)ip->i_gen);
925                 error = ENOATTR;
926                 goto vopunlock_exit;
927         }
928
929         /* Local size consistency check. */
930         if (ueh.ueh_len > attribute->uele_fileheader.uef_size) {
931                 error = ENXIO;
932                 goto vopunlock_exit;
933         }
934
935         /* Return full data size if caller requested it. */
936         if (size != NULL)
937                 *size = ueh.ueh_len;
938
939         /* Return data if the caller requested it. */
940         if (uio != NULL) {
941                 /* Allow for offset into the attribute data. */
942                 uio->uio_offset = base_offset + sizeof(struct
943                     ufs_extattr_header);
944
945                 /*
946                  * Figure out maximum to transfer -- use buffer size and
947                  * local data limit.
948                  */
949                 len = MIN(uio->uio_resid, ueh.ueh_len);
950                 old_len = uio->uio_resid;
951                 uio->uio_resid = len;
952
953                 error = VOP_READ(attribute->uele_backing_vnode, uio,
954                     IO_NODELOCKED, ump->um_extattr.uepm_ucred);
955                 if (error)
956                         goto vopunlock_exit;
957
958                 uio->uio_resid = old_len - (len - uio->uio_resid);
959         }
960
961 vopunlock_exit:
962
963         if (uio != NULL)
964                 uio->uio_offset = 0;
965
966         if (attribute->uele_backing_vnode != vp)
967                 VOP_UNLOCK(attribute->uele_backing_vnode, 0);
968
969         return (error);
970 }
971
972 /*
973  * Vnode operation to remove a named attribute.
974  */
975 int
976 ufs_deleteextattr(struct vop_deleteextattr_args *ap)
977 /*
978 vop_deleteextattr {
979         IN struct vnode *a_vp;
980         IN int a_attrnamespace;
981         IN const char *a_name;
982         IN struct ucred *a_cred;
983         IN struct thread *a_td;
984 };
985 */
986 {
987         struct mount *mp = ap->a_vp->v_mount;
988         struct ufsmount *ump = VFSTOUFS(mp); 
989         int error;
990
991         ufs_extattr_uepm_lock(ump);
992
993         error = ufs_extattr_rm(ap->a_vp, ap->a_attrnamespace, ap->a_name,
994             ap->a_cred, ap->a_td);
995
996
997         ufs_extattr_uepm_unlock(ump);
998
999         return (error);
1000 }
1001
1002 /*
1003  * Vnode operation to set a named attribute.
1004  */
1005 int
1006 ufs_setextattr(struct vop_setextattr_args *ap)
1007 /*
1008 vop_setextattr {
1009         IN struct vnode *a_vp;
1010         IN int a_attrnamespace;
1011         IN const char *a_name;
1012         INOUT struct uio *a_uio;
1013         IN struct ucred *a_cred;
1014         IN struct thread *a_td;
1015 };
1016 */
1017 {
1018         struct mount *mp = ap->a_vp->v_mount;
1019         struct ufsmount *ump = VFSTOUFS(mp); 
1020         int error;
1021
1022         /*
1023          * XXX: No longer a supported way to delete extended attributes.
1024          */
1025         if (ap->a_uio == NULL)
1026                 return (EINVAL);
1027
1028         ufs_extattr_uepm_lock(ump);
1029
1030         error = ufs_extattr_set(ap->a_vp, ap->a_attrnamespace, ap->a_name,
1031             ap->a_uio, ap->a_cred, ap->a_td);
1032
1033         ufs_extattr_uepm_unlock(ump);
1034
1035         return (error);
1036 }
1037
1038 /*
1039  * Real work associated with setting a vnode's extended attributes;
1040  * assumes that the attribute lock has already been grabbed.
1041  */
1042 static int
1043 ufs_extattr_set(struct vnode *vp, int attrnamespace, const char *name,
1044     struct uio *uio, struct ucred *cred, struct thread *td)
1045 {
1046         struct ufs_extattr_list_entry *attribute;
1047         struct ufs_extattr_header ueh;
1048         struct iovec local_aiov;
1049         struct uio local_aio;
1050         struct mount *mp = vp->v_mount;
1051         struct ufsmount *ump = VFSTOUFS(mp);
1052         struct inode *ip = VTOI(vp);
1053         off_t base_offset;
1054         int error = 0, ioflag;
1055
1056         if (vp->v_mount->mnt_flag & MNT_RDONLY)
1057                 return (EROFS);
1058         if (!(ump->um_extattr.uepm_flags & UFS_EXTATTR_UEPM_STARTED))
1059                 return (EOPNOTSUPP);
1060         if (!ufs_extattr_valid_attrname(attrnamespace, name))
1061                 return (EINVAL);
1062
1063         error = extattr_check_cred(vp, attrnamespace, cred, td, VWRITE);
1064         if (error)
1065                 return (error);
1066
1067         attribute = ufs_extattr_find_attr(ump, attrnamespace, name);
1068         if (!attribute)
1069                 return (ENOATTR);
1070
1071         /*
1072          * Early rejection of invalid offsets/length.
1073          * Reject: any offset but 0 (replace)
1074          *       Any size greater than attribute size limit
1075          */
1076         if (uio->uio_offset != 0 ||
1077             uio->uio_resid > attribute->uele_fileheader.uef_size)
1078                 return (ENXIO);
1079
1080         /*
1081          * Find base offset of header in file based on file header size, and
1082          * data header size + maximum data size, indexed by inode number.
1083          */
1084         base_offset = sizeof(struct ufs_extattr_fileheader) +
1085             ip->i_number * (sizeof(struct ufs_extattr_header) +
1086             attribute->uele_fileheader.uef_size);
1087
1088         /*
1089          * Write out a data header for the data.
1090          */
1091         ueh.ueh_len = uio->uio_resid;
1092         ueh.ueh_flags = UFS_EXTATTR_ATTR_FLAG_INUSE;
1093         ueh.ueh_i_gen = ip->i_gen;
1094         local_aiov.iov_base = (caddr_t) &ueh;
1095         local_aiov.iov_len = sizeof(struct ufs_extattr_header);
1096         local_aio.uio_iov = &local_aiov;
1097         local_aio.uio_iovcnt = 1;
1098         local_aio.uio_rw = UIO_WRITE;
1099         local_aio.uio_segflg = UIO_SYSSPACE;
1100         local_aio.uio_td = td;
1101         local_aio.uio_offset = base_offset;
1102         local_aio.uio_resid = sizeof(struct ufs_extattr_header);
1103
1104         /*
1105          * Acquire locks.
1106          *
1107          * Don't need to get a lock on the backing file if the setattr is
1108          * being applied to the backing file, as the lock is already held.
1109          */
1110         if (attribute->uele_backing_vnode != vp)
1111                 vn_lock(attribute->uele_backing_vnode, LK_EXCLUSIVE | LK_RETRY);
1112
1113         ioflag = IO_NODELOCKED;
1114         if (ufs_extattr_sync)
1115                 ioflag |= IO_SYNC;
1116         error = VOP_WRITE(attribute->uele_backing_vnode, &local_aio, ioflag,
1117             ump->um_extattr.uepm_ucred);
1118         if (error)
1119                 goto vopunlock_exit;
1120
1121         if (local_aio.uio_resid != 0) {
1122                 error = ENXIO;
1123                 goto vopunlock_exit;
1124         }
1125
1126         /*
1127          * Write out user data.
1128          */
1129         uio->uio_offset = base_offset + sizeof(struct ufs_extattr_header);
1130
1131         ioflag = IO_NODELOCKED;
1132         if (ufs_extattr_sync)
1133                 ioflag |= IO_SYNC;
1134         error = VOP_WRITE(attribute->uele_backing_vnode, uio, ioflag,
1135             ump->um_extattr.uepm_ucred);
1136
1137 vopunlock_exit:
1138         uio->uio_offset = 0;
1139
1140         if (attribute->uele_backing_vnode != vp)
1141                 VOP_UNLOCK(attribute->uele_backing_vnode, 0);
1142
1143         return (error);
1144 }
1145
1146 /*
1147  * Real work associated with removing an extended attribute from a vnode.
1148  * Assumes the attribute lock has already been grabbed.
1149  */
1150 static int
1151 ufs_extattr_rm(struct vnode *vp, int attrnamespace, const char *name,
1152     struct ucred *cred, struct thread *td)
1153 {
1154         struct ufs_extattr_list_entry *attribute;
1155         struct ufs_extattr_header ueh;
1156         struct iovec local_aiov;
1157         struct uio local_aio;
1158         struct mount *mp = vp->v_mount;
1159         struct ufsmount *ump = VFSTOUFS(mp);
1160         struct inode *ip = VTOI(vp);
1161         off_t base_offset;
1162         int error = 0, ioflag;
1163
1164         if (vp->v_mount->mnt_flag & MNT_RDONLY)  
1165                 return (EROFS);
1166         if (!(ump->um_extattr.uepm_flags & UFS_EXTATTR_UEPM_STARTED))
1167                 return (EOPNOTSUPP);
1168         if (!ufs_extattr_valid_attrname(attrnamespace, name))
1169                 return (EINVAL);
1170
1171         error = extattr_check_cred(vp, attrnamespace, cred, td, VWRITE);
1172         if (error)
1173                 return (error);
1174
1175         attribute = ufs_extattr_find_attr(ump, attrnamespace, name);
1176         if (!attribute)
1177                 return (ENOATTR);
1178
1179         /*
1180          * Find base offset of header in file based on file header size, and
1181          * data header size + maximum data size, indexed by inode number.
1182          */
1183         base_offset = sizeof(struct ufs_extattr_fileheader) +
1184             ip->i_number * (sizeof(struct ufs_extattr_header) +
1185             attribute->uele_fileheader.uef_size);
1186
1187         /*
1188          * Check to see if currently defined.
1189          */
1190         bzero(&ueh, sizeof(struct ufs_extattr_header));
1191
1192         local_aiov.iov_base = (caddr_t) &ueh;
1193         local_aiov.iov_len = sizeof(struct ufs_extattr_header);
1194         local_aio.uio_iov = &local_aiov;
1195         local_aio.uio_iovcnt = 1;
1196         local_aio.uio_rw = UIO_READ;
1197         local_aio.uio_segflg = UIO_SYSSPACE;
1198         local_aio.uio_td = td;
1199         local_aio.uio_offset = base_offset;
1200         local_aio.uio_resid = sizeof(struct ufs_extattr_header);
1201
1202         /*
1203          * Don't need to get the lock on the backing vnode if the vnode we're
1204          * modifying is it, as we already hold the lock.
1205          */
1206         if (attribute->uele_backing_vnode != vp)
1207                 vn_lock(attribute->uele_backing_vnode, LK_EXCLUSIVE | LK_RETRY);
1208
1209         error = VOP_READ(attribute->uele_backing_vnode, &local_aio,
1210             IO_NODELOCKED, ump->um_extattr.uepm_ucred);
1211         if (error)
1212                 goto vopunlock_exit;
1213
1214         /* Defined? */
1215         if ((ueh.ueh_flags & UFS_EXTATTR_ATTR_FLAG_INUSE) == 0) {
1216                 error = ENOATTR;
1217                 goto vopunlock_exit;
1218         }
1219
1220         /* Valid for the current inode generation? */
1221         if (ueh.ueh_i_gen != ip->i_gen) {
1222                 /*
1223                  * The inode itself has a different generation number than
1224                  * the attribute data.  For now, the best solution is to
1225                  * coerce this to undefined, and let it get cleaned up by
1226                  * the next write or extattrctl clean.
1227                  */
1228                 printf("ufs_extattr_rm (%s): inode number inconsistency (%d, %jd)\n",
1229                     mp->mnt_stat.f_mntonname, ueh.ueh_i_gen, (intmax_t)ip->i_gen);
1230                 error = ENOATTR;
1231                 goto vopunlock_exit;
1232         }
1233
1234         /* Flag it as not in use. */
1235         ueh.ueh_flags = 0;
1236         ueh.ueh_len = 0;
1237
1238         local_aiov.iov_base = (caddr_t) &ueh;
1239         local_aiov.iov_len = sizeof(struct ufs_extattr_header);
1240         local_aio.uio_iov = &local_aiov;
1241         local_aio.uio_iovcnt = 1;
1242         local_aio.uio_rw = UIO_WRITE;
1243         local_aio.uio_segflg = UIO_SYSSPACE;
1244         local_aio.uio_td = td;
1245         local_aio.uio_offset = base_offset;
1246         local_aio.uio_resid = sizeof(struct ufs_extattr_header);
1247
1248         ioflag = IO_NODELOCKED;
1249         if (ufs_extattr_sync)
1250                 ioflag |= IO_SYNC;
1251         error = VOP_WRITE(attribute->uele_backing_vnode, &local_aio, ioflag,
1252             ump->um_extattr.uepm_ucred);
1253         if (error)
1254                 goto vopunlock_exit;
1255
1256         if (local_aio.uio_resid != 0)
1257                 error = ENXIO;
1258
1259 vopunlock_exit:
1260         VOP_UNLOCK(attribute->uele_backing_vnode, 0);
1261
1262         return (error);
1263 }
1264
1265 /*
1266  * Called by UFS when an inode is no longer active and should have its
1267  * attributes stripped.
1268  */
1269 void
1270 ufs_extattr_vnode_inactive(struct vnode *vp, struct thread *td)
1271 {
1272         struct ufs_extattr_list_entry *uele;
1273         struct mount *mp = vp->v_mount;
1274         struct ufsmount *ump = VFSTOUFS(mp);
1275
1276         /*
1277          * In that case, we cannot lock. We should not have any active vnodes
1278          * on the fs if this is not yet initialized but is going to be, so
1279          * this can go unlocked.
1280          */
1281         if (!(ump->um_extattr.uepm_flags & UFS_EXTATTR_UEPM_INITIALIZED))
1282                 return;
1283
1284         ufs_extattr_uepm_lock(ump);
1285
1286         if (!(ump->um_extattr.uepm_flags & UFS_EXTATTR_UEPM_STARTED)) {
1287                 ufs_extattr_uepm_unlock(ump);
1288                 return;
1289         }
1290
1291         LIST_FOREACH(uele, &ump->um_extattr.uepm_list, uele_entries)
1292                 ufs_extattr_rm(vp, uele->uele_attrnamespace,
1293                     uele->uele_attrname, NULL, td);
1294
1295         ufs_extattr_uepm_unlock(ump);
1296 }
1297
1298 #endif /* !UFS_EXTATTR */