~ubuntu-branches/ubuntu/trusty/dvd95/trusty

« back to all changes in this revision

Viewing changes to src/systools.c

  • Committer: Bazaar Package Importer
  • Author(s): William Grant
  • Date: 2007-11-10 08:33:32 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20071110083332-pry0uz9nx4u1s1xz
Tags: 1.3p0-0ubuntu1
* New upstream release.
* debian/control:
  - Move homepage to Homepage field.
  - Comply with DebianMaintainerField.
  - Build-Depend on libmpeg-2-4-dev.
* debian/rules: Check if Makefile exists before cleaning, rather than
  ignoring all errors.
* Fix up .desktop:
  - debian/rules: Use dpatch.
  - debian/control: Build-Depend on dpatch.
  - debian/patches/01_fix_desktop_file.dpatch: Convince dvd95.desktop to
    comply with .desktop file standards.
* Add debian/watch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
#include <stdlib.h>
21
21
#include <sys/types.h>
22
22
#include <sys/stat.h>
23
 
#include <sys/statfs.h>
 
23
#if defined(__sun)
 
24
#       include <sys/statvfs.h>
 
25
#       include <sys/ioctl.h>
 
26
#else
 
27
#       include <sys/statfs.h>
 
28
#endif
24
29
#include <fcntl.h>
25
30
#include <unistd.h>
 
31
#if defined(__sun)
 
32
#       include <stropts.h>
 
33
#endif
26
34
#include <string.h>
27
35
#include <errno.h>
28
36
#include <sys/wait.h>
29
 
#include <linux/cdrom.h>
 
37
#if defined(__sun)
 
38
#       include <sys/cdio.h>
 
39
#       define NON_BLOCKING
 
40
#else
 
41
#       include <linux/cdrom.h>
 
42
#       include <linux/loop.h>
 
43
#endif
30
44
#include <ctype.h>
31
45
 
32
46
#include "support.h"
162
176
 
163
177
long long FsFree( char * fsName )
164
178
{
 
179
#if defined(__sun)
 
180
        struct statvfs b;
 
181
#else
165
182
        struct statfs b;
 
183
#endif
166
184
        int res;
167
185
        long long freeSize;
168
186
 
 
187
#if defined(__sun)
 
188
        res = statvfs( fsName, &b);
 
189
#else
169
190
        res = statfs( fsName, &b );
 
191
#endif
170
192
        if( res < 0 )   return( 0LL );
171
193
        freeSize = ((long long)b.f_bavail * (long long)b.f_bsize);
172
194
        return( freeSize );
436
458
        int fd;
437
459
        int ret;
438
460
        struct stat64 b;
 
461
#if !defined(__sun)
 
462
        struct loop_info lInfo;
 
463
#endif
439
464
 
440
465
// fprintf(stderr,"%s(%s)\n", __FUNCTION__, device );
441
466
        if( stat64( device, &b) ) {
448
473
// perror( "open" );
449
474
                return( -1 );
450
475
        }
 
476
#if defined (__sun)
 
477
        struct cdrom_tochdr cdth;
 
478
        ret = ioctl( fd, CDROMREADTOCHDR, &cdth);
 
479
        if( cdth.cdth_trk1 > 0 ) {
 
480
#else
451
481
        ret = ioctl( fd,  CDROM_DRIVE_STATUS, CDSL_CURRENT);
452
 
        close( fd );
453
 
        if( ret == -1 ) {
454
 
// perror( "ioctl" );
455
 
                return( -1 );
 
482
        if( ret == CDS_DISC_OK ) {
 
483
#endif
 
484
                close( fd );
 
485
                return( 1 );
456
486
        }
457
 
        if( ret == CDS_DISC_OK )        return( 1 );
 
487
#if !defined(__sun)
 
488
/* Try to know if it is a loop device */
 
489
        ret = ioctl( fd, LOOP_GET_STATUS, &lInfo );
 
490
        close( fd );
 
491
        if( !ret )      return( 1 );
 
492
#else
 
493
        close( fd );
 
494
#endif
458
495
        return( 0 );
459
496
}
460
497
/*------------------------------------------------------------------------------
481
518
        }
482
519
        return( sec );
483
520
}
 
521
/*------------------------------------------------------------------------------
 
522
        ISLOOPDEVICEREADY-
 
523
Linux!jef 2007/02/12 20:55:27
 
524
------------------------------------------------------------------------------*/
 
525
 
 
526
int IsLoopDeviceReady( char * loopDevice )
 
527
{
 
528
#if !defined(__sun)
 
529
        struct loop_info lInfo;
 
530
        int fd;
 
531
        int ret;
 
532
 
 
533
        fd = open( loopDevice, O_RDONLY | O_NONBLOCK);
 
534
        if( fd < 0 )    return( 0 );
 
535
        ret = ioctl( fd, LOOP_GET_STATUS, &lInfo );
 
536
// fprintf(stderr,"(%s)=%d lInfo.lo_name(%s)\n", loopDevice, ret,lInfo.lo_name );
 
537
        close( fd );
 
538
        if( !ret )      return( 1 );
 
539
#endif
 
540
        return( 0 );
 
541
}
484
542