コード例 #1
0
ファイル: smb_stat.c プロジェクト: leshkoapps/libdsm
smb_stat        smb_stat_fd(smb_session *s, smb_fd fd)
{
    assert(s != NULL && fd);
    
    if(s != NULL && fd){
        return smb_session_file_get(s, fd);
    }
}
コード例 #2
0
ファイル: smb_file.c プロジェクト: eiprol/libdsm
ssize_t   smb_fread(smb_session *s, smb_fd fd, void *buf, size_t buf_size)
{
    smb_file        *file;
    smb_message     *req_msg, resp_msg;
    smb_read_req    req;
    smb_read_resp   *resp;
    size_t          max_read;
    int             res;

    assert(s != NULL && buf != NULL);
    if (!fd)
      return (-1);
    if ((file = smb_session_file_get(s, fd)) == NULL)
        return (-1);

    req_msg = smb_message_new(SMB_CMD_READ);
    if (!req_msg)
        return (-1);
    req_msg->packet->header.tid = file->tid;

    max_read = 0xffff;
    max_read = max_read < buf_size ? max_read : buf_size;

    SMB_MSG_INIT_PKT_ANDX(req);
    req.wct              = 12;
    req.fid              = file->fid;
    req.offset           = file->readp;
    req.max_count        = max_read;
    req.min_count        = max_read;
    req.max_count_high   = 0;
    req.remaining        = 0;
    req.offset_high      = 0;
    req.bct              = 0;
    SMB_MSG_PUT_PKT(req_msg, req);

    res = smb_session_send_msg(s, req_msg);
    smb_message_destroy(req_msg);
    if (!res)
        return (-1);

    if (!smb_session_recv_msg(s, &resp_msg))
        return (-1);
    if (resp_msg.packet->header.status != NT_STATUS_SUCCESS)
        return (-1);

    resp = (smb_read_resp *)resp_msg.packet->payload;
    memcpy(buf, resp->file, resp->data_len);
    smb_fseek(s, fd, resp->data_len, SEEK_CUR);

    return (resp->data_len);
}
コード例 #3
0
ファイル: smb_file.c プロジェクト: eiprol/libdsm
ssize_t   smb_fseek(smb_session *s, smb_fd fd, ssize_t offset, int whence)
{
    smb_file  *file;

    assert(s != NULL);

    if (!fd || (file = smb_session_file_get(s, fd)) == NULL)
        return (0);

    if (whence == SMB_SEEK_SET)
        file->readp = offset;
    else if (whence == SMB_SEEK_CUR)
        file->readp += offset;

    return (file->readp);
}