* fhandler.h (fhandler_dev_zero::lseek): Convert to inline method.

(class fhandler_dev_random): Drop dummy_offset.
	(fhandler_dev_random::lseek): Convert to inline method.
	(fhandler_dev_dsp::lseek): Ditto.
	* fhandler_dsp.cc (fhandler_dev_dsp::lseek): Drop here.
	* fhandler_random.cc (fhandler_dev_random::open): Drop setting
	dummy_offset.
	(fhandler_dev_random::lseek): Drop here.
	* fhandler_tape.cc (fhandler_dev_tape::lseek): Make no-op, but keep
	old code for reference.
	* fhandler_zero.cc (fhandler_dev_zero::lseek): Drop here.
This commit is contained in:
Corinna Vinschen 2013-10-24 17:51:41 +00:00
parent 4ae84b2251
commit 8ef76ab6f9
6 changed files with 24 additions and 46 deletions

View File

@ -1,3 +1,17 @@
2013-10-24 Corinna Vinschen <corinna@vinschen.de>
* fhandler.h (fhandler_dev_zero::lseek): Convert to inline method.
(class fhandler_dev_random): Drop dummy_offset.
(fhandler_dev_random::lseek): Convert to inline method.
(fhandler_dev_dsp::lseek): Ditto.
* fhandler_dsp.cc (fhandler_dev_dsp::lseek): Drop here.
* fhandler_random.cc (fhandler_dev_random::open): Drop setting
dummy_offset.
(fhandler_dev_random::lseek): Drop here.
* fhandler_tape.cc (fhandler_dev_tape::lseek): Make no-op, but keep
old code for reference.
* fhandler_zero.cc (fhandler_dev_zero::lseek): Drop here.
2013-10-24 Christopher Faylor <me.cygwin2013@cgf.cx> 2013-10-24 Christopher Faylor <me.cygwin2013@cgf.cx>
* external.cc (fillout_pinfo): If start_time is 0, wait a while before * external.cc (fillout_pinfo): If start_time is 0, wait a while before

View File

@ -1621,7 +1621,7 @@ class fhandler_dev_zero: public fhandler_base
fhandler_dev_zero (); fhandler_dev_zero ();
ssize_t __stdcall write (const void *ptr, size_t len); ssize_t __stdcall write (const void *ptr, size_t len);
void __reg3 read (void *ptr, size_t& len); void __reg3 read (void *ptr, size_t& len);
off_t lseek (off_t offset, int whence); off_t lseek (off_t, int) { return 0; }
virtual HANDLE mmap (caddr_t *addr, size_t len, int prot, virtual HANDLE mmap (caddr_t *addr, size_t len, int prot,
int flags, off_t off); int flags, off_t off);
@ -1653,7 +1653,6 @@ class fhandler_dev_random: public fhandler_base
{ {
protected: protected:
uint32_t pseudo; uint32_t pseudo;
off_t dummy_offset;
bool crypt_gen_random (void *ptr, size_t len); bool crypt_gen_random (void *ptr, size_t len);
int pseudo_write (const void *ptr, size_t len); int pseudo_write (const void *ptr, size_t len);
@ -1663,7 +1662,7 @@ class fhandler_dev_random: public fhandler_base
int open (int flags, mode_t mode = 0); int open (int flags, mode_t mode = 0);
ssize_t __stdcall write (const void *ptr, size_t len); ssize_t __stdcall write (const void *ptr, size_t len);
void __reg3 read (void *ptr, size_t& len); void __reg3 read (void *ptr, size_t& len);
off_t lseek (off_t offset, int whence); off_t lseek (off_t, int) { return 0; }
int close (); int close ();
fhandler_dev_random () : fhandler_base () {} fhandler_dev_random () : fhandler_base () {}
@ -1780,7 +1779,7 @@ class fhandler_dev_dsp: public fhandler_base
ssize_t __stdcall write (const void *ptr, size_t len); ssize_t __stdcall write (const void *ptr, size_t len);
void __reg3 read (void *ptr, size_t& len); void __reg3 read (void *ptr, size_t& len);
int ioctl (unsigned int cmd, void *); int ioctl (unsigned int cmd, void *);
off_t lseek (off_t, int); off_t lseek (off_t, int) { return 0; }
int close (); int close ();
void fixup_after_fork (HANDLE parent); void fixup_after_fork (HANDLE parent);
void fixup_after_exec (); void fixup_after_exec ();

View File

@ -1,6 +1,6 @@
/* fhandler_dev_dsp: code to emulate OSS sound model /dev/dsp /* fhandler_dev_dsp: code to emulate OSS sound model /dev/dsp
Copyright 2001, 2002, 2003, 2004, 2008, 2011, 2012 Red Hat, Inc Copyright 2001, 2002, 2003, 2004, 2008, 2011, 2012, 2013 Red Hat, Inc
Written by Andy Younger (andy@snoogie.demon.co.uk) Written by Andy Younger (andy@snoogie.demon.co.uk)
Extended by Gerd Spalink (Gerd.Spalink@t-online.de) Extended by Gerd Spalink (Gerd.Spalink@t-online.de)
@ -1131,12 +1131,6 @@ fhandler_dev_dsp::read (void *ptr, size_t& len)
audio_in_->read ((char *)ptr, (int&)len); audio_in_->read ((char *)ptr, (int&)len);
} }
off_t
fhandler_dev_dsp::lseek (off_t offset, int whence)
{
return 0;
}
void void
fhandler_dev_dsp::close_audio_in () fhandler_dev_dsp::close_audio_in ()
{ {

View File

@ -34,7 +34,6 @@ fhandler_dev_random::open (int flags, mode_t)
set_flags ((flags & ~O_TEXT) | O_BINARY); set_flags ((flags & ~O_TEXT) | O_BINARY);
nohandle (true); nohandle (true);
set_open_status (); set_open_status ();
dummy_offset = 0;
return 1; return 1;
} }
@ -151,34 +150,6 @@ fhandler_dev_random::read (void *ptr, size_t& len)
len = pseudo_read (ptr, len); len = pseudo_read (ptr, len);
} }
off_t
fhandler_dev_random::lseek (off_t off, int whence)
{
/* As on Linux, fake being able to set an offset. The fact that neither
reading nor writing changes the dummy offset is also the same as on
Linux (tested with kernel 2.6.23). */
off_t new_off;
switch (whence)
{
case SEEK_SET:
new_off = off;
break;
case SEEK_CUR:
new_off = dummy_offset + off;
break;
default:
set_errno (EINVAL);
return (off_t) -1;
}
if (new_off < 0)
{
set_errno (EINVAL);
return (off_t) -1;
}
return dummy_offset = new_off;
}
int int
fhandler_dev_random::close () fhandler_dev_random::close ()
{ {

View File

@ -1368,6 +1368,11 @@ fhandler_dev_tape::raw_write (const void *ptr, size_t len)
off_t off_t
fhandler_dev_tape::lseek (off_t offset, int whence) fhandler_dev_tape::lseek (off_t offset, int whence)
{ {
#if 1
/* On Linux lseek on tapes is a no-op. For now, let's keep the old code
intact but commented out, should incompatibilities arise. */
return 0;
#else
struct mtop op; struct mtop op;
struct mtpos pos; struct mtpos pos;
DWORD block_size; DWORD block_size;
@ -1426,6 +1431,7 @@ fhandler_dev_tape::lseek (off_t offset, int whence)
out: out:
return unlock (ret); return unlock (ret);
#endif
} }
int __reg2 int __reg2

View File

@ -37,9 +37,3 @@ fhandler_dev_zero::read (void *ptr, size_t& len)
{ {
memset (ptr, 0, len); memset (ptr, 0, len);
} }
off_t
fhandler_dev_zero::lseek (off_t, int)
{
return 0;
}