summaryrefslogtreecommitdiff
path: root/src/user/ls.cc
diff options
context:
space:
mode:
authorRichard Qin <richard.qin.x@gmail.com>2026-07-10 11:31:46 +0800
committerRichard Qin <richard.qin.x@gmail.com>2026-07-10 11:31:46 +0800
commite90b72ec3082588b296956730bd2930cf8d5d671 (patch)
tree36ff6916af9b4176ea5a9662219d11e721f0b691 /src/user/ls.cc
parent1767d390fbf3d0c65389de46caf0b6d43ef3b6ad (diff)
downloadlume-e90b72ec3082588b296956730bd2930cf8d5d671.tar.gz
lume-e90b72ec3082588b296956730bd2930cf8d5d671.tar.xz
refactor: promote new architecture to repository root
Archive the deprecated implementation under lume-legacy, make the new kernel the default root-level build, and update repository entry points without changing kernel behavior.
Diffstat (limited to 'src/user/ls.cc')
-rw-r--r--src/user/ls.cc116
1 files changed, 0 insertions, 116 deletions
diff --git a/src/user/ls.cc b/src/user/ls.cc
deleted file mode 100644
index c44c799..0000000
--- a/src/user/ls.cc
+++ /dev/null
@@ -1,116 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-or-later
-/*
- * Copyright (C) 2026 Richard QIn
- */
-#include "ulib/stdio.h"
-#include "ulib/stdlib.h"
-#include "ulib/string.h"
-#include "user/user.h"
-#include "common/fcntl.h"
-
-
-struct FAT32_DirEnt
-{
- char name[11];
- uint8 attr;
- uint8 lcase;
- uint8 ctime_cs;
- uint16 ctime;
- uint16 cdate;
- uint16 adate;
- uint16 fstClusHI;
- uint16 wtime;
- uint16 wdate;
- uint16 fstClusLO;
- uint32 fileSize;
-} __attribute__((packed));
-
-#define ATTR_DIRECTORY 0x10
-#define ATTR_LONG_NAME 0x0F
-
-void fmt_name(char *dst, const char *src)
-{
- int i;
- char *d = dst;
-
- for (i = 0; i < 8; i++)
- {
- if (src[i] == ' ')
- break;
- *d++ = src[i];
- }
-
- if (src[8] != ' ')
- {
- *d++ = '.';
- for (i = 8; i < 11; i++)
- {
- if (src[i] == ' ')
- break;
- *d++ = src[i];
- }
- }
- *d = 0;
-
- for (d = dst; *d; d++)
- {
- if (*d >= 'A' && *d <= 'Z')
- *d += 32;
- }
-}
-
-void ls(const char *path)
-{
- int fd;
- struct FAT32_DirEnt de;
- char name_buf[16];
-
- if ((fd = open(path, O_RDONLY)) < 0)
- {
- printf("ls: cannot open %s\n", path);
- return;
- }
-
- while (read(fd, &de, sizeof(de)) == sizeof(de))
- {
- if (de.name[0] == 0)
- {
- break;
- }
-
- if ((unsigned char)de.name[0] == 0xE5)
- {
- continue;
- }
-
- if ((de.attr & ATTR_LONG_NAME) == ATTR_LONG_NAME)
- {
- continue;
- }
-
- fmt_name(name_buf, de.name);
-
- printf("%s %d\t%s\n",
- (de.attr & ATTR_DIRECTORY) ? "<DIR>" : " ",
- de.fileSize,
- name_buf);
- }
-
- close(fd);
-}
-
-int main(int argc, char *argv[])
-{
- if (argc < 2)
- {
- ls(".");
- }
- else
- {
- for (int i = 1; i < argc; i++)
- {
- ls(argv[i]);
- }
- }
- exit(0);
-} \ No newline at end of file