📄 link_r.c
字号:
#include <reent.h>#include <errno.h>#include <devices.h>#include <string.h>#include <sysdefs.h>#include <ioctl.h>int _link_r (struct _reent *r, const char * old, const char * new){#ifdef HAS_MMCint len, idx;struct IOCTLRENAMESTRUCT { const char * oldname; const char * newname;} IOCTL_RENAME; // all devices must start with a name and name is bracketed with '/'. if (old[0] == '/') { // we might have a valid device name, search the table list. for (idx=0; device_table_list [idx].item; idx++) { len = strlen(device_table_list[idx].item->name); if (strncmp (device_table_list [idx].item->name, &old[1], len) == 0) { // ensure trailing '/'. if (old[len+1] != '/') continue; // found it, now call the open. // device is called with device name removed. if (device_table_list [idx].item->ioctl) { IOCTL_RENAME.oldname = &old[len+2]; IOCTL_RENAME.newname = new; return device_table_list [idx].item->ioctl (r, 0, IOCTL_MMC_RENAME, &IOCTL_RENAME); } } } }#endif // otherwise we get nasty about it.. r->_errno = EINVAL; return -1;}// vi:nowrap
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -