Skip to content

Commit

Permalink
PSARC 2002/240 ZFS
Browse files Browse the repository at this point in the history
6338653 Integrate ZFS
PSARC 2004/652 - DKIOCFLUSH
5096886 Write caching disks need mechanism to flush cache to physical media
  • Loading branch information
ahrens committed Oct 31, 2005
1 parent f1b6474 commit fa9e406
Show file tree
Hide file tree
Showing 513 changed files with 91,621 additions and 1,906 deletions.
7 changes: 7 additions & 0 deletions usr/src/Makefile.lint
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ COMMON_SUBDIRS = \
cmd/fs.d/udfs/mount \
cmd/fs.d/ufs/mount \
cmd/fs.d/ufs/fsirand\
cmd/fs.d/zfs/fstyp \
cmd/fuser \
cmd/gcore \
cmd/getconf \
Expand Down Expand Up @@ -272,12 +273,16 @@ COMMON_SUBDIRS = \
cmd/xstr \
cmd/yes \
cmd/yppasswd \
cmd/zdb \
cmd/zdump \
cmd/zfs \
cmd/zlogin \
cmd/zoneadm \
cmd/zoneadmd \
cmd/zonecfg \
cmd/zonename \
cmd/zpool \
cmd/ztest \
lib/abi \
lib/auditd_plugins \
lib/crypt_modules \
Expand Down Expand Up @@ -349,6 +354,8 @@ COMMON_SUBDIRS = \
lib/libwanboot \
lib/libwanbootutil \
lib/libxnet \
lib/libzfs \
lib/libzfs_jni \
lib/libzonecfg \
lib/libzoneinfo \
lib/lvm \
Expand Down
2 changes: 2 additions & 0 deletions usr/src/Targetdirs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ ROOT.SYS= \
/etc/dfs \
/etc/fs \
/etc/fs/nfs \
/etc/fs/zfs \
/etc/ftpd \
/etc/rpcsec \
/etc/security \
Expand Down Expand Up @@ -307,6 +308,7 @@ ROOT.SYS2= \
/usr/lib/fs \
/usr/lib/fs/nfs \
/usr/lib/fs/proc \
/usr/lib/fs/zfs \
/usr/lib/mdb \
/usr/lib/mdb/kvm \
/usr/lib/mdb/proc \
Expand Down
11 changes: 9 additions & 2 deletions usr/src/cmd/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ FIRST_SUBDIRS= \

COMMON_SUBDIRS= \
agents \
availdevs \
lp \
perl \
man \
Expand Down Expand Up @@ -420,13 +421,17 @@ COMMON_SUBDIRS= \
yes \
ypcmd \
yppasswd \
zdb \
zdump \
zfs \
zic \
zlogin \
zoneadm \
zoneadmd \
zonecfg \
zonename
zonename \
zpool \
ztest

i386_SUBDIRS= \
addbadsec \
Expand Down Expand Up @@ -664,12 +669,14 @@ MSGSUBDIRS= \
xargs \
yppasswd \
zdump \
zfs \
zic \
zlogin \
zoneadm \
zoneadmd \
zonecfg \
zonename
zonename \
zpool

sparc_MSGSUBDIRS= \
fruadm \
Expand Down
4 changes: 2 additions & 2 deletions usr/src/cmd/allocate/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
# CDDL HEADER END
#
#
# Copyright 1989, 1998-2002 Sun Microsystems, Inc. All rights reserved.
# Copyright 2005 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# ident "%Z%%M% %I% %E% SMI"
Expand Down Expand Up @@ -84,7 +84,7 @@ $(ROOTSECDEV)/% := GROUP = bin

$(ROOTSECLIB)/% := FILEMODE = 0751

allocate := LDLIBS += -lbsm -lsecdb
allocate := LDLIBS += -lbsm -lsec -lsecdb

.KEEP_STATE:

Expand Down
25 changes: 5 additions & 20 deletions usr/src/cmd/allocate/allocate3.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* CDDL HEADER END
*/
/*
* Copyright 1999-2003 Sun Microsystems, Inc. All rights reserved.
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/

Expand Down Expand Up @@ -255,24 +255,7 @@ list_devices(int optflg, uid_t uid, char *device)
static int
newdac(char *file, uid_t owner, gid_t group, o_mode_t mode)
{
int err = 0;
aclent_t min_acl[MIN_ACL_ENTRIES];

min_acl[0].a_type = USER_OBJ;
min_acl[0].a_id = owner;
min_acl[0].a_perm = ((mode & 0700) >> 6);

min_acl[1].a_type = GROUP_OBJ;
min_acl[1].a_id = group;
min_acl[1].a_perm = ((mode & 0070) >> 3);

min_acl[2].a_type = CLASS_OBJ;
min_acl[2].a_id = (uid_t)-1;
min_acl[2].a_perm = ((mode & 0070) >> 3);

min_acl[3].a_type = OTHER_OBJ;
min_acl[3].a_id = (uid_t)-1;
min_acl[3].a_perm = (mode & 0007);
int err = 0;

do {
if (chown(file, owner, group) == -1) {
Expand All @@ -281,7 +264,9 @@ newdac(char *file, uid_t owner, gid_t group, o_mode_t mode)
}
} while (fdetach(file) == 0);

if (acl(file, SETACL, MIN_ACL_ENTRIES, min_acl) < 0) {
err = acl_strip(file, owner, group, (mode_t)mode);

if (err != 0) {
dperror("newdac, unable to setacl");
err = SETACL_PERR;
}
Expand Down
65 changes: 65 additions & 0 deletions usr/src/cmd/availdevs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License, Version 1.0 only
# (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
# or http://www.opensolaris.org/os/licensing.
# 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 2005 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# ident "%Z%%M% %I% %E% SMI"
#

PROG= availdevs
OBJS_COMMON= availdevs.o
OBJS= $(OBJS_COMMON)
SRCS= $(OBJS_COMMON:%.o=%.c)

include ../Makefile.cmd

ROOTCMDDIR= $(ROOTLIB)/zfs

INCS += -I../../lib/libzfs_jni/common \
-I/usr/include/libxml2

LDLIBS += -lzfs_jni -lxml2
CPPFLAGS += $(INCS) -D_LARGEFILE64_SOURCE=1 -D_REENTRANT

.KEEP_STATE:

.PARALLEL:

all: $(PROG)

$(PROG): $(OBJS)
$(LINK.c) -o $@ $(OBJS) $(LDLIBS)
$(POST_PROCESS)

%.o: %.c
$(COMPILE.c) -o $@ $<
$(POST_PROCESS_O)

install: all $(ROOTCMD)

clean:
$(RM) $(OBJS)

FRC:

include ../Makefile.targ
158 changes: 158 additions & 0 deletions usr/src/cmd/availdevs/availdevs.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (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
* or http://www.opensolaris.org/os/licensing.
* 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 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/

#pragma ident "%Z%%M% %I% %E% SMI"

#include "availdevs.h"
#include <libzfs_jni_diskmgt.h>
#include <libxml/parser.h>

/*
* Function prototypes
*/

static void handle_error(const char *, va_list);
static int add_disk_to_xml(dmgt_disk_t *, void *);
static xmlDocPtr create_doc();
int main();

/*
* Static functions
*/

static void
handle_error(const char *fmt, va_list ap)
{
(void) vfprintf(stderr, fmt, ap);
(void) fprintf(stderr, "\n");
}

static int
add_disk_to_xml(dmgt_disk_t *dp, void *data)
{
int i, n;
char tmp[64];
xmlNodePtr available = *((xmlNodePtr *)data);

xmlNodePtr disk = xmlNewChild(
available, NULL, (xmlChar *)ELEMENT_DISK, NULL);
xmlSetProp(disk,
(xmlChar *)ATTR_DISK_NAME, (xmlChar *)dp->name);
n = snprintf(tmp, sizeof (tmp) - 1, "%llu", dp->size);
tmp[n] = '\0';
xmlSetProp(disk, (xmlChar *)ATTR_DISK_SIZE, (xmlChar *)tmp);

if (dp->aliases != NULL) {
for (i = 0; dp->aliases[i] != NULL; i++) {
xmlNodePtr alias = xmlNewChild(
disk, NULL, (xmlChar *)ELEMENT_ALIAS, NULL);
xmlSetProp(alias,
(xmlChar *)ATTR_ALIAS_NAME,
(xmlChar *)dp->aliases[i]);
}
}

if (dp->slices != NULL) {
for (i = 0; dp->slices[i] != NULL; i++) {
dmgt_slice_t *sp = dp->slices[i];
xmlNodePtr slice = xmlNewChild(
disk, NULL, (xmlChar *)ELEMENT_SLICE, NULL);
xmlSetProp(slice,
(xmlChar *)ATTR_SLICE_NAME, (xmlChar *)sp->name);

n = snprintf(tmp, sizeof (tmp) - 1, "%llu", sp->size);
tmp[n] = '\0';
xmlSetProp(slice, (xmlChar *)ATTR_SLICE_SIZE,
(xmlChar *)tmp);

n = snprintf(tmp, sizeof (tmp) - 1, "%llu", sp->start);
tmp[n] = '\0';
xmlSetProp(slice, (xmlChar *)ATTR_SLICE_START,
(xmlChar *)tmp);

if (sp->used_name != NULL) {
xmlSetProp(slice,
(xmlChar *)ATTR_SLICE_USED_NAME,
(xmlChar *)sp->used_name);
}

if (sp->used_by != NULL) {
xmlSetProp(slice, (xmlChar *)ATTR_SLICE_USED_BY,
(xmlChar *)sp->used_by);
}
}
}

return (0);
}

static xmlDocPtr
create_doc(void)
{
/* Create the XML document */
xmlDocPtr doc = xmlNewDoc((xmlChar *)"1.0");

/* Create the root node */
xmlNodePtr root = xmlNewDocNode(
doc, NULL, (xmlChar *)ELEMENT_ROOT, NULL);
xmlAddChild((xmlNodePtr) doc, (xmlNodePtr)root);

/* Create the available node */
xmlNewChild(root, NULL, (xmlChar *)ELEMENT_AVAILABLE, NULL);

return (doc);
}

/*
* Main entry to availdisks.
*
* @return 0 on successful exit, non-zero otherwise
*/
int
main(void)
{
int error;
xmlDocPtr doc;
xmlNodePtr root;
xmlNodePtr available;

/* diskmgt.o error handler */
dmgt_set_error_handler(handle_error);

doc = create_doc();
root = xmlDocGetRootElement(doc);
available = xmlGetLastChild(root);

error = dmgt_avail_disk_iter(add_disk_to_xml, &available);
if (!error) {
/* Print out XML */
xmlDocFormatDump(stdout, doc, 1);
}

xmlFreeDoc(doc);

return (error != 0);
}
Loading

0 comments on commit fa9e406

Please sign in to comment.