📄 hy_os.c
字号:
/*
**************************************************************
*
* hyperstone MS-DOS FAT File System Drivers
*
* Link into Real Time Kernel and equivalent routines
*
* Christoph Baumhof 2000-03-21
* Reinhard K乭ne 2000-03-21
* Mihajlo Varga 2000-03-21
*
* Copyright (C) 1997-2000 hyperstone electronics GmbH Konstanz
*
* 2000-03-21 initial release
*
* $Id$
*
* $Log$
*
**************************************************************
*
* Changes:
*
**************************************************************
*/
#include <stdio.h>
#include <stdarg.h>
#include <time.h>
#include <io.h>
#include <sys/unistd.h>
#include <errno.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include "hybios.h"
#include "hy_dos.h"
#include "rpc.h"
#include <sys/hyrtk.h>
static struct hd_driveid id;
static struct PART_SECT p_sect;
static struct BOOT_SECT boot_sect;
#define LOWEST_LOCAL_HANDLE (1 << 14)
#define LF 10 /* line feed */
#define CR 13 /* carriage return */
#define CTRLZ 26 /* ctrl-z means eof for text */
STRUCT_H _handle[HANDLE_MAX];
static short int getftime()
{
time_t timer;
struct tm *tm;
timer = time(NULL);
tm = localtime(&timer);
return ((tm->tm_sec/2) & 0x1f) +
((tm->tm_min & 0x3f) << 5) +
((tm->tm_hour & 0x1f) << 11);
}
static int getfdate()
{
time_t timer;
struct tm *tm;
timer = time(NULL);
tm = localtime(&timer);
return (tm->tm_mday & 0x1f) +
(((tm->tm_mon+1) & 0x0f) << 5) +
(((tm->tm_year-80) & 0x7f) << 9);
}
/* returns index to the _handle structure */
static int search_handle(int handle) {
int i;
for (i=0; i < HANDLE_MAX; i++) {
if ((_handle[i].handle == handle) && _handle[i].valid) {
return i;
}
}
return -1;
}
/* returns index to the _handle structure */
static int search_file(const char * filename) {
int i;
for (i=0; (i < HANDLE_MAX); i++) {
if (_handle[i].valid && *_handle[i].fname) {
if (! stricmp(_handle[i].fname, filename)) {
return i;
}
}
}
return -1;
}
/* returns index to the _handle structure (unused entry) */
static int free_handle(void) {
int i;
for (i=0; (i < HANDLE_MAX); i++) {
if (!_handle[i].valid)
return i;
}
return -1;
}
static const struct dispatch {
const char *cmd;
int (*fn)(int, char **, int);
int type;
} dispatch[] = {
/* {"cd", hy_cd, 0},
{"copy", hy_copy, 0},
{"del", hy_del, 0},
{"deltree", hy_deltree, 2},
{"attrib", _hy_attrib, 0}, */
{"dir", _hy_dir, 0},
/* {"format", hy_format, 0},
{"info", hy_info, 0},
{"label", hy_label, 0},
{"md", hy_md, 0},
{"mount", hy_mount, 0},
{"partition", hy_partition, 0},
{"rd", hy_rd, 1} */
};
#define NDISPATCH (sizeof dispatch / sizeof dispatch[0])
static int _hy__chmod(const char *path, struct RPC_Command *Command,
int func, ... /* int attrib */ ) {
struct directory dir;
int err=EZERO, retvalue;
if ((func == 0) || (func == 1)) {
if (FINDFILE(0, 0, path, &dir, DIRENTRYSTRUCT)) {
if (func==0) { /* read attribute */
retvalue = dir.attr;
}
else { /* write attribute */
/* VARGA */
}
}
else
err = ENOENT;
}
else
err = EACCES;
if (err != EZERO) {
Command->ErrorCode = err;
retvalue = -1;
}
return retvalue;
}
/*
R乧kgabewert
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -