/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
* Copyright 2012 Milan Jurik. All rights reserved.
*/
#include "libcmdutils.h"
/*
* Gets file descriptors of attribute directories for source and target
* attribute files
*/
int
{
int pwdfd;
int fd1;
int fd2;
return (1);
}
} else {
return (1);
}
return (1);
}
} else {
return (1);
}
return (0);
}
/*
* mv_xattrs - Copies the content of the extended attribute files. Then
* moves the extended system attributes from the input attribute files
* to the target attribute files. Moves the extended system attributes
* from source to the target file. This function returns 0 on success
* and nonzero on error.
*/
int
{
goto error;
}
if (sattr)
goto error;
}
goto error;
}
goto error;
}
goto error;
}
continue;
O_RDONLY)) == -1) {
"cannot open src attribute file");
goto error;
}
"could not stat attribute file");
goto error;
}
"cannot open target attribute file");
goto error;
}
"could not stat attribute file");
goto error;
}
"failed to copy extended attribute "
"from source to target");
goto error;
}
errno = 0;
if (sattr) {
/*
* Gets non default extended system attributes from
* source to copy to target.
*/
&atfd) != 0) {
"Failed to open attribute files");
goto error;
}
/*
* Copy extended system attribute from source
* attribute file to target attribute file
*/
VIEW_READWRITE) != 0)) {
"Permission denied -"
"failed to move system attribute");
else
"failed to move extended "
"system attribute");
goto error;
}
}
if (sattrfd != -1)
if (tattrfd != -1)
if (asfd != -1)
if (atfd != -1)
}
}
errno = 0;
/* Copy extended system attribute from source to target */
VIEW_READWRITE) == 0)
goto done;
else
"failed to move system attribute");
}
if (!sattr)
"%s: %s: cannot move extended attributes, "),
else
"%s: %s: cannot move extended system "
}
done:
if (dirp)
if (sattrfd != -1)
if (tattrfd != -1)
if (asfd != -1)
if (atfd != -1)
if (indfd != -1)
if (outdfd != -1)
return (1);
else
return (0);
}
/*
* The function returns non default extended system attribute list
* associated with 'fname' and returns NULL when an error has occured
* or when only extended system attributes other than archive,
* av_modified or crtime are set.
*
* The function returns system attribute list for the following cases:
*
* - any extended system attribute other than the default attributes
* ('archive', 'av_modified' and 'crtime') is set
* - nvlist has NULL name string
* - nvpair has data type of 'nvlist'
* - default data type.
*/
nvlist_t *
{
char *name;
"%s: %s: fgetattr failed\n"),
return (NULL);
}
else
return (response);
switch (type) {
case DATA_TYPE_BOOLEAN_VALUE:
&value) != 0) {
"nvpair_value_boolean_value "
"failed\n"), cmd);
continue;
}
fattr != F_AV_MODIFIED)
return (response);
break;
case DATA_TYPE_UINT64_ARRAY:
return (response);
break;
case DATA_TYPE_NVLIST:
default:
return (response);
}
}
return (NULL);
}