|
Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com |
Re: Symlinks and Cryogenic Sleep
Subject: Re: Symlinks and Cryogenic Sleep
From: Goetz Babin-Ebell (babinebell
TRUSTCENTER.DE)
Date: Tue Jan 04 2000 - 05:11:19 CST
- Next message: pda
ING.PUC.CL: "Re: irix-soundplayer.sh"
- Previous message: Bill Ralph: "SHADOW and Y2K Problems"
- In reply to: Olaf Kirch: "Symlinks and Cryogenic Sleep"
- Next in thread: Mikael Olsson: "Re: Symlinks and Cryogenic Sleep"
- Reply: Goetz Babin-Ebell: "Re: Symlinks and Cryogenic Sleep"
- Reply: Mikael Olsson: "Re: Symlinks and Cryogenic Sleep"
- Reply: pedward
WEBCOM.COM: "Re: Symlinks and Cryogenic Sleep"
- Reply: Christos Zoulas: "Re: Symlinks and Cryogenic Sleep"
- Reply: Marc Heuse: "Re: Symlinks and Cryogenic Sleep"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
At 21:24 03.01.00 +0100, Olaf Kirch wrote:
>Hi all,
Hallo Olaf,
>when you're dealing with files in /tmp that are supposed to be re-opened
>(rather than opened once and then discarded) there's an established
>way to do it which goes like this:
>
> if (lstat(fname, &stb1) >= 0 && S_ISREG(stb1.st_mode)) {
> fd = open(fname, O_RDWR);
> if (fd < 0 || fstat(fd, &stb2) < 0
> || ino_or_dev_mismatch(&stb1, &stb2))
> raise_big_stink()
> } else {
> /* do the O_EXCL thing */
> }
I did something that way:
FILE *DoOpen(const char *cpFile, long bAppend)
{
FILE *spNew;
FILE *spTest;
struct stat sStat;
spTest = fopen(cpFile,"a");
if (!spTest)
{
Log("ERR FILE OPEN",cpFile);
return NULL;
}
if (lstat(cpFile,&sStat))
{
Log("ERR STAT",cpFile);
return NULL;
}
if ((sStat.st_mode & S_IFMT) == S_IFLNK)
{
fclose(spTest);
Log("ERR ISLINK",cpFile);
return NULL;
}
if (bAppend)
spNew = spTest;
else
{
spNew = freopen(cpFile,"w",spTest);
fclose(spTest);
}
if (!spNew)
{
Log("ERR FILE OPEN",cpFile);
return NULL;
}
return spFile;
}
Comments ?
Improvements ?
By
Goetz
-- Goetz Babin-Ebell, TC TrustCenter GmbH, http://www.trustcenter.de Sonninstr. 24-28, 20097 Hamburg, Germany Tel.: +49-(0)40 80 80 26 -0, Fax: +49-(0)40 80 80 26 -126
- Next message: pda
ING.PUC.CL: "Re: irix-soundplayer.sh"
- Previous message: Bill Ralph: "SHADOW and Y2K Problems"
- In reply to: Olaf Kirch: "Symlinks and Cryogenic Sleep"
- Next in thread: Mikael Olsson: "Re: Symlinks and Cryogenic Sleep"
- Reply: Goetz Babin-Ebell: "Re: Symlinks and Cryogenic Sleep"
- Reply: Mikael Olsson: "Re: Symlinks and Cryogenic Sleep"
- Reply: pedward
WEBCOM.COM: "Re: Symlinks and Cryogenic Sleep"
- Reply: Christos Zoulas: "Re: Symlinks and Cryogenic Sleep"
- Reply: Marc Heuse: "Re: Symlinks and Cryogenic Sleep"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
This archive was generated by hypermail 2b27 : Tue Jan 04 2000 - 16:00:34 CST