Re: pscp ls --time-style=long-iso display

From: all mail refused (elvis_at_notatla.org.uk)
Date: 12/24/04


Date: 24 Dec 2004 00:30:01 GMT

In article <1103828175.872895.167990@z14g2000cwz.googlegroups.com>, manu wrote:

>This gives the following output.
>-rw-r--r-- 258048 Jul 9 14:15 TTFILE00-3165

>I am trying to modify the code of pscp to manage to send the

>Apparently pscp uses a ssh code (SSH_FXP_OPENDIR 11) to ask the server
>to execute a ls.

Don't know. Code to do "ls" type stuff looks sometjing like this

If you haven't already got this in your server try adding it as
well as or instead of the SSH_FXP_OPENDIR you've noticed.

#include <dirent.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <time.h>
#include <unistd.h>

int longlisting(char *d)
{
DIR *dh;
int ld;
char *dn;
char ldn[2048];
struct dirent *de;
struct stat sb;
time_t t;
struct tm *bt;

if (!d) return (-1);
ld=strlen(d);
dh=opendir(d);
if (!dh) return (-1);
while ( (de=readdir(dh)) ) {
        dn= de->d_name;
        if ( ((int)ld + (int)strlen(dn) ) > 2000 ) {
           /* avoid buffer overflows */
           fprintf(stderr, "LONG NAME - QUITTING\n");
            break;
        }
        sprintf(ldn, "%s/%s", d, de->d_name);
        if (0 != lstat(ldn, &sb)) {
            perror("lstat() failed:");
            break;
        }
        while (1) {
            if (S_ISREG(sb.st_mode)) {printf("-"); break;}
            if (S_ISDIR(sb.st_mode)) {printf("d"); break;}
            if (S_ISLNK(sb.st_mode)) {printf("l"); break;}
            printf("?"); break;
        }

        /* XXX Number wants converting to rwxrwxrwx, style */
        printf("%0o ", sb.st_mode & ~S_IFMT);

        printf("%12d ", sb.st_size);
        t=sb.st_mtime;
        bt=localtime(&t);
        printf("%04d-%02d-%02d %02d:%02d:%02d ",
            1900+bt->tm_year, 1+bt->tm_mon, bt->tm_mday,
            bt->tm_hour, bt->tm_min, bt->tm_sec );
        printf("%s\n", dn );
}
closedir(dh);
}

int main()
{
longlisting("/etc");
exit(0);
}

-- 
Elvis Notargiacomo  master AT barefaced DOT cheek
http://www.notatla.org.uk/goen/
    7.031: OnACPower returned value( 0x1 ) which is Equal To 0x1


Relevant Pages

  • Re: Init.c, making it chroot
    ... that's located at a special place inside the chroot. ... int devfs; ... typedef struct init_session { ... main(int argc, char *argv) ...
    (freebsd-hackers)
  • [PATCH]a tar filesystem for 2.6.10-rc1-mm3
    ... +static int tarfs_readdir(struct file * filp, ... struct tarent *dir_tarent, *ent; ... +static int tarfs_readlink(struct dentry *dentry, char *buffer, int buflen) ...
    (Linux-Kernel)
  • [PATCH] a tar filesystem for 2.6.*(easily access tar file)
    ... +static int tarfs_readdir(struct file * filp, ... struct tarent *dir_tarent, *ent; ... +static int tarfs_readlink(struct dentry *dentry, char *buffer, int buflen) ...
    (Linux-Kernel)
  • Re: Memory Structure Pointer Problems
    ... typedef struct sta { ... char* name; ... int num_cmpnds; ... A pointer to a struct cmp is almost ...
    (comp.lang.c)
  • Re: Connector - how to start?
    ... It seems like one of the Red Hat guys had some netlink documentation ... Netlink is fast but not faster than char device for example, ... static int need_exit; ... struct nlmsghdr *nlh; ...
    (Linux-Kernel)