提交 e899cb3b 创建 作者: Nickolai Zeldovich's avatar Nickolai Zeldovich

ls.cc

上级 386b6539
extern "C" {
#include "types.h" #include "types.h"
#include "stat.h" #include "stat.h"
#include "user.h" #include "user.h"
#include "fs.h" #include "fs.h"
}
char* const char*
fmtname(char *path) fmtname(const char *path)
{ {
static char buf[DIRSIZ+1]; static char buf[DIRSIZ+1];
char *p; const char *p;
// Find first character after last slash. // Find first character after last slash.
for(p=path+strlen(path); p >= path && *p != '/'; p--) for(p=path+strlen(path); p >= path && *p != '/'; p--)
...@@ -23,7 +25,7 @@ fmtname(char *path) ...@@ -23,7 +25,7 @@ fmtname(char *path)
} }
void void
ls(char *path) ls(const char *path)
{ {
char buf[512], *p; char buf[512], *p;
int fd; int fd;
......
...@@ -101,7 +101,7 @@ writec(void *arg, char c) ...@@ -101,7 +101,7 @@ writec(void *arg, char c)
} }
void void
printf(int fd, char *fmt, ...) printf(int fd, const char *fmt, ...)
{ {
va_list ap; va_list ap;
......
...@@ -15,7 +15,7 @@ strncpy(char *s, const char *t, int n) ...@@ -15,7 +15,7 @@ strncpy(char *s, const char *t, int n)
} }
char* char*
strcpy(char *s, char *t) strcpy(char *s, const char *t)
{ {
char *os; char *os;
......
...@@ -28,7 +28,7 @@ void halt(void); ...@@ -28,7 +28,7 @@ void halt(void);
// ulib.c // ulib.c
int stat(char*, struct stat*); int stat(char*, struct stat*);
char* strcpy(char*, char*); char* strcpy(char*, const char*);
void *memmove(void*, const void*, int); void *memmove(void*, const void*, int);
char* strchr(const char*, char c); char* strchr(const char*, char c);
int strcmp(const char*, const char*); int strcmp(const char*, const char*);
...@@ -45,6 +45,6 @@ int atoi(const char*); ...@@ -45,6 +45,6 @@ int atoi(const char*);
int forkt(void *sp, void *pc, void *arg); int forkt(void *sp, void *pc, void *arg);
// printf.c // printf.c
void printf(int, char*, ...); void printf(int, const char*, ...);
void snprintf(char *buf, unsigned int n, const char *fmt, ...); void snprintf(char *buf, unsigned int n, const char *fmt, ...);
void die(const char* errstr, ...) __attribute__((noreturn)); void die(const char* errstr, ...) __attribute__((noreturn));
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论