From c2fa12ccdd9434ec1bae156b463bcbe6f858d8a1 Mon Sep 17 00:00:00 2001 From: stan Date: Thu, 12 Jun 2003 14:29:27 +0000 Subject: [PATCH] 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 --- src/zm_local_camera.cpp | 6 +++--- src/zmfix.cpp | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/zm_local_camera.cpp b/src/zm_local_camera.cpp index fdde9c811..8e2972a4b 100644 --- a/src/zm_local_camera.cpp +++ b/src/zm_local_camera.cpp @@ -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 ) diff --git a/src/zmfix.cpp b/src/zmfix.cpp index d8ea51104..9433f8337 100644 --- a/src/zmfix.cpp +++ b/src/zmfix.cpp @@ -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 );