Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.os.linux.development.apps > #458
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!border3.nntp.dca.giganews.com!Xl.tags.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local2.nntp.dca.giganews.com!nntp.earthlink.com!news.earthlink.com.POSTED!not-for-mail |
|---|---|
| NNTP-Posting-Date | Mon, 16 Apr 2012 17:03:00 -0500 |
| From | "Joe Shead" <Joe@SheadProgramming.com> |
| Newsgroups | comp.os.linux.development.apps |
| Subject | fopen() of a read-only file for writing? |
| Date | Mon, 16 Apr 2012 17:03:13 -0600 |
| MIME-Version | 1.0 |
| Content-Type | multipart/alternative; boundary="----=_NextPart_000_008C_01CD1BF2.CF1296F0" |
| X-Priority | 3 |
| X-MSMail-Priority | Normal |
| X-Newsreader | Microsoft Outlook Express 6.00.2800.2001 |
| X-MimeOLE | Produced By Microsoft MimeOLE V6.00.2800.2001 |
| Message-ID | <s5KdnY85luiJChHSnZ2dnUVZ_uGdnZ2d@earthlink.com> (permalink) |
| Lines | 99 |
| X-Usenet-Provider | http://www.giganews.com |
| NNTP-Posting-Host | 4.230.120.211 |
| X-Trace | sv3-5gekQCaRLVvGEnFtdGplbSXPwDonk22i/F2w0MWabEh2U2W4p0FQ6wDaGOkXxDZz+znkGKzmFfYgp5o!96rAqaERZhq6KH7dt2eGaWJpyCd807vap+/TKBhdlMe8bJHzfkcPHkrVDAVkWk3OsEJzsB1J99qB!6rxppw7LNNHjW2mSCN3GMPuGo2rd/84xVQ== |
| X-Abuse-and-DMCA-Info | Please be sure to forward a copy of ALL headers |
| X-Abuse-and-DMCA-Info | Otherwise we will be unable to process your complaint properly |
| X-Postfilter | 1.3.40 |
| X-Original-Bytes | 4500 |
| Xref | csiph.com comp.os.linux.development.apps:458 |
Show key headers only | View raw
[Multipart message — attachments visible in raw view] - view raw
Hi,
I have a file that has no write permissions on it, called readonly.txt. I am logged on as root.
ls -l returns the line:
-r-xr--r-- 1 root root 32 Apr 15 20:20 readonly.txt
I do:
<CODE>
int errnos[4];
FILE *f=0;
errno=0;
errnos[0]=errno;
f=fopen("readonly.txt", "wb");
errnos[1]=errno;
if (f!=0){
putc('a', f);
errnos[2]=errno;
fclose(f); f=0;
errnos[3]=errno;}
</CODE>
I get a non-zero f from fopen(), the putc() works, and all 4 errnos are 0. After executing this code, the file is 1 byte long with just the 'a' in it.
Is this behavior correct?
I'm really not sure, but if someone could explain it to me, or direct me to the right people to talk to, that would help. It seems like fopen() ought to return 0, and set errno to EACCES.
I built my version of linux using lfs (linux from scratch). I'm using linux kernel version 2.4.21, gcc version 3.2.1, and libc version 2.3.1.
Thanks in advance,
Joe
Back to comp.os.linux.development.apps | Previous | Next — Next in thread | Find similar
fopen() of a read-only file for writing? "Joe Shead" <Joe@SheadProgramming.com> - 2012-04-16 17:03 -0600
Re: fopen() of a read-only file for writing? pacman@kosh.dhis.org (Alan Curry) - 2012-04-17 05:12 +0000
Re: fopen() of a read-only file for writing? "Joe Shead" <Joe@SheadProgramming.com> - 2012-04-17 01:36 -0600
Re: fopen() of a read-only file for writing? "Joe Shead" <Joe@SheadProgramming.com> - 2012-04-18 22:40 -0600
Re: fopen() of a read-only file for writing? Richard Kettlewell <rjk@greenend.org.uk> - 2012-04-19 08:57 +0100
Re: fopen() of a read-only file for writing? Rainer Weikusat <rweikusat@mssgmbh.com> - 2012-04-19 14:18 +0100
Re: fopen() of a read-only file for writing? Grant Edwards <invalid@invalid.invalid> - 2012-04-19 14:16 +0000
Re: fopen() of a read-only file for writing? "Joe Shead" <Joe@SheadProgramming.com> - 2012-04-20 19:10 -0600
Re: fopen() of a read-only file for writing? Richard Kettlewell <rjk@greenend.org.uk> - 2012-04-21 10:20 +0100
Re: fopen() of a read-only file for writing? "Joe Shead" <Joe@SheadProgramming.com> - 2012-04-22 00:07 -0600
Re: fopen() of a read-only file for writing? "Joe Shead" <Joe@SheadProgramming.com> - 2012-04-23 15:24 -0600
csiph-web