Subject: RE : Error reporting of libssh2_sftp_xxxx functions.

RE : Error reporting of libssh2_sftp_xxxx functions.

From: Jean-Louis CHARTON <Jean-Louis.CHARTON_at_oikialog.com>
Date: Mon, 23 Mar 2009 20:39:23 +0100

Hi Alexander,

It seems that many more new error codes have been added in newer revisions of the RFC. See for example http://tools.ietf.org/id/draft-ietf-secsh-filexfer-13.txt :

SSH_FX_OK 0
SSH_FX_EOF 1
SSH_FX_NO_SUCH_FILE 2
SSH_FX_PERMISSION_DENIED 3
SSH_FX_FAILURE 4
SSH_FX_BAD_MESSAGE 5
SSH_FX_NO_CONNECTION 6
SSH_FX_CONNECTION_LOST 7
SSH_FX_OP_UNSUPPORTED 8
SSH_FX_INVALID_HANDLE 9
SSH_FX_NO_SUCH_PATH 10
SSH_FX_FILE_ALREADY_EXISTS 11
SSH_FX_WRITE_PROTECT 12
SSH_FX_NO_MEDIA 13
SSH_FX_NO_SPACE_ON_FILESYSTEM 14
SSH_FX_QUOTA_EXCEEDED 15
SSH_FX_UNKNOWN_PRINCIPAL 16
SSH_FX_LOCK_CONFLICT 17
SSH_FX_DIR_NOT_EMPTY 18
SSH_FX_NOT_A_DIRECTORY 19
SSH_FX_INVALID_FILENAME 20
SSH_FX_LINK_LOOP 21
SSH_FX_CANNOT_DELETE 22
SSH_FX_INVALID_PARAMETER 23
SSH_FX_FILE_IS_A_DIRECTORY 24
SSH_FX_BYTE_RANGE_LOCK_CONFLICT 25
SSH_FX_BYTE_RANGE_LOCK_REFUSED 26
SSH_FX_DELETE_PENDING 27
SSH_FX_FILE_CORRUPT 28
SSH_FX_OWNER_INVALID 29
SSH_FX_GROUP_INVALID 30
SSH_FX_NO_MATCHING_BYTE_RANGE_LOCK 31

For the MKDIR operation, this RFC says :

"8.4. Creating and Deleting Directories

   New directories can be created using the SSH_FXP_MKDIR request. It
   has the following format:

       byte SSH_FXP_MKDIR
       uint32 request-id
       string path [UTF-8]
       ATTRS attrs

   where 'request-id' is the request identifier.

   'path' specifies the directory to be created. See Section ''File
   Names'' for more information on file names.

   'attrs' specifies the attributes that should be applied to it upon
   creation. Attributes are discussed in more detail in Section ''File
   Attributes''.

   The server will respond to this request with a SSH_FXP_STATUS
   message. If a file or directory with the specified path already
   exists, an error will be returned."

Unfortunately, it does not indicate precisely which specific error has to be returned in the case the directory exists!

So, finally, you're right, the best way to handle this "EEXIST error" is probably to make a call to libssh2_sftp_stat() to see if the directory is already there.

Thank you for this solution.

J-L

-----Message d'origine-----
De : Alexander Lamaison [mailto:swish_at_lammy.co.uk]
Envoyé : lundi 23 mars 2009 20:23
À : libssh2 development
Objet : Re: Error reporting of libssh2_sftp_xxxx functions.

2009/3/23 Daniel Stenberg <daniel_at_haxx.se>:
> On Mon, 23 Mar 2009, Jean-Louis CHARTON wrote:
>
>> I was expecting a more accurate error code like
>> LIBSSH2_FX_FILE_ALREADY_EXISTS or something like that instead.
>
> There is no such code available! See
> http://tools.ietf.org/wg/secsh/draft-ietf-secsh-filexfer/draft-ietf-secsh-filexfer-02.txt

As I understand it, LIBSSH2_FX_FILE_ALREADY_EXISTS is only returned by
SFTP v5+ to indicate that the operation could have succeeded if the
call had specified LIBSSH2_SFTP_RENAME_OVERWRITE. As earlier versions
of SFTP (i.e. almost anything in the real world) don't support
overwriting at all, they don't tell you that you could.

I realise this is not very helpful for you, unfortunately. In my own
code, I handle the LIBSSH2_FX_FAILURE error by immediately calling
libssh2_sftp_stat() to see if the directory actually exists and then
react accordingly.

HTH

Alex

------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
libssh2-devel mailing list
libssh2-devel_at_lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libssh2-devel

------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
libssh2-devel mailing list
libssh2-devel_at_lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libssh2-devel
Received on 2009-03-23