/*
* 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 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* lockfs
* user interface to lockfs functionality
*/
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
/*
* command line processing
*/
extern char *optarg;
extern int optind;
extern int opterr;
extern void exit();
static void exitusage();
static void printstatusline(char *, char *, char *);
static void printstatus(char *);
static void flushfs(char *);
static void lockfs(char *);
static void getmntnames();
static void getcmdnames(int, char **, int);
/*
* -a = all
* -v = verbose
*/
int all = 0;
int verbose = 0;
/*
* exitstatus
* 0 all ok
* 1 internal error
* 2 system call error
*/
int exitstatus = 0;
/*
* list of filenames
*/
struct filename {
char *fn_name;
};
/*
* default request is `file system lock status'
* default lock type is `unlock'
* -wnduhfe changes them
*/
/*
* default comment is null
* -c changes it
*/
/*
* for prettyprint
*/
int firsttime = 0;
/*
* no unlocks printed
*/
int no_unlocks_printed = 0;
/*
*/
{ \
if (verbose) \
exitstatus = 2; \
}
/*
* forward reference
*/
char *malloc();
int
{
int c;
exitstatus = 0;
/*
* process command line
*/
opterr = 0;
optarg = 0;
switch (c) {
case 'v':
verbose = 1;
break;
case 'f':
break;
case 'w':
lock = LOCKFS_WLOCK;
break;
case 'n':
lock = LOCKFS_NLOCK;
break;
case 'd':
lock = LOCKFS_DLOCK;
break;
case 'h':
lock = LOCKFS_HLOCK;
break;
case 'e':
lock = LOCKFS_ELOCK;
break;
case 'u':
lock = LOCKFS_ULOCK;
break;
case 'a':
all = 1;
break;
case 'c':
break;
default:
exitusage();
break;
}
if (argc == 1) {
no_unlocks_printed = 1;
all = 1;
}
if (all)
/*
*/
getmntnames();
else
/*
* use command line
*/
/*
* for each filename, doit
*/
switch (request) {
case _FIOLFSS:
break;
case _FIOLFS:
break;
case _FIOFFS:
break;
default:
break;
}
}
/*
* all done
*/
return (exitstatus);
}
/*
* exitusage
* bad command line, give hint
*/
void
{
printf("usage: lockfs [-dfhnuw] [-c string] [-a] [file system ...]\n");
exit(1);
}
/*
* printstatusline
* prettyprint the status line
*/
void
{
if (firsttime++ == 0)
}
/*
* printstatus
* get and prettyprint file system lock status
*/
void
{
int fd;
int fsmod = 0;
char *locktype;
if (fd == -1) {
else
exitstatus = 2;
return;
}
exitstatus = 2;
return;
}
case LOCKFS_ULOCK:
if (no_unlocks_printed)
goto out;
if (LOCKFS_IS_BUSY(&lf))
locktype = "(unlock)";
else
locktype = "unlock";
break;
case LOCKFS_WLOCK:
if (LOCKFS_IS_BUSY(&lf))
locktype = "(write)";
else {
locktype = "write";
}
break;
case LOCKFS_NLOCK:
if (LOCKFS_IS_BUSY(&lf))
locktype = "(name)";
else
locktype = "name";
break;
case LOCKFS_DLOCK:
locktype = "delete";
if (LOCKFS_IS_BUSY(&lf))
locktype = "(delete)";
else
locktype = "delete";
break;
case LOCKFS_HLOCK:
if (LOCKFS_IS_BUSY(&lf))
locktype = "(hard)";
else {
locktype = "hard";
}
break;
case LOCKFS_ELOCK:
if (LOCKFS_IS_BUSY(&lf))
locktype = "(error)";
else {
locktype = "error";
}
break;
default:
if (LOCKFS_IS_BUSY(&lf))
locktype = "(unknown)";
else
locktype = "unknown";
break;
}
if (fsmod)
out:
}
/*
* flushfs
* push and invalidate at least the data that is *currently* dirty
*/
void
{
int fd;
if (fd == -1) {
exitstatus = 2;
return;
}
exitstatus = 2;
return;
}
}
/*
* lockfs
* lock the file system
*/
void
{
int fd;
if (fd == -1) {
exitstatus = 2;
return;
}
exitstatus = 2;
return;
}
if (LOCKFS_IS_HLOCK(&lf))
if (LOCKFS_IS_ELOCK(&lf))
if (LOCKFS_IS_WLOCK(&lf))
}
exitstatus = 2;
return;
}
}
/*
* getmntnames
*/
void
{
int fnlen;
exit(32);
}
continue;
if (fnpc)
else
}
}
/*
* getcmdnames
* file names from command line
*/
void
{
if (fnpc)
else
}
}