Module Name: src Committed By: christos Date: Sun Mar 9 16:10:22 UTC 2025
Modified Files: src/lib/libc/sys: Makefile.inc Added Files: src/lib/libc/sys: extattrctl.2 Log Message: PR/59160: Taylor R Campbell: extattrctl(2): missing man page To generate a diff of this commit: cvs rdiff -u -r1.257 -r1.258 src/lib/libc/sys/Makefile.inc cvs rdiff -u -r0 -r1.1 src/lib/libc/sys/extattrctl.2 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/lib/libc/sys/Makefile.inc diff -u src/lib/libc/sys/Makefile.inc:1.257 src/lib/libc/sys/Makefile.inc:1.258 --- src/lib/libc/sys/Makefile.inc:1.257 Thu Oct 3 12:59:15 2024 +++ src/lib/libc/sys/Makefile.inc Sun Mar 9 12:10:22 2025 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile.inc,v 1.257 2024/10/03 16:59:15 christos Exp $ +# $NetBSD: Makefile.inc,v 1.258 2025/03/09 16:10:22 christos Exp $ # @(#)Makefile.inc 8.3 (Berkeley) 10/24/94 # sys sources @@ -261,6 +261,7 @@ MAN+= accept.2 access.2 acct.2 adjtime.2 chflags.2 chmod.2 chown.2 chroot.2 clock_getcpuclockid2.2 \ clock_settime.2 clone.2 close.2 \ connect.2 dup.2 eventfd.2 execve.2 _exit.2 extattr_get_file.2 \ + extattctl.2 \ fcntl.2 fdatasync.2 fdiscard.2 fhopen.2 \ flock.2 fork.2 fsync.2 getcontext.2 getdents.2 \ getfh.2 getvfsstat.2 getgid.2 getgroups.2 \ Added files: Index: src/lib/libc/sys/extattrctl.2 diff -u /dev/null src/lib/libc/sys/extattrctl.2:1.1 --- /dev/null Sun Mar 9 12:10:23 2025 +++ src/lib/libc/sys/extattrctl.2 Sun Mar 9 12:10:22 2025 @@ -0,0 +1,119 @@ +.\" $NetBSD: extattrctl.2,v 1.1 2025/03/09 16:10:22 christos Exp $ +.\" Copyright (c) 2025 The NetBSD Foundation, Inc. +.\" All rights reserved. +.\" +.\" This code is derived from software contributed to The NetBSD Foundation +.\" by Christos Zoulas. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS +.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS +.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +.\" POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd March 9, 2025 +.Dt EXTATTRCTL 2 +.Os NetBSD +.Sh NAME +.Nm extattrctl +.Nd control extended attributes on a UFS1 filesystem +.Sh SYNOPSIS +.In sys/extattr.h +.In ufs/ufs/extattr.h +.Ft int +.Fn extattrctl "const char *path" "int cmd" "const char *attrname" "int attrnamespace" "const char *filename" +.Sh DESCRIPTION +The +.Fn extattrctl +system call provides low-level control over extended attributes on a UFS1 +filesystem. +It allows enabling, disabling, and managing extended attribute storage +through direct interaction with the filesystem. +.Sh PARAMETERS +.Bl -tag -width indent +.It Fa path +The path to the mount point of the filesystem. +.It Fa cmd +The command to execute. Valid commands include: +.Bl -tag -width indent +.It Dv EXTATTR_CMD_ENABLE +Enable a specific extended attribute. +.It Dv EXTATTR_CMD_DISABLE +Disable a specific extended attribute. +.It Dv EXTATTR_CMD_START +Start extended attribute support on the filesystem. +.It Dv EXTATTR_CMD_STOP +Stop extended attribute support on the filesystem. +.El +.It Fa attrname +The name of the extended attribute (for relevant commands). +.It Fa attrnamespace +The attribute namespace, such as +.Dv EXTATTR_NAMESPACE_USER +or +.Dv EXTATTR_NAMESPACE_SYSTEM. +.It Fa filename +The path to a backing file for extended attribute storage +(if required by the command). +.El +.Sh RETURN VALUES +Upon successful completion, +.Fn extattrctl +returns +.Dv 0 . +Otherwise, +.Dv -1 +is returned, and +.Va errno +is set to indicate the error. +.Sh ERRORS +The +.Fn extattrctl +system call may fail with the following errors: +.Bl -tag -width indent +.It Bq Er ENOTSUP +The filesystem does not support extended attributes. +.It Bq Er EACCES +Permission denied. +.It Bq Er EINVAL +Invalid arguments were provided. +.It Bq Er ENOENT +The specified path, attribute, or file does not exist. +.El +.Sh EXAMPLES +Enable an attribute on a filesystem: +.Bd -literal -offset indent +#include <sys/extattr.h> +#include <ufs/ufs/extattr.h> + +if (extattrctl("/home", EXTATTR_CMD_ENABLE, + "user.comment", EXTATTR_NAMESPACE_USER, NULL) == -1) + err(EXIT_FAILURE, "extattrctl"); +.Ed +.Sh SEE ALSO +.Xr extattr_get_file 2 , +.Xr extattr_set_file 2 , +.Xr extattr_delete_file 2 , +.Xr extattr_list_file 2 +.Sh HISTORY +The +.Fn extattrctl +system call was imported from +.Fx 5.0 +in +.Nx 4.0 .