/*
* 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.
*/
/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
/*
* Portions of this source code were derived from Berkeley 4.3 BSD
* under license from the Regents of the University of California.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* ff -- obtain file names from reading filesystem
*/
#include <stdio.h>
#include <stdlib.h>
#include <strings.h>
#include <errno.h>
#include <fcntl.h>
#include <unistd.h>
#include <pwd.h>
#include "roll_log.h"
union {
} real_fs;
struct ilist {
struct htab
{
} *htab;
char *strngtab;
long hsize;
int strngloc;
int strngtab_size;
struct dirstuff {
int loc;
};
int mflg = 0;
int fi;
int nhent;
int nxfile;
int inode_reads;
int passwd_lookups;
/*
* Function prototypes
*/
int cmp(int a, int b, int s);
void out_multilinks();
void usage();
int extend_strngtab(unsigned int size);
long atol();
char *strcpy();
char *prefix;
int nerror;
extern int optind;
extern char *optarg;
char *subopts [] = {
#define A_FLAG 0
"a",
"m",
"s",
};
int
{
long n;
int opt;
char *p;
int first = 0;
switch (opt) {
case 'a':
Aflg++;
break;
case 'I':
Iflg++;
break;
case 'c':
Cflg++;
break;
case 'l':
Lflg++;
perror("open");
"ff: unable to open temp file, -l ignored\n");
Lflg = 0;
}
break;
case 'm':
Mflg++;
break;
case 'n':
Nflg++;
break;
case 'o':
/*
* ufs specific options.
*/
suboptions = optarg;
if (*suboptions == '\0')
usage();
while (*suboptions != '\0') {
switch ((getsubopt(&suboptions,
case A_FLAG:
aflg++;
break;
case M_FLAG:
mflg++;
break;
case S_FLAG:
sflg++;
break;
default:
usage();
}
}
break;
case 'i':
if ((n = atoi(p)) == 0)
break;
iflg++;
}
break;
case 'p':
pflg++;
break;
case 's':
Sflg++;
break;
case 'u':
uflg++;
break;
case '?':
usage();
}
}
while (argc--) {
argv++;
}
if (Lflg) {
}
if (nerror)
return (32);
return (0);
}
void
{
int i, j, c;
if (fi < 0) {
nerror++;
return;
}
nhent = 0;
sync();
nerror++;
return;
}
nerror++;
return;
}
nerror++;
return;
}
/* If fs is logged, roll the log. */
switch (rl_roll_log(file)) {
case RL_SUCCESS:
/*
* Reread the superblock. Rolling the log may have
* changed it.
*/
break;
case RL_SYSERR:
(void) printf("Warning: Cannot roll log for %s. %s\n",
break;
default:
(void) printf("Warning: Cannot roll log for %s.\n ",
file);
break;
}
}
(void) printf("not enough memory to allocate tables\n");
nerror++;
return;
}
strngloc = 0;
(void) printf("not enough memory to allocate tables\n");
nerror++;
return;
}
ino = 0;
}
ino++;
}
}
ino = 0;
}
ino++;
}
}
ino = 0;
}
ino++;
}
}
}
void
{
int i;
if (mflg)
for (i = 0; i < iflg; i++)
}
return;
return;
}
}
}
void
{
return;
int nmlen;
continue;
if (hp == 0)
continue;
continue;
if (!extend_strngtab(STRNGTAB_INCR)) {
perror("ncheck: can't grow string table\n");
exit(32);
}
}
}
}
void
{
int k;
return;
continue;
goto pr;
break;
continue;
if (mflg)
(void) printf("mode %-6o uid %-5ld gid %-5ld ino ",
pr:
if ((!Aflg ||
Asign)) &&
if (Iflg == 0)
(void) printf("/.");
if (Sflg)
(void) printf("\t%6lld",
if (uflg)
(void) printf("\t%s",
(void) printf("\n");
}
}
}
}
/*
* get next entry in a directory.
*/
struct direct *
{
for (;;) {
return (NULL);
if (d == 0)
return (NULL);
}
continue;
return (dp);
}
}
int
{
return (1);
return (0);
}
void
{
if (i == UFSROOTINO)
return;
return;
}
if (lev > 10) {
return;
}
if (pflg)
else
}
struct htab *
{
return (hp);
}
if (ef == 0)
return (0);
"ff: hsize of %ld is too small\n", hsize);
exit(32);
}
return (hp);
}
void
{
int i;
int got;
"ff: llseek error %lx %lx\n",
for (i = 0; i < cnt; i++)
buf[i] = 0;
return;
}
perror("read");
for (i = 0; i < cnt; i++)
buf[i] = 0;
}
}
{
if (i < NDADDR)
i -= NDADDR;
return ((diskaddr_t)0);
}
return ((diskaddr_t)ibuf[i]);
}
struct dinode *
{
int ioff;
"bad inode number %ld to ginode\n", inumber);
exit(32);
}
inode_reads++;
}
return (ibuf);
}
struct name_ent {
int name_uid;
char *name_string;
};
char *
{
int h_index;
return (hp->name_string);
}
}
} else {
}
return (hp->name_string);
}
int
cmp(int a, int b, int s)
{
if (s == '+')
return (a > b);
if (s == '-')
return (a < -(b));
return (a == b);
}
/*
* We can't do this one by reading the disk directly, since there
* is no guarantee that the file is even on a local disk.
*/
{
return (0);
}
}
void
{
int length;
perror("fseek");
exit(32);
} else
"\nmultilink files\nIno\tLinks\tPathname\n\n");
while (length-- > 0)
} else
}
void
usage()
{
"ufs usage: ff [-F ufs] [generic options] [-o a,m,s] special\n");
exit(32);
}
/*
* Extend or create the string table.
* Preserves contents.
* Return non-zero for success.
*/
int
{
strngtab_size += size;
return ((int)strngtab);
}