Date: Tue, 06 Feb 2001 03:19:01 +0000 From: Brian Somers <brian@Awfulhak.org> To: domi@saargate.de Cc: freebsd-current@freebsd.org, Brian Somers <brian@Awfulhak.org> Subject: Strange fopen() behaviour (was: xsane patch to maintainer) Message-ID: <200102060319.f163J2610146@hak.lan.Awfulhak.org> In-Reply-To: Message from Brian Somers <brian@Awfulhak.org> of "Tue, 06 Feb 2001 02:35:12 GMT." <200102060235.f162ZC609373@hak.lan.Awfulhak.org>
next in thread | previous in thread | raw e-mail | index | archive | help
This is a multipart MIME message. --==_Exmh_8122223300 Content-Type: text/plain; charset=us-ascii > Hi, > > Would you mind if I commit the attached patch for the xsane port ? > It makes sense - rather than dropping a core when fopen() fails (and > fclose() is called with a NULL arg). It happens when your home > directory isn't writable :-/ I've cc'd -current as I think something more sinister is going on. To recap, I'm having trouble running xsane on -current from about two days ago. fopen() is failing... The attached patch exposes more about what's wrong. Interestingly enough, the file it's trying to create is in /tmp (mode 1777, separate filesystem), and according to truss: lstat("/tmp//preview-level-0-15-b924dc",0xbfbfe894) ERR#2 'No such file or directory' umask(0x7f) = 7 (0x7) /tmp//preview-level-0-15-b924dc17767-microtek:_dev_scanner.ppm: could not create for preview-level 0: No such file or directory write(2,0xbfbfe48c,128) = 128 (0x80) getuid() = 15 (0xf) lstat("/tmp//preview-level-1-15-jNO6zx",0xbfbfe894) ERR#2 'No such file or directory' umask(0x7f) = 127 (0x7f) /tmp//preview-level-1-15-jNO6zx09158-microtek:_dev_scanner.ppm: could not create for preview-level 1: No such file or directory write(2,0xbfbfe48c,128) = 128 (0x80) getuid() = 15 (0xf) lstat("/tmp//preview-level-2-15-CO6k7w",0xbfbfe894) ERR#2 'No such file or directory' umask(0x7f) = 127 (0x7f) break(0x8134000) = 0 (0x0) /tmp//preview-level-2-15-CO6k7w39017-microtek:_dev_scanner.ppm: could not create for preview-level 2: No such file or directory write(2,0xbfbfe48c,128) = 128 (0x80) fopen() is failing after calling lstat() (I assume via _open()) !!! As if the "wb" didn't mean O_CREAT ??!? Very strange. Anyway, here's the patch if you're interested. I'll look into things further on Wednesday. Cheers. -- Brian <brian@Awfulhak.org> <brian@[uk.]FreeBSD.org> <http://www.Awfulhak.org> <brian@[uk.]OpenBSD.org> Don't _EVER_ lose your sense of humour ! --==_Exmh_8122223300 Content-Type: text/plain ; name="patch-ae"; charset=us-ascii Content-Description: patch-ae Content-Disposition: attachment; filename="patch-ae" --- src/xsane-preview.c.orig Sun Jan 14 15:35:06 2001 +++ src/xsane-preview.c Tue Feb 6 03:03:18 2001 @@ -2802,6 +2802,7 @@ int i; char buf[256]; char filename[PATH_MAX]; + FILE *fp; DBG(DBG_proc, "preview_new\n"); @@ -2830,9 +2831,17 @@ if (preview_make_image_path(p, sizeof(filename), filename, i)>=0) { umask(0177); /* create temporary file with "-rw-------" permissions */ - fclose(fopen(filename, "wb")); /* make sure file exists, b = binary mode for win32 */ - umask(XSANE_DEFAULT_UMASK); /* define new file permissions */ - p->filename[i] = strdup(filename);/* store filename */ + fp = fopen(filename, "wb"); /* make sure file exists, b = binary mode for win32 */ + if (fp == NULL) { + fprintf(stderr, "%s: could not create for preview-level %d: %s\n", filename, i, strerror(errno)); + p->filename[i] = NULL; + } + else + { + fclose(fp); + umask(XSANE_DEFAULT_UMASK); /* define new file permissions */ + p->filename[i] = strdup(filename);/* store filename */ + } } else { --==_Exmh_8122223300-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200102060319.f163J2610146>