~ubuntu-branches/ubuntu/quantal/mc/quantal

« back to all changes in this revision

Viewing changes to lib/vfs/mc-vfs/undelfs.c

  • Committer: Bazaar Package Importer
  • Author(s): Yury V. Zaytsev, Yury V. Zaytsev
  • Date: 2010-09-07 10:59:46 UTC
  • mfrom: (4.2.9 sid)
  • Revision ID: james.westby@ubuntu.com-20100907105946-bf9et2bryuq6aoa5
Tags: 3:4.7.0.9-1
[Yury V. Zaytsev]
* New upstream version (bugfix release).
  + Corrected typos in man pages (Closes: #585503)
* Enabled ext2undelfs by default (LP: #267480)
* Tightened libslang2 dependency (Closes: #592772)

Show diffs side-by-side

added added

removed removed

Lines of Context:
400
400
    int f_index;                /* file index into delarray */
401
401
    char *buf;
402
402
    int error_code;             /*  */
403
 
    int pos;                    /* file position */
404
 
    int current;                /* used to determine current position in itereate */
405
 
    int finished;
 
403
    off_t pos;                  /* file position */
 
404
    off_t current;              /* used to determine current position in itereate */
 
405
    gboolean finished;
406
406
    ext2_ino_t inode;
407
407
    int bytes_read;
408
 
    long size;
 
408
    off_t size;
409
409
 
410
410
    /* Used by undelfs_read: */
411
411
    char *dest_buffer;          /* destination buffer */
412
 
    int count;                  /* bytes to read */
 
412
    size_t count;               /* bytes to read */
413
413
} undelfs_file;
414
414
 
415
415
/* We do not support lseek */
416
416
static void *
417
 
undelfs_open (struct vfs_class *me, const char *fname, int flags, int mode)
 
417
undelfs_open (struct vfs_class *me, const char *fname, int flags, mode_t mode)
418
418
{
419
419
    char *file, *f;
420
420
    ext2_ino_t inode, i;
460
460
            return 0;
461
461
        }
462
462
        p->inode = inode;
463
 
        p->finished = 0;
 
463
        p->finished = FALSE;
464
464
        p->f_index = i;
465
465
        p->error_code = 0;
466
466
        p->pos = 0;
500
500
    else
501
501
        memset (p->buf, 0, param_fs->blocksize);
502
502
 
503
 
    if (p->pos + p->count < p->current)
 
503
    if (p->pos + (off_t) p->count < p->current)
504
504
    {
505
 
        p->finished = 1;
 
505
        p->finished = TRUE;
506
506
        return BLOCK_ABORT;
507
507
    }
508
 
    if ((size_t) p->pos > p->current + param_fs->blocksize)
 
508
    if (p->pos > p->current + param_fs->blocksize)
509
509
    {
510
510
        p->current += param_fs->blocksize;
511
511
        return 0;               /* we have not arrived yet */
516
516
    {
517
517
 
518
518
        /* First case: starting pointer inside this block */
519
 
        if ((size_t) (p->pos + p->count) <= p->current + param_fs->blocksize)
 
519
        if (p->pos + (off_t) p->count <= p->current + param_fs->blocksize)
520
520
        {
521
521
            /* Fully contained */
522
522
            copy_count = p->count;
523
 
            p->finished = p->count;
 
523
            p->finished = (p->count != 0);
524
524
        }
525
525
        else
526
526
        {
532
532
    else
533
533
    {
534
534
        /* Second case: we already have passed p->pos */
535
 
        if ((size_t) (p->pos + p->count) < p->current + param_fs->blocksize)
 
535
        if (p->pos + (off_t) p->count < p->current + param_fs->blocksize)
536
536
        {
537
537
            copy_count = (p->pos + p->count) - p->current;
538
 
            p->finished = p->count;
 
538
            p->finished = (p->count != 0);
539
539
        }
540
540
        else
541
541
        {
553
553
}
554
554
 
555
555
static ssize_t
556
 
undelfs_read (void *vfs_info, char *buffer, int count)
 
556
undelfs_read (void *vfs_info, char *buffer, size_t count)
557
557
{
558
558
    undelfs_file *p = vfs_info;
559
559
    int retval;
560
560
 
561
561
    p->dest_buffer = buffer;
562
562
    p->current = 0;
563
 
    p->finished = 0;
 
563
    p->finished = FALSE;
564
564
    p->count = count;
565
565
 
566
 
    if (p->pos + p->count > p->size)
 
566
    if (p->pos + (off_t) p->count > p->size)
567
567
    {
568
568
        p->count = p->size - p->pos;
569
569
    }