don't print 0 bytes for ls commands
authorKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Tue, 17 Jan 1989 04:03:11 +0000 (20:03 -0800)
committerKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Tue, 17 Jan 1989 04:03:11 +0000 (20:03 -0800)
SCCS-vsn: libexec/ftpd/ftpd.c 5.25

usr/src/libexec/ftpd/ftpd.c

index db23121..06e1667 100644 (file)
@@ -22,7 +22,7 @@ char copyright[] =
 #endif /* not lint */
 
 #ifndef lint
 #endif /* not lint */
 
 #ifndef lint
-static char sccsid[] = "@(#)ftpd.c     5.24 (Berkeley) %G%";
+static char sccsid[] = "@(#)ftpd.c     5.25 (Berkeley) %G%";
 #endif /* not lint */
 
 /*
 #endif /* not lint */
 
 /*
@@ -429,20 +429,21 @@ retrieve(cmd, name)
        struct stat st;
        int (*closefunc)(), tmp;
 
        struct stat st;
        int (*closefunc)(), tmp;
 
-       if (cmd == 0)
+       if (cmd == 0) {
                fin = fopen(name, "r"), closefunc = fclose;
                fin = fopen(name, "r"), closefunc = fclose;
-       else {
+               st.st_size = 0;
+       } else {
                char line[BUFSIZ];
 
                (void) sprintf(line, cmd, name), name = line;
                fin = ftpd_popen(line, "r"), closefunc = ftpd_pclose;
                char line[BUFSIZ];
 
                (void) sprintf(line, cmd, name), name = line;
                fin = ftpd_popen(line, "r"), closefunc = ftpd_pclose;
+               st.st_size = -1;
        }
        if (fin == NULL) {
                if (errno != 0)
                        perror_reply(550, name);
                return;
        }
        }
        if (fin == NULL) {
                if (errno != 0)
                        perror_reply(550, name);
                return;
        }
-       st.st_size = 0;
        if (cmd == 0 &&
            (stat(name, &st) < 0 || (st.st_mode&S_IFMT) != S_IFREG)) {
                reply(550, "%s: not a plain file.", name);
        if (cmd == 0 &&
            (stat(name, &st) < 0 || (st.st_mode&S_IFMT) != S_IFREG)) {
                reply(550, "%s: not a plain file.", name);