This commit is contained in:
Your Name 2023-11-22 13:58:43 +03:00
parent 751421d2e2
commit 3e88a43744
7 changed files with 14 additions and 15 deletions

2
TODO
View File

@ -62,7 +62,7 @@ Findutils:
xargs
Shell:
lsh - lavash
rc - run command
Init:
sinit - Simple init

View File

@ -10,6 +10,9 @@
/* format for printf (head) */
#define HEAD_FMT "==> %s <==\n"
/* du block size */
#define BLK_SIZE 512
/* Options: To disable, comment line */
/* Add escape-char support in echo */
#define ECHO_FANCY

View File

@ -7,20 +7,19 @@
#include <stdint.h>
#include "get_stat.h"
#include "make_path.h"
#include "human.c"
#include "human.h"
#include "config.h"
unsigned int h_flag;
unsigned int s_flag;
unsigned int c_flag;
unsigned int b_flag;
unsigned int n_flag;
off_t blksize;
off_t total;
void print(off_t size, const char *filename) {
if (h_flag)
printf("%s\t%s%c", mu_humansize(size * blksize), filename, (n_flag) ? '\0' : '\n');
printf("%s\t%s%c", mu_humansize(size * BLK_SIZE), filename, (n_flag) ? '\0' : '\n');
else
printf("%jd\t%s%c", (intmax_t)size, filename, (n_flag) ? '\0' : '\n');
@ -72,7 +71,7 @@ off_t du(const char *path, int recurs_flag) {
sum = sb.st_size;
else
sum = (512 * sb.st_blocks + blksize - 1) / blksize;
sum = (512 * sb.st_blocks + BLK_SIZE - 1) / BLK_SIZE;
if (c_flag)
total += sum;
@ -85,7 +84,6 @@ off_t du(const char *path, int recurs_flag) {
}
int main(int argc, char **argv) {
blksize = 512;
int opt;
while ((opt = getopt(argc, argv, "hsbc0")) != -1) {

View File

@ -137,7 +137,7 @@ int print(const struct d_node *node) {
}
if (!l_flag)
return printf("%s%c", node->name, suf);
return printf("%s%c ", node->name, suf);
if (l_flag) {
GetPerm(node->stats);
@ -162,9 +162,10 @@ void col_print(struct d_node **node, size_t files, struct winsize w) {
size_t maxlen = 0;
for (size_t i = 0; i < files; i++)
if (strlen(node[i]->name) > maxlen)
maxlen = strlen(node[i]->name) + 3;
maxlen = strlen(node[i]->name);
/* Calc */
maxlen += 4;
size_t ncols = w.ws_col / maxlen;
size_t nrows = files;
if (ncols > 1) {

3
shell/rc.c Normal file
View File

@ -0,0 +1,3 @@
int main(void) {
return 0;
}

View File

@ -1,6 +0,0 @@
#include <stdio.h>
#include <stdlib.h>
int main(void) {
return 0;
}