      SUBROUTINE MAIN
      INTEGER DESC, FOUND, FUIC, D, I, J, LOCAL, GRP, MEM, JUNK, VERBOS,
     * WIDTH
      LOGICAL*1 FILE(40), DEV(10), BUF(40), BUIC(2), UIC(10), ARG(10), D
     *IRECT(40)
      INTEGER OPENDR, GDRPRM, INDEXS, F11UIC, EQUAL, GETARG, INDEXC
      EQUIVALENCE (FUIC, BUIC(1))
      LOGICAL*1 DOTDIR(5)
      LOGICAL*1 ROOT(8)
      DATA DOTDIR(1)/46/,DOTDIR(2)/100/,DOTDIR(3)/105/,DOTDIR(4)/114/,DO
     *TDIR(5)/0/
      DATA ROOT(1)/91/,ROOT(2)/48/,ROOT(3)/44/,ROOT(4)/51/,ROOT(5)/55/,R
     *OOT(6)/55/,ROOT(7)/93/,ROOT(8)/0/
      CALL QUERY(27Husage:  lsd [-lv] [device].)
      LOCAL = 0
      VERBOS = 0
      WIDTH = -1
      CALL TRNDEV(2HSY, 0, DEV)
      I=1
23000 IF (.NOT.(GETARG(I, ARG, 10) .NE. -1))GOTO 23002
      IF (.NOT.(ARG(1) .EQ. 45))GOTO 23003
      CALL FOLD(ARG)
      IF (.NOT.(INDEXC(ARG, 108) .GT. 0))GOTO 23005
      LOCAL = 1
23005 CONTINUE
      IF (.NOT.(INDEXC(ARG, 118) .GT. 0))GOTO 23007
      WIDTH = -20
      VERBOS = 1
23007 CONTINUE
      GOTO 23004
23003 CONTINUE
      CALL FXLATE(ARG,6, DEV)
23004 CONTINUE
23001 I=I+1
      GOTO 23000
23002 CONTINUE
      CALL CONCAT(DEV, ROOT, DIRECT)
      IF (.NOT.(OPENDR(DIRECT, DESC) .NE. -3))GOTO 23009
23011 IF (.NOT.(GDRPRM(DESC, FILE) .NE. -1))GOTO 23012
      I = INDEXS(FILE, DOTDIR)
      IF (.NOT.(I .GT. 0))GOTO 23013
      FILE(I) = 0
      J = 1
      CALL STCOPY(DEV, 1, BUF, J)
      CALL CHCOPY(91, BUF, J)
      CALL STCOPY(FILE, 1, BUF, J)
      CALL CHCOPY(93, BUF, J)
      JUNK = F11UIC(DESC, FUIC)
      MEM = BUIC(1)
      GRP = BUIC(2)
      CALL FMTUIC(GRP, MEM, UIC)
      IF (.NOT.(LOCAL .EQ. 1))GOTO 23015
      CALL FXLATE(BUF,6, FILE)
      GOTO 23016
23015 CONTINUE
      CALL MKPATH(BUF, FILE)
23016 CONTINUE
      CALL PUTSTR(FILE, WIDTH, 2)
      IF (.NOT.(VERBOS .EQ. 1))GOTO 23017
      CALL PUTLIN(UIC, 2)
23017 CONTINUE
      CALL PUTCH(10, 2)
23013 CONTINUE
      GOTO 23011
23012 CONTINUE
23009 CONTINUE
      CALL CLOSDR(DESC)
      RETURN
      END
