plan9fox/sys/src/cmd/hjfs/fns.h
cinap_lenrek 9a39427183 hjfs: fix dump / create
getdent() introduced a bug as the qid check fails in
the case when we walk to DUMPROOTQID, but get ROOTQID
in the directory instead.

newentry() getblk(..., GBCREATE) caused the whole
directory to get dumped until it hit a free slot.
we cannot do this because this changes the addresses
of Dentries of files but doesnt update the loctree.

this caused the bogus walks when we hit a different
directory than we expected.

what we do now is the following: newentry() was changed
to never dump anything. it will just read the directory
and return a the address of a free slot or create a
new block having space for one. chancreat() then makes
a loc in the loctree for the free slot, drops the dirent
buffer and calls willmodify() on the new slot. this will
dump the block containing the slot (and possible other
slots) and updates the loctree to the new version.

after that, chancreate() modifies the slot filling the
Dentry. there should be no race, as newentry() skips
slots that have a loc in the loctree.

theres one case where newentry() can dump the block
immidiately when it is called from dump. added new
parameter for that and documented in the comment.

createuserdir() was simplified by just calling chancreat().
to get arround the permission check, a new per channel
flag CHFNOPERM was added.
2012-11-18 00:06:54 +01:00

54 lines
1.6 KiB
C

void* emalloc(int);
void bufinit(int);
Buf* getbuf(Dev *, uvlong, int, int);
void putbuf(Buf *);
void sync(int);
void pack(Buf *, uchar *);
void unpack(Buf *, uchar *);
Dev* newdev(char *);
ThrData* getthrdata(void);
Fs* initfs(Dev *, int, int);
Dentry* getdent(FLoc *, Buf *);
int getfree(Fs *, uvlong *);
int putfree(Fs *, uvlong);
Chan* chanattach(Fs *, int);
Chan* chanclone(Chan *);
int chanwalk(Chan *, char *);
int chancreat(Chan *, char *, int, int);
int chanopen(Chan *, int mode);
int chanwrite(Chan *, void *, ulong, uvlong);
int chanread(Chan *, void *, ulong, uvlong);
int chanstat(Chan *, Dir *);
int chanwstat(Chan *, Dir *);
int permcheck(Fs *, Dentry *, short, int);
char * uid2name(Fs *, short, char *);
int name2uid(Fs *, char *, short *);
void start9p(char *, int);
int chanclunk(Chan *);
int chanremove(Chan *);
int getblk(Fs *, FLoc *, Buf *, uvlong, uvlong *, int);
void initcons(char *);
void shutdown(void);
int fsdump(Fs *);
int willmodify(Fs *, Loc *, int);
void chbegin(Chan *);
void chend(Chan *);
int newqid(Fs *, uvlong *);
Loc * getloc(Fs *, FLoc, Loc *);
int haveloc(Fs *, uvlong, int, Loc *);
Loc * cloneloc(Fs *, Loc *);
void putloc(Fs *, Loc *, int);
int findentry(Fs *, FLoc *, Buf *, char *, FLoc *, int);
void modified(Chan *, Dentry *);
int trunc(Fs *, FLoc *, Buf *, uvlong);
int dprint(char *fmt, ...);
int delete(Fs *, FLoc *, Buf *);
int chref(Fs *, uvlong, int);
int newentry(Fs *, Loc *, Buf *, char *, FLoc *, int);
int namevalid(char *);
int usersload(Fs *, Chan *);
int userssave(Fs *, Chan *);
int ingroup(Fs *, short, short, int);
void workerinit(void);
void writeusers(Fs *);