[dev] Re: [sbase] [PATCH] ls: List directory contents if file is a symlink to a directory
On Sun, Dec 07, 2014 at 10:40:42PM +0000, Michael Forney wrote:
> ---
> ls.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/ls.c b/ls.c
> index b48391b..90193cc 100644
> --- a/ls.c
> +++ b/ls.c
> _AT_@ -21,6 +21,7 @@ typedef struct {
> off_t size;
> time_t mtime;
> ino_t ino;
> + int isdir;
> } Entry;
>
> static int entcmp(const void *, const void *);
> _AT_@ -117,7 +118,7 @@ entcmp(const void *va, const void *vb)
> static void
> ls(Entry *ent)
> {
> - if (S_ISDIR(ent->mode) && !dflag) {
> + if (ent->isdir && !dflag) {
> lsdir(ent->name);
> } else {
> output(ent);
> _AT_@ -191,6 +192,7 @@ mkent(Entry *ent, char *path, int dostat)
> ent->size = st.st_size;
> ent->mtime = st.st_mtime;
> ent->ino = st.st_ino;
> + ent->isdir = S_ISLNK(ent->mode) && stat(path, &st) == 0 && S_ISDIR(st.st_mode);
Whoops, this should also have S_ISDIR(ent->mode) || ...
Will send a new patch shortly.
Received on Sun Dec 07 2014 - 23:51:33 CET
This archive was generated by hypermail 2.3.0
: Mon Dec 08 2014 - 00:00:25 CET