all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#18370: insert-file-contents: forbids also beg, end for non-regular (special) files
@ 2014-08-31 19:50 Ivan Shmakov
  2022-05-11 15:22 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 5+ messages in thread
From: Ivan Shmakov @ 2014-08-31 19:50 UTC (permalink / raw)
  To: 18370

Package:  emacs
Severity: minor

	As currently implemented, insert-file-contents disallows not
	only (as per (elisp.info) Reading from Files) the case of either
	‘visit’ or ‘replace’ arguments being non-nil, but also when
	non-nil are either ‘beg’ or ‘end’ (or both):

  3506	  /* This code will need to be changed in order to work on named
  3507	     pipes, and it's probably just not worth it.  So we should at
  3508	     least signal an error.  */
  3509	  if (!S_ISREG (st.st_mode))
  3510	    {
  3511	      not_regular = 1;
⋯
  3516	      if (! NILP (replace) || ! NILP (beg) || ! NILP (end))
  3517		xsignal2 (Qfile_error,
  3518			  build_string ("not a regular file"), orig_filename);
  3519	    }

	This, however, precludes the use of insert-file-contents not
	only on named pipes, but also on /dev/cdrom, /dev/random, and
	the like, – for (and especially in the case of the latter) the
	‘end’ argument gets rather essential here, as otherwise the
	function is likely to read much more than the caller will be
	able to handle at any single time.

	Instead, I’d suggest that ‘end’ is always allowed, and ‘beg’ is
	allowed when the file in question is /seekable/, – which, ISTR,
	is possible to check beforehand (lseek (fd, 0, SEEK_CUR) < 0?)

	From a glance over the code, this new behavior wouldn’t be all
	that hard to implement (some not_regular checks will have to be
	replaced with the ones against beg_offset, end_offset, etc.),
	but from what I read, – it’s already going to be more than I can
	test right now.  So no .diff this time, alas.

-- 
FSF associate member #7257  http://boycottsystemd.org/  … 3013 B6A0 230E 334A





^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-06-12 10:19 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-31 19:50 bug#18370: insert-file-contents: forbids also beg, end for non-regular (special) files Ivan Shmakov
2022-05-11 15:22 ` Lars Ingebrigtsen
2022-06-11 12:40   ` Lars Ingebrigtsen
2022-06-12  7:11     ` Juri Linkov
2022-06-12 10:19       ` Lars Ingebrigtsen

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.