git.ucc.asn.au
/
tpg
/
acess2.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
InitRD - Libc++, libm, bochs, dbserver
[tpg/acess2.git]
/
Usermode
/
Applications
/
ls_src
/
main.c
diff --git
a/Usermode/Applications/ls_src/main.c
b/Usermode/Applications/ls_src/main.c
index
57ff306
..
973013b
100644
(file)
--- a/
Usermode/Applications/ls_src/main.c
+++ b/
Usermode/Applications/ls_src/main.c
@@
-51,17
+51,17
@@
int main(int argc, char *argv[])
ParseArguments(argc, argv);
// Open Directory
ParseArguments(argc, argv);
// Open Directory
- fd =
o
pen(gsDirectory, OPENFLAG_READ|OPENFLAG_EXEC);
+ fd =
_SysO
pen(gsDirectory, OPENFLAG_READ|OPENFLAG_EXEC);
if(fd == -1) {
printf("Unable to open '%s' for reading\n", gsDirectory);
return EXIT_FAILURE;
}
// Check that it is a directory
if(fd == -1) {
printf("Unable to open '%s' for reading\n", gsDirectory);
return EXIT_FAILURE;
}
// Check that it is a directory
-
fi
nfo(fd, &info, 0);
+
_SysFI
nfo(fd, &info, 0);
if( !(info.flags & FILEFLAG_DIRECTORY) ) {
fprintf(stderr, "'%s' is not a directory\n", gsDirectory);
if( !(info.flags & FILEFLAG_DIRECTORY) ) {
fprintf(stderr, "'%s' is not a directory\n", gsDirectory);
-
c
lose(fd);
+
_SysC
lose(fd);
return EXIT_FAILURE;
}
return EXIT_FAILURE;
}
@@
-75,11
+75,11
@@
int main(int argc, char *argv[])
}
// Traverse Directory
}
// Traverse Directory
- while( (tmp =
readdir(fd, buf))
)
+ while( (tmp =
_SysReadDir(fd, buf)) > 0
)
{
// Error check
if(tmp < 0) {
{
// Error check
if(tmp < 0) {
-
c
lose(fd);
+
_SysC
lose(fd);
return EXIT_FAILURE;
}
return EXIT_FAILURE;
}
@@
-89,7
+89,7
@@
int main(int argc, char *argv[])
space += 16;
gFileList = realloc(gFileList, space*sizeof(char*));
if(gFileList == NULL) {
space += 16;
gFileList = realloc(gFileList, space*sizeof(char*));
if(gFileList == NULL) {
-
c
lose(fd);
+
_SysC
lose(fd);
return EXIT_FAILURE;
}
}
return EXIT_FAILURE;
}
}
@@
-105,7
+105,7
@@
int main(int argc, char *argv[])
DisplayFile( gFileList[i] );
}
DisplayFile( gFileList[i] );
}
-
c
lose(fd);
+
_SysC
lose(fd);
printf("\n");
return EXIT_SUCCESS;
printf("\n");
return EXIT_SUCCESS;
@@
-152,7
+152,7
@@
void ParseArguments(int argc, char *argv[])
// Human readable sizes
case 'h': gbViewHumanReadable = 1; continue;
default:
// Human readable sizes
case 'h': gbViewHumanReadable = 1; continue;
default:
- fprintf(stderr, "%s: Unknown option '%c'\n", *str);
+ fprintf(stderr, "%s: Unknown option '%c'\n",
argv[0],
*str);
ShowUsage(argv[0]);
exit(EXIT_FAILURE);
}
ShowUsage(argv[0]);
exit(EXIT_FAILURE);
}
@@
-218,13
+218,13
@@
void DisplayFile(char *Filename)
strcpy(&path[dirLen+1], Filename);
// Get file type
strcpy(&path[dirLen+1], Filename);
// Get file type
- fd =
o
pen(path, 0);
+ fd =
_SysO
pen(path, 0);
if(fd == -1) {
fprintf(stderr, "Unable to open '%s'\n", path);
}
else {
// Get Info
if(fd == -1) {
fprintf(stderr, "Unable to open '%s'\n", path);
}
else {
// Get Info
-
fi
nfo(fd, &info, 0);
+
_SysFI
nfo(fd, &info, 0);
// Get Type
if(info.flags & FILEFLAG_DIRECTORY) {
type = FTYPE_DIR;
// Get Type
if(info.flags & FILEFLAG_DIRECTORY) {
type = FTYPE_DIR;
@@
-243,26
+243,26
@@
void DisplayFile(char *Filename)
// Get Permissions
// - Owner
// Get Permissions
// - Owner
- acl.
group = 0; acl.id
= info.uid;
+ acl.
object
= info.uid;
_SysGetACL(fd, &acl);
if(acl.perms & 1) perms |= 0400; // R
if(acl.perms & 2) perms |= 0200; // W
if(acl.perms & 8) perms |= 0100; // X
// - Group
_SysGetACL(fd, &acl);
if(acl.perms & 1) perms |= 0400; // R
if(acl.perms & 2) perms |= 0200; // W
if(acl.perms & 8) perms |= 0100; // X
// - Group
- acl.
group = 1; acl.id = info.gid
;
+ acl.
object = info.gid | 0x80000000
;
_SysGetACL(fd, &acl);
if(acl.perms & 1) perms |= 0040; // R
if(acl.perms & 2) perms |= 0020; // W
if(acl.perms & 8) perms |= 0010; // X
// - World
_SysGetACL(fd, &acl);
if(acl.perms & 1) perms |= 0040; // R
if(acl.perms & 2) perms |= 0020; // W
if(acl.perms & 8) perms |= 0010; // X
// - World
- acl.
group = 1; acl.id = -1
;
+ acl.
object = 0xFFFFFFFF
;
_SysGetACL(fd, &acl);
if(acl.perms & 1) perms |= 0004; // R
if(acl.perms & 2) perms |= 0002; // W
if(acl.perms & 8) perms |= 0001; // X
// Close file
_SysGetACL(fd, &acl);
if(acl.perms & 1) perms |= 0004; // R
if(acl.perms & 2) perms |= 0002; // W
if(acl.perms & 8) perms |= 0001; // X
// Close file
-
c
lose(fd);
+
_SysC
lose(fd);
}
free(path); // We're finished with it
}
free(path); // We're finished with it
@@
-283,22
+283,22
@@
void DisplayFile(char *Filename)
printf("%s %4i %4i ", permStr, owner, group);
if(gbViewHumanReadable && type != FTYPE_DIR) {
if(size < 2048) { // < 2 KiB
printf("%s %4i %4i ", permStr, owner, group);
if(gbViewHumanReadable && type != FTYPE_DIR) {
if(size < 2048) { // < 2 KiB
- printf("%4i B ", size);
+ printf("%4
ll
i B ", size);
}
else if(size < 2048*1024) { // < 2 MiB
}
else if(size < 2048*1024) { // < 2 MiB
- printf("%4i KiB ", size>>10);
+ printf("%4
ll
i KiB ", size>>10);
}
else if(size < (uint64_t)2048*1024*1024) { // < 2 GiB
}
else if(size < (uint64_t)2048*1024*1024) { // < 2 GiB
- printf("%4i MiB ", size>>20);
+ printf("%4
ll
i MiB ", size>>20);
}
else if(size < (uint64_t)2048*1024*1024*1024) { // < 2 TiB
}
else if(size < (uint64_t)2048*1024*1024*1024) { // < 2 TiB
- printf("%4i GiB ", size>>30);
+ printf("%4
ll
i GiB ", size>>30);
}
}
- else { // Greater than 2 TiB
- printf("%4i TiB ", size>>40);
+ else { // Greater than 2 TiB
(if your files are larger than this, you are Doing It Wrong [TM])
+ printf("%4
ll
i TiB ", size>>40);
}
} else {
}
} else {
- printf("%8i ", size);
+ printf("%8
ll
i ", size);
}
}
}
}
UCC
git Repository :: git.ucc.asn.au