[sane-devel] All sane frontends segfault with my HP 5200C
abel deuring
adeuring at gmx.net
Sun Feb 3 13:34:31 GMT 2002
Henning Meier-Geinitz wrote:
>
> Hi,
>
> On Sun, Feb 03, 2002 at 12:10:10PM +0100, Oliver Rauch wrote:
> > I think we could and should create a function
> > sanei_identify_device(char *device_file)
> >
> > that has some
> > #IFDEF _LINUX_
> > test for major/minor number for SCSI/USB/PARALLEL/...
> > #...
>
> That's a good idea. I propose a little change:
>
> Add something like sanei_scsi_is_scsi, sanei_scsi_is_usb etc to the
> respective sanei files so we don't have to link every backend to yet
> another file. So the sanei_usb_open etc. functions would test on their
> own.
>
> Maybe something like
>
> SANE_Status
> sanei_scsi_is_scsi (SANE_String_Const device_file) /* or (int fd) */
> {
> #if USE == LINUX_INTERFACE /* is this enough or must we check for __linux__ */
> /* get major and minor number */
> if (major_minor_is_in_range)
> return SANE_STATUS_GOOD;
> else
> return SANE_STATUS_INVAL;
> #else
> return SANE_STATUS_UNSUPPORTED;
> #endif
> }
>
> How can I get the major/minor number of a device file?
Something like
#include <sys/types.h>
#include <sys/stat.h>
stat fileinfo;
stat(filename, &fileinfo);
if (S_ISCHR(fileinfo.st_mode) && major(fileinfo.st_rdev) == 21) {
/* SG device file found */
}
This is just written down -- not tested! (Don't know, if or where a
macro definition for the major number 21 exists.)
Abel
More information about the sane-devel
mailing list