- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
- 91
- 92
- 93
- 94
- 95
- 96
- 97
- 98
- 99
- 100
// https://github.com/sergev/bkunix/blob/master/src/bin/pwd.c
void
cat(name)
char *name;
{
register int i, j;
i = -1;
while (name[++i] != 0);
if ((off+i+2) > 511) {
write(2, "pwd: too long path\n", 19);
exit(1);
}
for (j=off+1; j>=0; --j)
path[j+i+1] = path[j];
off=i+off+1;
path[i] = '/';
for (--i; i>=0; --i)
path[i] = name[i];
}
char * ckroot(dev, ino)
int dev, ino;
{
DIR * dir;
struct stat st;
register struct dirent * d;
chdir("/");
dir = opendir("/");
do {
d = readdir(dir);
if (! d) {
return "[mount point]";
}
stat(d->d_name, &st);
} while (st.st_dev != dev || st.st_ino != ino);
closedir(dir);
return d->d_name;
}
int
main()
{
int rdev, rino;
DIR *dir;
struct stat dot, dotdot;
register struct dirent *d;
stat("/", &dot);
rdev = dot.st_dev;
rino = dot.st_ino;
/*printf ("/ dev=%d ino=%d\n", rdev, (int) rino);*/
for (;;) {
stat(".", &dot);
/*printf (". dev=%d ino=%d\n", (int) dot.st_dev, (int) dot.st_ino);*/
if (dot.st_ino == rino && dot.st_dev == rdev)
break;
dir = opendir("..");
if (! dir) {
write(2, "pwd: cannot open ..\n", 20);
return 1;
}
stat("..", &dotdot);
/*printf (".. dev=%d ino=%d\n", (int) dotdot.st_dev, (int) dotdot.st_ino);*/
chdir("..");
if (dot.st_dev == dotdot.st_dev) {
if (dot.st_ino == dotdot.st_ino) {
cat(ckroot(dot.st_dev, dot.st_ino));
break;
}
do {
d = readdir(dir);
if (! d) {
write(2, "read error in ..\n", 17);
return 1;
}
} while (d->d_ino != dot.st_ino);
} else {
do {
d = readdir(dir);
if (! d) {
write(2, "read error in ..\n", 17);
return 1;
}
stat(d->d_name, &dotdot);
/*printf ("%.14s dev=%d ino=%d\n", d->d_name, (int) dotdot.st_dev, (int) dotdot.st_ino);*/
} while (dotdot.st_ino != dot.st_ino ||
dotdot.st_dev != dot.st_dev);
}
closedir(dir);
cat(d->d_name);
/*path[off] = 0; printf ("pwd %s\n", path);*/
}
write(1, "/", 1);
if (off < 0)
off = 0;
path[off] = '\n';
write(1, path, off + 1);
return 0;
}
j123123 # 0
bormand # 0 ⇈
А почему его нет? Какая-то необычная эмбеддед ось?
j123123 # 0 ⇈
https://ru.wikipedia.org/wiki/Операционные_системы_БК-0010/11#BKUNIX
https://github.com/sergev/bkunix/
guest # 0 ⇈
https://github.com/sergev/bkunix/blob/master/src/stand/console.c
guest # 0 ⇈
какой свитч)
какой к&r
guest # 0 ⇈
Обычная си-лапша.
j123123 # 0 ⇈
https://www.mailcom.com/lsx/index.html
guest # 0 ⇈
блядь, реально чтоли эмуль поставть и запидролица?
>Most importantly, on Unix V6, it's not cd, it's chdir!
хи
А какой там редактор? ed?
j123123 # 0 ⇈
Да.
https://www.mailcom.com/lsx/log.txt
guest # 0 ⇈
Не, в ed я должно не просижу. vi вроде изобрели примерно в том же году, но в BSD, а не в самом unix
ASD_77 # 0
guest # 0
Ого, думал в Си так незя
j123123 # 0 ⇈
guest # 0 ⇈
j123123 # 0 ⇈