[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

RE: [CPROG] automatisk mount umount af CD-ROM!



Mange tak, jeg tror jeg har nok til at kunne lave noget selv nu, dit
eksempel virker ikke helt, men jeg tror at jeg kan finde ud af reste selv.

Mange tak for din tolmodighed!

Mvh.
 Jimmy

-----Original Message-----
From: Jens Axboe [mailto:sslug@sslug
Sent: 21. oktober 1999 16:43
To: sslug@sslug
Subject: Re: [CPROG] automatisk mount umount af CD-ROM!


On Thu, Oct 21 1999, Dansbo, Jimmy wrote:
> Som jeg skrev i min første mail så er jeg meget "ny" inden for
programmering
> til Linux, kunne du forklare lidt mere om hvordan jeg skal gøre?
> 
> Jeg har forsøgt mig lidt frem, men kan ikke finde ud af at bruge de her
> STATUS flag!

Noget ala nedenstående. Fuldstændig utestet, men det kan give
dig en ide om hvordan du bruger kaldene.

include <stdio.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <linux/cdrom.h>

int main(int argc, char *argv[])
{
        int fd = open("/dev/cdrom", O_RDONLY | O_NONBLOCK);
        int ret;

        ret = ioctl(fd, CDROM_DRIVE_STATUS, CDSL_CURRENT);
        if (ret == -1) {
                perror("ioctl");
                return 1;
        }

        /* ok, ret er nu en af følgende
         * #define CDS_NO_INFO             0
         * #define CDS_NO_DISC             1
         * #define CDS_TRAY_OPEN           2
         * #define CDS_DRIVE_NOT_READY     3
         * #define CDS_DISC_OK             4
         */
        switch (ret) {
                case CDS_NO_DISC:
                        printf("ingen disc i drevet\n");
                        break;
                case CDS_TRAY_OPEN:
                        printf("skuffen er åben\n");
                        break;
                case CDS_DRIVE_NOT_READY:
                        printf("drevet er ikke klar, vent lidt\n");
                        break;
                case CDS_DISC_OK:
                        printf("ok, der er disc i drevet.\n");
                        break;
        }

        if (ret == CDS_DISC_OK) {
                ret = ioctl(fd, CDROM_DRIVE_STATUS, CDSL_CURRENT);
                if (ret == -1) {
                        perror("ioctl");
                        return 2;
                }
                switch (ret) {
                        case CDS_AUDIO:
                                printf("audio disc\n");
                                break;
                        case CDS_DATA_1:
                                printf("mode 1 data disc\n");
                                break;
                        case CDS_DATA_2:
                                printf("mode 2 data disc\n");
                                break;
                        case CDS_XA_2_1:
                                printf("XA mode 2 form 1 disc\n");
                                break;
                        case CDS_XA_2_2:
                                printf("XA mode 2 form 2 disc\n");
                                break;
                        case CDS_MIXED:
                                printf("blandet data og audio disc\n");
                                break;
                }

        }
	return 0;
}

-- 
*  Jens Axboe <sslug@sslug>
*  Linux CD-ROM Maintainer
*  http://www.kernel.dk


 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-08-10, 20:07 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *