meta_patch.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* 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
* 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 2003 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* Just in case we're not in a build environment, make sure that
* TEXT_DOMAIN gets set to something.
*/
#if !defined(TEXT_DOMAIN)
#define TEXT_DOMAIN "SYS_TEST"
#endif
/*
*/
#include <meta.h>
#include <string.h>
/*
* patch filesystem lines into vfstab file, return tempfilename
*/
int
char *cmpname, /* filesystem mount point or */
/* "swap" if updating swap partition */
char *vname, /* vfstab file name */
char *old_bdevname, /* old name of block device, needed */
/* for deciding which of multiple */
/* swap file entries to change */
/* if NULL then not changing swap */
int doit, /* really patch file */
int verbose, /* show what we're doing */
char **tname, /* returned temp file name */
)
{
char buf[512];
char cdev[512];
char bdev[512];
char mntpt[512];
char fstype[512];
char fsckpass[512];
char mntboot[512];
char mntopt[512];
int gotfs = 0;
/* or fstype if swap */
char *char_device = chrname;
/* check names */
/* get temp names */
/* check if going to update swap entry in file */
/* if so then compare against file system type */
char_device = &cdev[0];
}
/* copy vfstab file, replace filesystem line */
goto out;
}
goto out;
}
if (doit) {
goto out;
}
goto out;
}
goto out;
}
}
/* check that have all required params from vfstab file */
/* or that the line isnt a comment */
/* or that the block device matches if changing swap */
/* the last check is needed since there may be multiple */
/* entries of swap in the file, and so the fstype is not */
/* a sufficient check */
((old_bdevname != NULL) &&
if (doit) {
goto out;
}
}
continue;
}
if (verbose) {
"Delete the following line from %s:\n\n"),
vname);
(void) printf(
"Add the following line to %s:\n\n"),
vname);
(void) printf("%s\t%s\t%s\t%s\t%s\t%s\t%s\n\n",
}
if (doit) {
goto out;
}
}
gotfs = 1;
}
goto out;
}
if (! gotfs) {
goto out;
}
goto out;
}
if (doit) {
goto out;
}
}
/* return success */
return (0);
/* cleanup, return error */
out:
}
return (-1);
}
/*
* set filesystem device name in vfstab
*/
int
char *fsname, /* filesystem mount point */
char *vname, /* vfstab file name */
)
{
int doit = 1;
int verbose = 0;
int rval = -1;
/* check names */
/* replace lines in vfstab */
ep) != 0) {
goto out;
}
/* rename temp file on top of real one */
goto out;
}
rval = 0;
/* cleanup, return error */
out:
if (doit)
}
return (rval);
}
/*
* set filesystem device name in vfstab
*/
int
char *vname, /* vfstab file name */
char *old_bdevname, /* block device name to change */
)
{
int doit = 1;
int verbose = 0;
int rval = -1;
/* check names */
/* replace lines in vfstab */
goto out;
}
/* rename temp file on top of real one */
goto out;
}
rval = 0;
/* cleanup, return error */
out:
if (doit)
}
return (rval);
}