Changeset View
Changeset View
Standalone View
Standalone View
sbin/fsdb/fsdb.c
Show All 39 Lines | |||||
#include <err.h> | #include <err.h> | ||||
#include <grp.h> | #include <grp.h> | ||||
#include <histedit.h> | #include <histedit.h> | ||||
#include <pwd.h> | #include <pwd.h> | ||||
#include <stdint.h> | #include <stdint.h> | ||||
#include <string.h> | #include <string.h> | ||||
#include <time.h> | #include <time.h> | ||||
#include <timeconv.h> | #include <timeconv.h> | ||||
#include <capsicum_helpers.h> | |||||
#include <ufs/ufs/dinode.h> | #include <ufs/ufs/dinode.h> | ||||
#include <ufs/ufs/dir.h> | #include <ufs/ufs/dir.h> | ||||
#include <ufs/ffs/fs.h> | #include <ufs/ffs/fs.h> | ||||
#include "fsdb.h" | #include "fsdb.h" | ||||
#include "fsck.h" | #include "fsck.h" | ||||
static void usage(void) __dead2; | static void usage(void) __dead2; | ||||
int cmdloop(void); | int cmdloop(void); | ||||
static int compare_blk32(uint32_t *wantedblk, uint32_t curblk); | static int compare_blk32(uint32_t *wantedblk, uint32_t curblk); | ||||
static int compare_blk64(uint64_t *wantedblk, uint64_t curblk); | static int compare_blk64(uint64_t *wantedblk, uint64_t curblk); | ||||
static int founddatablk(uint64_t blk); | static int founddatablk(uint64_t blk); | ||||
static int find_blks32(uint32_t *buf, int size, uint32_t *blknum); | static int find_blks32(uint32_t *buf, int size, uint32_t *blknum); | ||||
static int find_blks64(uint64_t *buf, int size, uint64_t *blknum); | static int find_blks64(uint64_t *buf, int size, uint64_t *blknum); | ||||
static int find_indirblks32(uint32_t blk, int ind_level, uint32_t *blknum); | static int find_indirblks32(uint32_t blk, int ind_level, uint32_t *blknum); | ||||
static int find_indirblks64(uint64_t blk, int ind_level, uint64_t *blknum); | static int find_indirblks64(uint64_t blk, int ind_level, uint64_t *blknum); | ||||
cap_channel_t *cappwd, *capgrp; | |||||
oshogbo: New line after this. | |||||
static void | static void | ||||
usage(void) | usage(void) | ||||
{ | { | ||||
fprintf(stderr, "usage: fsdb [-d] [-f] [-r] fsname\n"); | fprintf(stderr, "usage: fsdb [-d] [-f] [-r] fsname\n"); | ||||
exit(1); | exit(1); | ||||
} | } | ||||
/* | /* | ||||
▲ Show 20 Lines • Show All 152 Lines • ▼ Show 20 Lines | cmdloop(void) | ||||
const char *elline; | const char *elline; | ||||
int cmd_argc, rval = 0, known; | int cmd_argc, rval = 0, known; | ||||
#define scratch known | #define scratch known | ||||
char **cmd_argv; | char **cmd_argv; | ||||
struct cmdtable *cmdp; | struct cmdtable *cmdp; | ||||
History *hist; | History *hist; | ||||
EditLine *elptr; | EditLine *elptr; | ||||
HistEvent he; | HistEvent he; | ||||
cap_channel_t *capcas; | |||||
curinode = ginode(UFS_ROOTINO); | curinode = ginode(UFS_ROOTINO); | ||||
curinum = UFS_ROOTINO; | curinum = UFS_ROOTINO; | ||||
printactive(0); | printactive(0); | ||||
hist = history_init(); | hist = history_init(); | ||||
history(hist, &he, H_SETSIZE, 100); /* 100 elt history buffer */ | history(hist, &he, H_SETSIZE, 100); /* 100 elt history buffer */ | ||||
elptr = el_init("fsdb", stdin, stdout, stderr); | elptr = el_init("fsdb", stdin, stdout, stderr); | ||||
el_set(elptr, EL_EDITOR, "emacs"); | el_set(elptr, EL_EDITOR, "emacs"); | ||||
el_set(elptr, EL_PROMPT, prompt); | el_set(elptr, EL_PROMPT, prompt); | ||||
el_set(elptr, EL_HIST, history, hist); | el_set(elptr, EL_HIST, history, hist); | ||||
el_source(elptr, NULL); | el_source(elptr, NULL); | ||||
capcas = cap_init(); | |||||
if (capcas == NULL) | |||||
Not Done Inline ActionsSome ident are broken in this block. oshogbo: Some ident are broken in this block. | |||||
Not Done Inline ActionsUnfortunately, this file doesn't conform to our usual code style. Here, indentation is by four spaces, and eight consecutive spaces are converted into a tab. markj: Unfortunately, this file doesn't conform to our usual code style. Here, indentation is by four… | |||||
err(1, "Unable to contact Casper"); | |||||
/* | |||||
* Here we enter capability mode. Further down access to global | |||||
* namespaces (e.g filesystem) is restricted (see capsicum(4)). | |||||
* We must connect(2) our socket before this point. | |||||
*/ | |||||
if (caph_enter_casper() < 0) { | |||||
err(1, "unable to enter capability mode"); | |||||
} | |||||
cappwd = cap_service_open(capcas, "system.pwd"); | |||||
if(cappwd == NULL) | |||||
err(1, "Unable to open system.pwd service"); | |||||
capgrp = cap_service_open(capcas, "system.grp"); | |||||
if(capgrp == NULL) | |||||
err(1, "Unable to open system.grp service"); | |||||
cap_close(capcas); | |||||
while ((elline = el_gets(elptr, &scratch)) != NULL && scratch != 0) { | while ((elline = el_gets(elptr, &scratch)) != NULL && scratch != 0) { | ||||
if (debug) | if (debug) | ||||
printf("command `%s'\n", elline); | printf("command `%s'\n", elline); | ||||
history(hist, &he, H_ENTER, elline); | history(hist, &he, H_ENTER, elline); | ||||
line = strdup(elline); | line = strdup(elline); | ||||
▲ Show 20 Lines • Show All 986 Lines • Show Last 20 Lines |
New line after this.