Coder Social home page Coder Social logo

Comments (7)

geysee avatar geysee commented on May 29, 2024

Hi,

I created pull request.
#47

Best Regards,

from amsmb2.

geysee avatar geysee commented on May 29, 2024

Hi,

Thank you for your reply about pull request.
#47 (comment)

I checked packet.
I confirmed that smb2_write_async in libsmb2 is requesting with 61440 size.

I guess that the size has been changed to 61440 by the following function in libsmb2, but it is difficult to understand for me.

Please let me know if you notice any cause.

int
smb2_pwrite_async(struct smb2_context *smb2, struct smb2fh *fh,
                  uint8_t *buf, uint32_t count, uint64_t offset,
                  smb2_command_cb cb, void *cb_data)
{
        struct smb2_write_request req;
        struct rw_data *rd;
        struct smb2_pdu *pdu;
        int needed_credits = (count - 1) / 65536 + 1;

        if (count > smb2->max_write_size) {
                count = smb2->max_write_size;
        }
        if (smb2->dialect > SMB2_VERSION_0202) {
                if (needed_credits > MAX_CREDITS - 16) {
                        count =  (MAX_CREDITS - 16) * 65536;
                }
                needed_credits = (count - 1) / 65536 + 1;
                if (needed_credits > smb2->credits) {
                        count = smb2->credits * 65536;
                }
        } else {
                if (count > 65536) {
                        count = 65536;
                }
        }

        rd = calloc(1, sizeof(struct rw_data));
        if (rd == NULL) {
                smb2_set_error(smb2, "Failed to allocate rw_data");
                return -ENOMEM;
        }
                
        rd->cb = cb;
        rd->cb_data = cb_data;
        rd->fh = fh;
        rd->offset = offset;

        memset(&req, 0, sizeof(struct smb2_write_request));
        req.length = count;
        req.offset = offset;
        req.buf = buf;
        memcpy(req.file_id, fh->file_id, SMB2_FD_SIZE);
        req.channel = SMB2_CHANNEL_NONE;
        req.remaining_bytes = 0;
        req.flags = 0;

        pdu = smb2_cmd_write_async(smb2, &req, write_cb, rd);
        if (pdu == NULL) {
                smb2_set_error(smb2, "Failed to create write command");
                return -ENOMEM;
        }
        smb2_queue_pdu(smb2, pdu);

        return 0;
} 

Best Regards,

from amsmb2.

amosavian avatar amosavian commented on May 29, 2024

Please check this issue #17

from amsmb2.

geysee avatar geysee commented on May 29, 2024

Hi,

Thank you for your reply.

I confirmed libsmb2 code, but I do not still understand why libsmb2 request to SMB server with 61440 byte.

However, as you advised, by setting a chunk size to 61440, my app was able to write files to the SMB server correctly.

Thank you very much.

By the way, the SMB protocol version of this server is 2.2

https://github.com/sahlberg/libsmb2/issues/43#issuecomment-392449832

I captured packet of iPad with Mac PC and following command, without jailbreak.
I'm sorry if you already know.

from amsmb2.

amosavian avatar amosavian commented on May 29, 2024

I confirmed libsmb2 code, but I do not still understand why libsmb2 request to SMB server with 61440 byte.

This value is changed to 65535 bytes in latest release. But I checked and the issue is still happening.

from amsmb2.

geysee avatar geysee commented on May 29, 2024

Hi,

It may be fixed in following commit of libsmb2.
sahlberg/libsmb2@aaad1ba

This was committed 22 days ago.

Does the following "libsmb2.a" in AMSMB2 contain this commit?
https://github.com/amosavian/AMSMB2/tree/master/libsmb2/lib

On the other hand, this commit is after v3.0.0 tag.
I am worried that this commit may not be stable.

from amsmb2.

geysee avatar geysee commented on May 29, 2024

Hi,

I tried chunk size to less than 61440.
But, error message "Inconsitency in writing to SMB file handle" was thrown as same.

So that, It seems that this issue has not resolved by this commit .
sahlberg/libsmb2@aaad1ba

As you advised, by setting a chunk size to 61440, my app was able to write files to the SMB server correctly.
#46 (comment)

I will close the issue.
Thank you very much for your advice.

from amsmb2.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.