Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
1563003
Latest stdio destructor changes was creating a bad problem subtractin…
afxgroup Jan 14, 2025
d0ce9f2
Duplicate IO handles on CreateNewProc
afxgroup Jan 14, 2025
ceeeecb
Merge branch 'development' of github.com:AmigaLabs/clib4 into develop…
afxgroup Jan 14, 2025
5827b22
Merge branch 'development' of github.com:AmigaLabs/clib4 into develop…
afxgroup Jan 19, 2025
b6f9bdd
More WINDOWS to LINUX file ending conversion
afxgroup Jan 21, 2025
107cfed
Wrong Printf version requirement printing
afxgroup Jan 28, 2025
bd6b295
Merge branch 'development' of github.com:AmigaLabs/clib4 into line_en…
afxgroup Jan 28, 2025
2f80f55
Get DOSIFace in pthread_create from extern _IDOS
afxgroup Jan 30, 2025
7676191
Merge branch 'afxgroup' of github.com:AmigaLabs/clib4 into afxgroup
afxgroup Jan 30, 2025
989e54f
Added %b format type in printf
afxgroup Feb 8, 2025
ebd6998
Fix on dcngettext was crashing on bindtextdomain and on destructor
afxgroup Feb 9, 2025
03053e5
Added Amiga-1251 charset to iconv
afxgroup Feb 9, 2025
39f9de7
Removed __set_errno from librt since it isn't exported and undefined …
afxgroup Feb 12, 2025
6f9e9d7
Added dlopen example to test shared objects alog rpath and soname
afxgroup Feb 23, 2025
0894c8c
Removed some quirks from dlopen examples
afxgroup Feb 23, 2025
e9e190c
Added static_assert in assert.h
afxgroup Feb 28, 2025
2a0ea0f
Reverted back flock.c changes
afxgroup Feb 28, 2025
11e4d31
Merge branch 'development' of github.com:AmigaLabs/clib4 into afxgroup
afxgroup Feb 28, 2025
52259e3
Changed back (again..) flock.c
afxgroup Feb 28, 2025
4853e6b
Merge branch 'development' of github.com:AmigaLabs/clib4 into afxgroup
afxgroup Feb 28, 2025
06216df
implemented NETBSD getvfsstat function and added an example to test i…
afxgroup Mar 2, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions libc.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ C_NL_TYPES := \
C_POSIX := \
posix/fnmatch.o \
posix/fstatvfs.o \
posix/getvfsstat.o \
posix/glob.o \
posix/globfree.o \
posix/basename.o \
Expand Down
7 changes: 7 additions & 0 deletions library/include/sys/statvfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
#define ST_NOSUID 0x0002 /* Does not support the semantics of the ST_ISUID and ST_ISGID file mode bits. */
#define ST_CASE_SENSITIVE 0x0004 /* The file system is case sensitive. */

#define ST_WAIT 1
#define ST_NOWAIT 2

__BEGIN_DECLS

struct statvfs {
Expand All @@ -24,10 +27,14 @@ struct statvfs {
unsigned long f_fsid;
unsigned long f_flag;
unsigned long f_namemax;

char f_mntonname[256]; // Mount point
char f_fstypename[32]; // File system type
};

extern int statvfs(const char *, struct statvfs *);
extern int fstatvfs(int, struct statvfs *);
extern int getvfsstat(struct statvfs *buf, size_t bufsize, int flags);

__END_DECLS

Expand Down
5 changes: 5 additions & 0 deletions library/include/sys/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ typedef unsigned long useconds_t;
typedef long suseconds_t;

typedef int32_t blksize_t;
#ifndef __USE_FILE_OFFSET64
typedef int32_t blkcnt_t;
#else
typedef int64_t blkcnt_t;
#endif

typedef unsigned long long u_quad_t; /* quads */
typedef long long quad_t;
Expand Down
101 changes: 101 additions & 0 deletions library/posix/getvfsstat.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
/*
* $Id: posix_getvfsstat.c,v 1.0 2025-02-03 16:35:27 clib4devs Exp $
*/

#ifndef _STDIO_HEADERS_H
#include "stdio_headers.h"
#endif /* _STDIO_HEADERS_H */

#ifndef _POSIX_HEADERS_H
#include "posix_headers.h"
#endif /* _POSIX_HEADERS_H */

int
getvfsstat(struct statvfs *buf, size_t bufsize, int flags) {
struct _clib4 *__clib4 = __CLIB4;
int count = 0;
uint32_t lFlags = LDF_DEVICES | LDF_READ;

/* On OS4 we don't have any difference between ST_WAIT and ST_NOWAIT */
if (flags != ST_WAIT && flags != ST_NOWAIT) {
__set_errno_r(__clib4, EINVAL);
return -1;
}

struct DosList *dosList = LockDosList(lFlags);
if (dosList == NULL) {
__set_errno_r(__clib4, ENOMEM);
return -1;
}

struct InfoData *info = AllocDosObject(DOS_INFODATA, 0);
if (info == NULL) {
__set_errno_r(__clib4, ENOMEM);
UnLockDosList(LDF_DEVICES | LDF_READ);
return -1;
}

// Traverse the DOS list
while ((dosList = NextDosEntry(dosList, lFlags))) {
if (dosList->dol_Port != NULL) {
/* If buf is NOT NULL just get all information from DosList entry and increase the count */
if (buf != NULL) {
// Check if the buffer has space
if (count >= bufsize / sizeof(struct statvfs)) {
break;
}

if (GetDiskInfoTags(
GDI_MsgPortInput, dosList->dol_Port,
GDI_InfoData, info,
TAG_END) != 0) {

uint32 DosType = info->id_DiskType;

/* Convert the InfoData to statvfs structure */
__convert_info_to_statvfs(info, &buf[count]);
/* Populate the missing statvfs structure */
CopyStringBSTRToC(dosList->dol_Name, buf[count].f_mntonname, sizeof(buf[count].f_mntonname));

/* Skip DOSType checking if Disk is not present (for example on ICD0, IDF0 and so on..) */
if (info->id_DiskType != ID_NO_DISK_PRESENT) {
const char *dosFormat = "%c%c%c\\%02lx";
if ((DosType & 0xFF) > 0x20) {
dosFormat = "%c%c%c%c";
}
if (!(DosType & 0xFF000000))
DosType |= 0x20000000;
else if (!(DosType & 0x00FF0000))
DosType |= 0x00200000;
else if (!(DosType & 0x0000FF00))
DosType |= 0x00002000;

sprintf(buf[count].f_fstypename, dosFormat, (DosType >> 24) & 0xFF, (DosType >> 16) & 0xFF,
(DosType >> 8) & 0xFF, DosType & 0xFF);
}
else {
/* If disk is not present set file system type to UNKNOWN */
strcpy(buf[count].f_fstypename, "UNKNOWN");
}

count++;
}
}
else {
/* If buf is NULL just try to get Disk Info from DosList entry and increase the count */
if (GetDiskInfoTags(
GDI_MsgPortInput, dosList->dol_Port,
GDI_InfoData, info,
TAG_END) != 0) {
count++;
}
}
}
}
FreeDosObject(DOS_INFODATA, info);

// Unlock the DOS list
UnLockDosList(lFlags);

return count;
}
6 changes: 4 additions & 2 deletions library/shared_library/clib4_vectors.h
Original file line number Diff line number Diff line change
Expand Up @@ -1172,14 +1172,16 @@ static void *clib4Vectors[] = {
(void *) (__get_tc_up), /* 4384 */
(void *) (__get_tc_bc), /* 4388 */

(void *) (0), /* 4392 */
(void *) (0), /* 4392 - unused */

(void *) (sigsuspend), /* 4396 */
(void *) (spawnve), /* 4400 */
(void *) (sigpause), /* 4404 */
(void *) (sigwait), /* 4408 */
(void *) (sigwaitinfo), /* 4412 */
(void *) (sigtimedwait), /* 4416 */


(void *) (getvfsstat), /* 4420 */

(void *)-1
};
2 changes: 2 additions & 0 deletions library/shared_library/interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -1351,6 +1351,8 @@ struct Clib4IFace {
int (* sigwait) (const sigset_t *set, int *sig); /* 4408 */
int (* sigwaitinfo) (const sigset_t *set, siginfo_t *info); /* 4412 */
int (* sigtimedwait) (const sigset_t *set, siginfo_t *info, const struct timespec *timeout); /* 4416 */

int (* getvfsstat) (struct statvfs *buf, size_t bufsize, int flags); /* 4420 */
};

#ifdef __PIC__
Expand Down
2 changes: 2 additions & 0 deletions library/shared_library/stubs_getvfsstat.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#include "stubs_common.h"
Clib4Call(getvfsstat, 4420);
Empty file added test_programs/misc/getvfsstat.c
Empty file.