Now opens devices and shared memory read/write for v4l2 compatibility.

git-svn-id: http://svn.zoneminder.com/svn/zm/trunk@569 e3e1d417-86f3-4887-817a-d78f3d33393f
This commit is contained in:
stan 2003-06-12 14:29:27 +00:00
parent 04ce08ef7e
commit c2fa12ccdd
2 changed files with 7 additions and 7 deletions

View File

@ -56,7 +56,7 @@ void LocalCamera::Initialise()
char device_path[64];
sprintf( device_path, "/dev/video%d", device );
if( (m_videohandle=open(device_path, O_RDONLY)) <=0 )
if ( (m_videohandle=open(device_path, O_RDWR)) <=0 )
{
Error(( "Failed to open video device %s: %s", device_path, strerror(errno) ));
exit(-1);
@ -147,7 +147,7 @@ void LocalCamera::Initialise()
m_vmm[loop].format = palette;
}
m_buffer = (unsigned char *)mmap(0, m_vmb.size, PROT_READ, MAP_SHARED, m_videohandle,0);
m_buffer = (unsigned char *)mmap(0, m_vmb.size, PROT_READ|PROT_WRITE, MAP_SHARED, m_videohandle,0);
if( !((long)m_buffer > 0) )
{
Error(( "Could not mmap video: %s", strerror(errno) ));
@ -226,7 +226,7 @@ bool LocalCamera::GetCurrentSettings( int device, char *output, bool verbose )
sprintf( device_path, "/dev/video%d", device );
if ( verbose )
sprintf( output, output+strlen(output), "Checking Video Device: %s\n", device_path );
if( (m_videohandle=open(device_path, O_RDONLY)) <=0 )
if ( (m_videohandle=open(device_path, O_RDWR)) <=0 )
{
Error(( "Failed to open video device %s: %s", device_path, strerror(errno) ));
if ( verbose )

View File

@ -52,21 +52,21 @@ bool fixDevice( int device )
if ( uid == stat_buf.st_uid )
{
// If we are the owner
mask = 00400;
mask = 00600;
}
else if ( gid == stat_buf.st_gid )
{
// If we are in the owner group
mask = 00040;
mask = 00060;
}
else
{
// We are neither the owner nor in the group
mask = 00004;
mask = 00006;
}
mode_t mode = stat_buf.st_mode;
if ( mode & mask )
if ( (mode & mask) == mask )
{
Info(( "Permissions on %s are ok at %o", device_path, mode ));
return( true );