Changeset 08232ee in mainline for uspace/srv


Ignore:
Timestamp:
2010-01-09T21:52:07Z (15 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
9245413
Parents:
dccf721
Message:

Obtain block device size automatically, if possible. Implement ftell(). Fix seek implementation in VFS if whence == SEEK_END.

Location:
uspace/srv
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/bd/ata_bd/ata_bd.c

    rdccf721 r08232ee  
    296296                        ipc_answer_1(callid, EOK, block_size);
    297297                        continue;
     298                case BD_GET_NUM_BLOCKS:
     299                        ipc_answer_2(callid, EOK, LOWER32(disk[disk_id].blocks),
     300                            UPPER32(disk[disk_id].blocks));
     301                        continue;
    298302                default:
    299303                        retval = EINVAL;
  • uspace/srv/bd/file_bd/file_bd.c

    rdccf721 r08232ee  
    5656
    5757static const size_t block_size = 512;
     58static bn_t num_blocks;
    5859static FILE *img;
    5960
     
    99100{
    100101        int rc;
     102        long img_size;
    101103
    102104        rc = devmap_driver_register(NAME, file_bd_connection);
     
    109111        if (img == NULL)
    110112                return EINVAL;
     113
     114        if (fseek(img, 0, SEEK_END) != 0) {
     115                fclose(img);
     116                return EIO;
     117        }
     118
     119        img_size = ftell(img);
     120        if (img_size < 0) {
     121                fclose(img);
     122                return EIO;
     123        }
     124
     125        num_blocks = img_size / block_size;
    111126
    112127        fibril_mutex_initialize(&dev_lock);
     
    174189                        ipc_answer_1(callid, EOK, block_size);
    175190                        continue;
     191                case BD_GET_NUM_BLOCKS:
     192                        ipc_answer_2(callid, EOK, LOWER32(num_blocks),
     193                            UPPER32(num_blocks));
     194                        continue;
    176195                default:
    177196                        retval = EINVAL;
  • uspace/srv/bd/gxe_bd/gxe_bd.c

    rdccf721 r08232ee  
    234234                        ipc_answer_1(callid, EOK, block_size);
    235235                        continue;
     236                case BD_GET_NUM_BLOCKS:
     237                        retval = ENOTSUP;
     238                        break;
    236239                default:
    237240                        retval = EINVAL;
  • uspace/srv/bd/part/mbr_part/mbr_part.c

    rdccf721 r08232ee  
    463463                        ipc_answer_1(callid, EOK, block_size);
    464464                        continue;
    465 
     465                case BD_GET_NUM_BLOCKS:
     466                        ipc_answer_2(callid, EOK, LOWER32(part->length),
     467                            UPPER32(part->length));
     468                        continue;
    466469                default:
    467470                        retval = EINVAL;
  • uspace/srv/bd/rd/rd.c

    rdccf721 r08232ee  
    153153                        ipc_answer_1(callid, EOK, block_size);
    154154                        continue;
     155                case BD_GET_NUM_BLOCKS:
     156                        ipc_answer_2(callid, EOK, LOWER32(rd_size / block_size),
     157                            UPPER32(rd_size / block_size));
     158                        continue;
    155159                default:
    156160                        /*
  • uspace/srv/vfs/vfs_ops.c

    rdccf721 r08232ee  
    900900                }
    901901                newpos = size + off;
     902                file->pos = newpos;
    902903                fibril_mutex_unlock(&file->lock);
    903904                ipc_answer_1(rid, EOK, newpos);
Note: See TracChangeset for help on using the changeset viewer.