由买买提看人间百态

topics

全部话题 - 话题: dellock
(共0页)
j***g
发帖数: 19
1
来自主题: sysop版 - D source

get two file names: deleted=".deleted" | "xxx/.deleted"
tmpfile=".tmpfile" | "xxx/.tmpfile"
if ".dellock" cannot be created, return
what if ".dellock" already existed?
Lock ".dellock" QUESTION: can we guarantee ".dellock" to be locked?
why not check the return value? such as
if (flock(fd,LOCK_EX)==-1) return -1;
If that board is readonly, unlock ".dellock" and return.
create tmpfile ".tmpfile"
j***g
发帖数: 19
2
来自主题: sysop版 - D source
1 int
2 delete_range(filename,id1,id2)
3 char *filename ;
4 int id1,id2 ;
5 {
6 struct fileheader fhdr;
7 char tmpfile[ STRLEN ], deleted[ STRLEN ];
8 int fdr, fdw, fd;
9 int count;
10
11 tmpfilename( filename, tmpfile, deleted );
12 if((fd = open(".dellock",O_RDWR|O_CREAT|O_APPEND, 0644)) == -1)
13 return -1;
14 flock(fd,LOCK_EX);
15
16 if((fdr
(共0页)