anchor.diff:  	    send_status({error, Error}, ReqId, State1)
       end.
   
  +type_to_string(regular)   -> "-";
  +type_to_string(directory) -> "d";
  +type_to_string(symlink)   -> "s";
  +type_to_string(device)   -> "?";
  +type_to_string(undefined)   -> "?";
  +type_to_string(other)   -> "?".
  +
  +%% Converts a numeric mode to its human-readable representation
  +mode_to_string(Mode) ->
  +    mode_to_string(Mode, "xwrxwrxwr", []).
  +mode_to_string(Mode, [C|T], Acc) when Mode band 1 =:= 1 ->
  +    mode_to_string(Mode bsr 1, T, [C|Acc]);
  +mode_to_string(Mode, [_|T], Acc) ->
  +    mode_to_string(Mode bsr 1, T, [$-|Acc]);
  +mode_to_string(_, [], Acc) ->
  +    Acc.
  +
  +%% Converts a POSIX time to a readable string
  +time_to_string({{Y, Mon, Day}, {H, Min, _}}) ->
  +    io_lib:format("~s ~2w ~s:~s ~w", [month(Mon), Day, two_d(H), two_d(Min), Y]).
  +
  +two_d(N) ->
  +    tl(integer_to_list(N + 100)).
  +
  +month(1) -> "Jan";
  +month(2) -> "Feb";
  +month(3) -> "Mar";
  +month(4) -> "Apr";
  +month(5) -> "May";
  +month(6) -> "Jun";
  +month(7) -> "Jul";
  +month(8) -> "Aug";
  +month(9) -> "Sep";
  +month(10) -> "Oct";
  +month(11) -> "Nov";
  +month(12) -> "Dec".
  +
  +longame({Name, Type, Size, Mtime, Mode, Uid, Gid}) ->
  +	io_lib:format("~s~s ~4w/~-4w ~7w ~s ~s\n", 
  +           [type_to_string(Type), mode_to_string(Mode),
  +           Uid, Gid, Size, time_to_string(Mtime), Name]).
  +
  +%%% get_long_name: get file longname (version 3)
  +%%% format output : -rwxr-xr-x   1 uid/gid    348911 Mar 25 14:29 t-filexfer
  +get_long_name(FileName, I) when is_record(I, file_info) ->
  +    longame({FileName, I#file_info.type, I#file_info.size, I#file_info.mtime, 
  +        I#file_info.mode, I#file_info.uid, I#file_info.gid}).
   
   %%% get_attrs: get stat of each file and return
  -get_attrs(RelPath, Files, FileMod, FS) ->
  -    get_attrs(RelPath, Files, FileMod, FS, []).
  -
  -get_attrs(_RelPath, [], _FileMod, FS, Acc) ->
  +get_attrs(RelPath, Files, FileMod, FS, Vsn) ->
  +    get_attrs(RelPath, Files, FileMod, FS, Vsn, []).
  +
  +get_attrs(_RelPath, [], _FileMod, FS, _Vsn, Acc) ->
       {lists:reverse(Acc), FS};
  -get_attrs(RelPath, [F | Rest], FileMod, FS0, Acc) ->
  +get_attrs(RelPath, [F | Rest], FileMod, FS0, Vsn, Acc) ->
       Path = filename:absname(F, RelPath),
       case FileMod:read_link_info(Path, FS0) of
   	{{ok, Info}, FS1} ->
  +		Name = if Vsn =< 3 ->
  +			 LongName = get_long_name(F, Info),
  +		     {F, LongName};
  +		 true ->
  +			 F
  +	     end,
   	    Attrs = ssh_sftp:info_to_attr(Info),
  -	    get_attrs(RelPath, Rest, FileMod, FS1, [{F, Attrs} | Acc]);
  +	    get_attrs(RelPath, Rest, FileMod, FS1, Vsn, [{Name, Attrs} | Acc]);
   	{{error, enoent}, FS1} ->
  -	    get_attrs(RelPath, Rest, FileMod, FS1, Acc);
  +	    get_attrs(RelPath, Rest, FileMod, FS1, Vsn, Acc);
   	{Error, FS1} ->
   	    {Error, FS1}
       end.
  
positive.code: 	    State0#state{handles = Handles, file_state = FS1}
      end;
  read_dir(State0 = #state{file_handler = FileMod, max_files = MaxLength, file_state = FS0},
  	 XF, ReqId, Handle, RelPath, _Status) ->
      AbsPath = relate_file_name(RelPath, State0),
      {Res, FS1} = FileMod:list_dir(AbsPath, FS0),
      case Res of
  	{ok, Files} when MaxLength == 0 orelse MaxLength > length(Files) ->
  	    {NamesAndAttrs, FS2} = get_attrs(AbsPath, Files, FileMod, FS1),
  	    ssh_xfer:xf_send_names(XF, ReqId, NamesAndAttrs),
  	    Handles = lists:keyreplace(Handle, 1,
  				       State0#state.handles,
  
negative.code: -include("ssh.hrl").
  -include("ssh_xfer.hrl").
  -include("ssh_connect.hrl"). %% For ?DEFAULT_PACKET_SIZE and ?DEFAULT_WINDOW_SIZE
  
  
  %%--------------------------------------------------------------------
  %% External exports
  