Print this page
195 Need replacement for nfs/lockd+klm
Reviewed by: Gordon Ross <gordon.ross@nexenta.com>
Reviewed by: Jeremy Jones <jeremy@delphix.com>
Reviewed by: Jeff Biseda <jbiseda@delphix.com>
   1 /*
   2  * CDDL HEADER START
   3  *
   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */

  21 /*
  22  * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.

  23  */
  24 #include <stdio.h>
  25 #include <stdlib.h>
  26 #include <syslog.h>
  27 #include <stdarg.h>
  28 #include "smfcfg.h"
  29 
  30 fs_smfhandle_t *
  31 fs_smf_init(char *fmri, char *instance)
  32 {
  33         fs_smfhandle_t *handle = NULL;
  34         char *svcname, srv[MAXPATHLEN];
  35 
  36         /*
  37          * svc name is of the form svc://network/fs/server:instance1
  38          * FMRI portion is /network/fs/server
  39          */
  40         snprintf(srv, MAXPATHLEN, "%s", fmri + strlen("svc:/"));
  41         svcname = strrchr(srv, ':');
  42         if (svcname != NULL)


 341                 }
 342         } else {
 343                 ret = scf_error();
 344         }
 345         if ((ret != 0) && scf_error() != SCF_ERROR_NONE)
 346                 fprintf(stdout, gettext("%s\n"), scf_strerror(ret));
 347 out:
 348         fs_smf_fini(phandle);
 349         return (ret);
 350 }
 351 
 352 
 353 int
 354 nfs_smf_get_prop(char *prop_name, char *propbuf, char *instance,
 355     scf_type_t sctype, char *svc_name, int *bufsz)
 356 {
 357         return (fs_smf_get_prop(NFS_SMF, prop_name, propbuf,
 358             instance, sctype, svc_name, bufsz));
 359 }
 360 





















 361 int
 362 nfs_smf_set_prop(char *prop_name, char *value, char *instance,
 363     scf_type_t type, char *svc_name)
 364 {
 365         return (fs_smf_set_prop(NFS_SMF, prop_name, value, instance,
 366             type, svc_name));
 367 }
 368 
 369 int
 370 autofs_smf_set_prop(char *prop_name, char *value, char *instance,
 371     scf_type_t type, char *svc_name)
 372 {
 373         return (fs_smf_set_prop(AUTOFS_SMF, prop_name, value, instance,
 374             type, svc_name));
 375 }
 376 
 377 int
 378 autofs_smf_get_prop(char *prop_name, char *propbuf, char *instance,
 379     scf_type_t sctype, char *svc_name, int *bufsz)
 380 {
   1 /*
   2  * CDDL HEADER START
   3  *
   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
  24  * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
  25  */
  26 #include <stdio.h>
  27 #include <stdlib.h>
  28 #include <syslog.h>
  29 #include <stdarg.h>
  30 #include "smfcfg.h"
  31 
  32 fs_smfhandle_t *
  33 fs_smf_init(char *fmri, char *instance)
  34 {
  35         fs_smfhandle_t *handle = NULL;
  36         char *svcname, srv[MAXPATHLEN];
  37 
  38         /*
  39          * svc name is of the form svc://network/fs/server:instance1
  40          * FMRI portion is /network/fs/server
  41          */
  42         snprintf(srv, MAXPATHLEN, "%s", fmri + strlen("svc:/"));
  43         svcname = strrchr(srv, ':');
  44         if (svcname != NULL)


 343                 }
 344         } else {
 345                 ret = scf_error();
 346         }
 347         if ((ret != 0) && scf_error() != SCF_ERROR_NONE)
 348                 fprintf(stdout, gettext("%s\n"), scf_strerror(ret));
 349 out:
 350         fs_smf_fini(phandle);
 351         return (ret);
 352 }
 353 
 354 
 355 int
 356 nfs_smf_get_prop(char *prop_name, char *propbuf, char *instance,
 357     scf_type_t sctype, char *svc_name, int *bufsz)
 358 {
 359         return (fs_smf_get_prop(NFS_SMF, prop_name, propbuf,
 360             instance, sctype, svc_name, bufsz));
 361 }
 362 
 363 /* Get an integer (base 10) property */
 364 int
 365 nfs_smf_get_iprop(char *prop_name, int *rvp, char *instance,
 366     scf_type_t sctype, char *svc_name)
 367 {
 368         char propbuf[32];
 369         int bufsz, rc, val;
 370 
 371         bufsz = sizeof (propbuf);
 372         rc = fs_smf_get_prop(NFS_SMF, prop_name, propbuf,
 373             instance, sctype, svc_name, &bufsz);
 374         if (rc != SA_OK)
 375                 return (rc);
 376         errno = 0;
 377         val = strtol(propbuf, NULL, 10);
 378         if (errno != 0)
 379                 return (SA_BAD_VALUE);
 380         *rvp = val;
 381         return (SA_OK);
 382 }
 383 
 384 int
 385 nfs_smf_set_prop(char *prop_name, char *value, char *instance,
 386     scf_type_t type, char *svc_name)
 387 {
 388         return (fs_smf_set_prop(NFS_SMF, prop_name, value, instance,
 389             type, svc_name));
 390 }
 391 
 392 int
 393 autofs_smf_set_prop(char *prop_name, char *value, char *instance,
 394     scf_type_t type, char *svc_name)
 395 {
 396         return (fs_smf_set_prop(AUTOFS_SMF, prop_name, value, instance,
 397             type, svc_name));
 398 }
 399 
 400 int
 401 autofs_smf_get_prop(char *prop_name, char *propbuf, char *instance,
 402     scf_type_t sctype, char *svc_name, int *bufsz)
 403 {