Fix all the missing comments.

This commit is contained in:
Enrico Fraccaroli
2022-01-03 22:25:21 +01:00
parent 181d1d69cb
commit 2461d82431
59 changed files with 826 additions and 601 deletions
+2 -1
View File
@@ -35,7 +35,8 @@ void dbg_printf(const char *file, const char *fun, int line, const char *format,
const char *to_human_size(unsigned long bytes);
/// @brief Transforms the given value to a binary string.
/// @param value The decimal value.
/// @param value to print.
/// @param length of the binary output.
/// @return String representing the binary value.
const char *dec_to_binary(unsigned long value, unsigned length);
+51 -54
View File
@@ -10,66 +10,63 @@
/// Maximum number of users per group
#define MAX_MEMBERS_PER_GROUP 64
///@brief Contains user group informations
typedef struct group{
/// @brief Contains user group informations.
typedef struct group {
/// The name of the group.
char *gr_name;
/// Encrypted password.
char *gr_passwd;
/// Group ID.
gid_t gr_gid;
/// List of group members.
char *gr_mem[MAX_MEMBERS_PER_GROUP + 1];
} group_t;
char* gr_name; // the name of the group
gid_t gr_gid; // numerical group ID
char* gr_passwd; // password
/// @brief Provides access to the group database entry for `uid`.
/// @param gid The gid to search inside the database.
/// @return A pointer to the structure containing the database entry.
group_t *getgrgid(gid_t gid);
//pointer to a null-terminated array of character pointers to member names
char* gr_mem[MAX_MEMBERS_PER_GROUP + 1];
} group;
/// @brief Provides access to the group database entry for `name`.
/// @param name The name to search inside the database.
/// @return A pointer to the structure containing the database entry.
group_t *getgrnam(const char *name);
///@brief Provides access to the group database entry for `uid`.
///@param gid The gid to search inside the database.
///@return A pointer to the structure containing the database entry.
struct group* getgrgid(gid_t gid);
/// @brief Provides the same information as getgrgid but it stores the results
/// inside group, and the string information are store store inside `buf`.
/// @param gid The uid to search inside the database.
/// @param group The structure containing pointers to the entry fields.
/// @param buf The buffer where the strings should be stored.
/// @param buflen The lenght of the buffer.
/// @param result A pointer to the result or NULL is stored here.
/// @return If the entry was found returns zero and set *result to group, if the
/// entry was not found returns zero and set *result to NULL, on failure returns
/// a number and sets and set *result to NULL.
int getgrgid_r(gid_t gid, group_t *group, char *buf, size_t buflen, group_t **result);
///@brief Provides access to the group database entry for `name`.
///@param name The name to search inside the database.
///@return A pointer to the structure containing the database entry.
struct group* getgrnam(const char* name);
/// @brief Provides the same information as getgrnam but it stores the results
///inside group, and the string information are store store inside `buf`.
/// @param name The name to search inside the database.
/// @param group The structure containing pointers to the entry fields.
/// @param buf The buffer where the strings should be stored.
/// @param buflen The lenght of the buffer.
/// @param result A pointer to the result or NULL is stored here.
/// @return If the entry was found returns zero and set *result to group, if the
/// entry was not found returns zero and set *result to NULL, on failure returns
/// a number and sets and set *result to NULL.
int getgrnam_r(const char *name, group_t *group, char *buf, size_t buflen, group_t **result);
///@brief Provides the same information as getgrgid but it stores the
/// results inside group, and the string information are store store
/// inside `buf`.
///@param gid The uid to search inside the database.
///@param group The structure containing pointers to the entry fields.
///@param buf The buffer where the strings should be stored.
///@param buflen The lenght of the buffer.
///@param result A pointer to the result or NULL is stored here.
///@return If the entry was found returns zero and set *result to group,
/// if the entry was not found returns zero and set *result to NULL,
/// on failure returns a number and sets and set *result to NULL.
int getgrgid_r(gid_t gid, struct group* group, char* buf, size_t buflen, struct group ** result);
/// @brief Returns a pointer to a structure containing the broken-out fields of
/// an entry in the group database.
/// @return pointer to the group entry.
/// @details When first called returns a pointer to a group structure containing
/// the first entry in the group database. Thereafter, it returns a pointer to a
/// group structure containing the next group structure in the group database,
/// so successive calls may be used to search the entire database.
group_t *getgrent(void);
///@brief Provides the same information as getgrnam but it stores the
/// results inside group, and the string information are store store
/// inside `buf`.
///@param name The name to search inside the database.
///@param group The structure containing pointers to the entry fields.
///@param buf The buffer where the strings should be stored.
///@param buflen The lenght of the buffer.
///@param result A pointer to the result or NULL is stored here.
///@return If the entry was found returns zero and set *result to group,
/// if the entry was not found returns zero and set *result to NULL,
/// on failure returns a number and sets and set *result to NULL.
int getgrnam_r(const char* name, struct group* group, char* buf, size_t buflen, struct group** result);
///@brief Returns a pointer to a structure containing the broken-out
/// fields of an entry in the group database.
/// When first called returns a pointer to a group structure
/// containing the first entry in the group database.
/// Thereafter, it returns a pointer to a group structure
/// containing the next group structure in the group database,
/// so successive calls may be used to search the entire database.
struct group* getgrent(void);
///@brief Rewinds the group database to allow repeated searches.
/// @brief Rewinds the group database to allow repeated searches.
void endgrent(void);
///@brief May be called to close the group database when processing is complete.
/// @brief May be called to close the group database when processing is complete.
void setgrent(void);
+66 -10
View File
@@ -17,15 +17,15 @@ typedef unsigned int msgqnum_t;
typedef unsigned int msglen_t;
/// @brief Buffer to use with the message queue IPC.
struct msgbuf {
typedef struct msgbuf {
/// Type of the message.
long mtype;
/// Text of the message.
char mtext[1];
};
} msgbuf_t;
/// @brief Message queue data structure.
struct msqid_ds {
typedef struct msqid_ds {
/// Ownership and permissions.
struct ipc_perm msg_perm;
/// Time of last msgsnd(2).
@@ -44,26 +44,82 @@ struct msqid_ds {
pid_t msg_lspid;
/// PID of last msgrcv(2).
pid_t msg_lrpid;
};
} msqid_ds_t;
#ifdef __KERNEL__
/// @brief Get a System V message queue identifier.
/// @param key can be used either to obtain the identifier of a previously
/// created message queue, or to create a new set.
/// @param msgflg controls the behaviour of the function.
/// @return the message queue identifier, -1 on failure, and errno is set to
/// indicate the error.
long sys_msgget(key_t key, int msgflg);
long sys_msgsnd(int msqid, struct msgbuf *msgp, size_t msgsz, int msgflg);
/// @brief Used to send messages.
/// @param msqid the message queue identifier.
/// @param msgp points to a used-defined msgbuf.
/// @param msgsz specifies the size in bytes of mtext.
/// @param msgflg specifies the action to be taken in case of specific events.
/// @return 0 on success, -1 on failure and errno is set to indicate the error.
long sys_msgsnd(int msqid, msgbuf_t *msgp, size_t msgsz, int msgflg);
long sys_msgrcv(int msqid, struct msgbuf *msgp, size_t msgsz, long msgtyp, int msgflg);
/// @brief Used to receive messages.
/// @param msqid the message queue identifier.
/// @param msgp points to a used-defined msgbuf.
/// @param msgsz specifies the size in bytes of mtext.
/// @param msgtyp specifies the type of message requested, as follows:
/// - msgtyp == 0: the first message on the queue is received.
/// - msgtyp > 0: the first message of type, msgtyp, is received.
/// - msgtyp < 0: the first message of the lowest type that is less than or
/// equal to the absolute value of msgtyp is received.
/// @param msgflg specifies the action to be taken in case of specific events.
/// @return 0 on success, -1 on failure and errno is set to indicate the error.
long sys_msgrcv(int msqid, msgbuf_t *msgp, size_t msgsz, long msgtyp, int msgflg);
long sys_msgctl(int msqid, int cmd, struct msqid_ds *buf);
/// @brief Message queue control operations.
/// @param msqid the message queue identifier.
/// @param cmd The command to perform.
/// @param buf used with IPC_STAT and IPC_SET.
/// @return 0 on success, -1 on failure and errno is set to indicate the error.
long sys_msgctl(int msqid, int cmd, msqid_ds_t *buf);
#else
/// @brief Get a System V message queue identifier.
/// @param key can be used either to obtain the identifier of a previously
/// created message queue, or to create a new set.
/// @param msgflg controls the behaviour of the function.
/// @return the message queue identifier, -1 on failure, and errno is set to
/// indicate the error.
long msgget(key_t key, int msgflg);
long msgsnd(int msqid, struct msgbuf *msgp, size_t msgsz, int msgflg);
/// @brief Used to send messages.
/// @param msqid the message queue identifier.
/// @param msgp points to a used-defined msgbuf.
/// @param msgsz specifies the size in bytes of mtext.
/// @param msgflg specifies the action to be taken in case of specific events.
/// @return 0 on success, -1 on failure and errno is set to indicate the error.
long msgsnd(int msqid, msgbuf_t *msgp, size_t msgsz, int msgflg);
long msgrcv(int msqid, struct msgbuf *msgp, size_t msgsz, long msgtyp, int msgflg);
/// @brief Used to receive messages.
/// @param msqid the message queue identifier.
/// @param msgp points to a used-defined msgbuf.
/// @param msgsz specifies the size in bytes of mtext.
/// @param msgtyp specifies the type of message requested, as follows:
/// - msgtyp == 0: the first message on the queue is received.
/// - msgtyp > 0: the first message of type, msgtyp, is received.
/// - msgtyp < 0: the first message of the lowest type that is less than or
/// equal to the absolute value of msgtyp is received.
/// @param msgflg specifies the action to be taken in case of specific events.
/// @return 0 on success, -1 on failure and errno is set to indicate the error.
long msgrcv(int msqid, msgbuf_t *msgp, size_t msgsz, long msgtyp, int msgflg);
long msgctl(int msqid, int cmd, struct msqid_ds *buf);
/// @brief Message queue control operations.
/// @param msqid the message queue identifier.
/// @param cmd The command to perform.
/// @param buf used with IPC_STAT and IPC_SET.
/// @return 0 on success, -1 on failure and errno is set to indicate the error.
long msgctl(int msqid, int cmd, msqid_ds_t *buf);
#endif
+36
View File
@@ -22,18 +22,54 @@ struct sembuf {
#ifdef __KERNEL__
/// @brief Get a System V semaphore set identifier.
/// @param key can be used either to obtain the identifier of a previously
/// created semaphore set, or to create a new set.
/// @param nsems number of semaphores.
/// @param semflg controls the behaviour of the function.
/// @return the semaphore set identifier, -1 on failure, and errno is set to
/// indicate the error.
long sys_semget(key_t key, int nsems, int semflg);
/// @brief Performs operations on selected semaphores in the set.
/// @param semid the semaphore set identifier.
/// @param sops specifies operations to be performed on single semaphores.
/// @param nsops number of operations.
/// @return 0 on success, -1 on failure and errno is set to indicate the error.
long sys_semop(int semid, struct sembuf *sops, unsigned nsops);
/// @brief Performs control operations on a semaphore set.
/// @param semid the semaphore set identifier.
/// @param semnum the n-th semaphore of the set on which we perform the operations.
/// @param cmd the command to perform.
/// @param arg
/// @return 0 on success, -1 on failure and errno is set to indicate the error.
long sys_semctl(int semid, int semnum, int cmd, unsigned long arg);
#else
/// @brief Get a System V semaphore set identifier.
/// @param key can be used either to obtain the identifier of a previously
/// created semaphore set, or to create a new set.
/// @param nsems number of semaphores.
/// @param semflg controls the behaviour of the function.
/// @return the semaphore set identifier, -1 on failure, and errno is set to
/// indicate the error.
long semget(key_t key, int nsems, int semflg);
/// @brief Performs operations on selected semaphores in the set.
/// @param semid the semaphore set identifier.
/// @param sops specifies operations to be performed on single semaphores.
/// @param nsops number of operations.
/// @return 0 on success, -1 on failure and errno is set to indicate the error.
long semop(int semid, struct sembuf *sops, unsigned nsops);
/// @brief Performs control operations on a semaphore set.
/// @param semid the semaphore set identifier.
/// @param semnum the n-th semaphore of the set on which we perform the operations.
/// @param cmd the command to perform.
/// @param arg
/// @return 0 on success, -1 on failure and errno is set to indicate the error.
long semctl(int semid, int semnum, int cmd, unsigned long arg);
#endif
+56 -6
View File
@@ -135,22 +135,72 @@ struct shmid_ds *find_shm_fromvaddr(void *shmvaddr);
#ifdef __KERNEL__
long sys_shmat(int shmid, char *shmaddr, int shmflg);
/// @brief Get a System V shared memory identifier.
/// @param key can be used either to obtain the identifier of a previously
/// created shared memory, or to create a new one.
/// @param size of the shared memory, rounded up to a multiple of PAGE_SIZE.
/// @param flag controls the behaviour of the function.
/// @return the shared memory identifier, -1 on failure, and errno is set to
/// indicate the error.
long sys_shmget(key_t key, size_t size, int flag);
long sys_shmdt(char *shmaddr);
/// @brief Attaches the shared memory segment identified by shmid to the address
/// space of the calling process.
/// @param shmid the shared memory identifier.
/// @param shmaddr the attaching address.
/// @param shmflg controls the behaviour of the function.
/// @return returns the address of the attached shared memory segment; on error
/// (void *) -1 is returned, and errno is set to indicate the error.
void * sys_shmat(int shmid, const void *shmaddr, int shmflg);
/// @brief Detaches the shared memory segment located at the address specified
/// by shmaddr from the address space of the calling process
/// @param shmaddr the address of the shared memory segment.
/// @return 0 on success, -1 on failure and errno is set to indicate the error.
long sys_shmdt(const void *shmaddr);
/// @brief Performs the control operation specified by cmd on the shared memory
/// segment whose identifier is given in shmid.
/// @param shmid the shared memory identifier.
/// @param cmd the command to perform.
/// @param buf is a pointer to a shmid_ds structure.
/// @return a non-negative value basedon on the requested operation, -1 on
/// failure and errno is set to indicate the error.
long sys_shmctl(int shmid, int cmd, struct shmid_ds *buf);
#else
long shmat(int shmid, char *shmaddr, int shmflg);
/// @brief Get a System V shared memory identifier.
/// @param key can be used either to obtain the identifier of a previously
/// created shared memory, or to create a new one.
/// @param size of the shared memory, rounded up to a multiple of PAGE_SIZE.
/// @param flag controls the behaviour of the function.
/// @return the shared memory identifier, -1 on failure, and errno is set to
/// indicate the error.
long shmget(key_t key, size_t size, int flag);
long shmdt(char *shmaddr);
/// @brief Attaches the shared memory segment identified by shmid to the address
/// space of the calling process.
/// @param shmid the shared memory identifier.
/// @param shmaddr the attaching address.
/// @param shmflg controls the behaviour of the function.
/// @return returns the address of the attached shared memory segment; on error
/// (void *) -1 is returned, and errno is set to indicate the error.
void * shmat(int shmid, const void *shmaddr, int shmflg);
/// @brief Detaches the shared memory segment located at the address specified
/// by shmaddr from the address space of the calling process
/// @param shmaddr the address of the shared memory segment.
/// @return 0 on success, -1 on failure and errno is set to indicate the error.
long shmdt(const void *shmaddr);
/// @brief Performs the control operation specified by cmd on the shared memory
/// segment whose identifier is given in shmid.
/// @param shmid the shared memory identifier.
/// @param cmd the command to perform.
/// @param buf is a pointer to a shmid_ds structure.
/// @return a non-negative value basedon on the requested operation, -1 on
/// failure and errno is set to indicate the error.
long shmctl(int shmid, int cmd, struct shmid_ds *buf);
#endif
+15
View File
@@ -21,8 +21,23 @@ typedef struct sched_param_t {
bool_t is_periodic;
} sched_param_t;
/// @brief Sets scheduling parameters.
/// @param pid pid of the process we want to change the parameters. If zero,
/// then the parameters of the calling process are set.
/// @param param The interpretation of the argument param depends on the
/// scheduling policy of the thread identified by pid.
/// @return 0 on success, -1 on failure and errno is set to indicate the error.
int sched_setparam(pid_t pid, const sched_param_t *param);
/// @brief Gets scheduling parameters.
/// @param pid pid of the process we want to retrieve the parameters. If zero,
/// then the parameters of the calling process are returned.
/// @param param The interpretation of the argument param depends on the
/// scheduling policy of the thread identified by pid.
/// @return 0 on success, -1 on failure and errno is set to indicate the error.
int sched_getparam(pid_t pid, sched_param_t *param);
/// @brief Placed at the end of an infinite while loop, stops the process until,
/// its next period starts. The calling process must be a periodic one.
/// @return 0 on success, -1 on failure and errno is set to indicate the error.
int waitperiod();
+7
View File
@@ -222,11 +222,13 @@ char *getcwd(char *buf, size_t size);
/// @brief Changes the current working directory to the given path.
/// @param path The new current working directory.
/// @return 0 on success, -1 on failure and errno is set to indicate the error.
int chdir(char const *path);
/// @brief Is identical to chdir(), the only difference is that the
/// directory is given as an open file descriptor.
/// @param fd The file descriptor of the open directory.
/// @return 0 on success, -1 on failure and errno is set to indicate the error.
int fchdir(int fd);
/// Provide access to the directory entries.
@@ -239,4 +241,9 @@ int fchdir(int fd);
int getdents(int fd, dirent_t *dirp, unsigned int count);
/// @brief Send signal to calling thread after desired seconds.
/// @param seconds the amount of seconds.
/// @return If there is a previous alarm() request with time remaining, alarm()
/// shall return a non-zero value that is the number of seconds until the
/// previous request would have generated a SIGALRM signal. Otherwise, alarm()
/// shall return 0.
int alarm(int seconds);
+27 -12
View File
@@ -7,10 +7,16 @@
#include "stddef.h"
/// Domains of interval timers
#define ITIMER_REAL 0
/// @brief This timer counts down in real (i.e., wall clock) time. At each
/// expiration, a SIGALRM signal is generated.
#define ITIMER_REAL 0
/// @brief This timer counts down against the user-mode CPU time consumed by the
/// process. At each expiration, a SIGVTALRM signal is generated.
#define ITIMER_VIRTUAL 1
#define ITIMER_PROF 2
/// @brief This timer counts down against the total (i.e., both user and system)
/// CPU time consumed by the process. At each expiration, a SIGPROF signal is
/// generated.
#define ITIMER_PROF 2
/// Used to store time values.
typedef unsigned int time_t;
@@ -37,16 +43,16 @@ typedef struct tm_t {
int tm_isdst;
} tm_t;
/// Rappresents time
/// Rappresents time.
typedef struct _timeval {
time_t tv_sec; /* seconds */
time_t tv_usec; /* microseconds */
time_t tv_sec; ///< Seconds.
time_t tv_usec; ///< Microseconds.
} timeval;
/// Rappresents a time interval
/// Rappresents a time interval.
typedef struct _itimerval {
timeval it_interval; /* next value */
timeval it_value; /* current value */
timeval it_interval; ///< Next value.
timeval it_value; ///< Current value.
} itimerval;
/// @brief Specify intervals of time with nanosecond precision.
@@ -101,9 +107,18 @@ int nanosleep(const timespec *req, timespec *rem);
/// left to sleep, if the call was interrupted by a signal handler.
unsigned int sleep(unsigned int seconds);
/// @brief Fills the structure pointed to by curr_value with the current setting for the timer specified by which.
/// @brief Fills the structure pointed to by curr_value with the current setting
/// for the timer specified by which.
/// @param which which timer.
/// @param curr_value where we place the timer value.
/// @return 0 on success, -1 on failure and errno is set to indicate the error.
int getitimer(int which, itimerval *curr_value);
/// @brief The system provides each process with three interval timers, each decrementing in a distinct time domain.
/// When any timer expires, a signal is sent to the process, and the timer (potentially) restarts.
/// @brief The system provides each process with three interval timers, each
/// decrementing in a distinct time domain. When any timer expires, a signal is
/// sent to the process, and the timer (potentially) restarts.
/// @param which which timer.
/// @param new_value the new value for the timer.
/// @param old_value output variable where the function places the previous value.
/// @return 0 on success, -1 on failure and errno is set to indicate the error.
int setitimer(int which, const itimerval *new_value, itimerval *old_value);
+32 -35
View File
@@ -3,7 +3,7 @@
/// @copyright (c) 2014-2021 This file is distributed under the MIT License.
/// See LICENSE.md for details.
#include "grp.h"
#include "grp.h"
#include "sys/unistd.h"
#include "sys/errno.h"
#include "assert.h"
@@ -12,8 +12,9 @@
#include "debug.h"
#include "fcntl.h"
static int __fd = -1;
static inline void __parse_line(struct group* grp, char *buf)
static inline void __parse_line(group_t *grp, char *buf)
{
assert(grp && "Received null grp!");
char *token;
@@ -28,7 +29,7 @@ static inline void __parse_line(struct group* grp, char *buf)
grp->gr_gid = atoi(token);
size_t found_users = 0;
while((token = strtok(NULL, ",\n\0")) != NULL && found_users < MAX_MEMBERS_PER_GROUP) {
while ((token = strtok(NULL, ",\n\0")) != NULL && found_users < MAX_MEMBERS_PER_GROUP) {
grp->gr_mem[found_users] = token;
found_users += 1;
}
@@ -89,45 +90,44 @@ static inline char *__search_entry(int fd, char *buf, int buflen, const char *na
return NULL;
}
struct group* getgrgid(gid_t gid) {
static group grp;
group_t *getgrgid(gid_t gid)
{
static group_t grp;
static char buffer[BUFSIZ];
group *result;
group_t *result;
if (!getgrgid_r(gid, &grp, buffer, BUFSIZ, &result))
return NULL;
return &grp;
}
struct group *getgrnam(const char* name) {
group_t *getgrnam(const char *name)
{
if (name == NULL)
return NULL;
static group grp;
static group_t grp;
static char buffer[BUFSIZ];
group *result;
group_t *result;
if (!getgrnam_r(name, &grp, buffer, BUFSIZ, &result))
return NULL;
return &grp;
}
int getgrgid_r(gid_t gid, struct group* group, char* buf, size_t buflen, struct group ** result) {
int getgrgid_r(gid_t gid, group_t *group, char *buf, size_t buflen, group_t **result)
{
int fd = open("/etc/group", O_RDONLY, 0);
if (fd == -1) {
errno = ENOENT;
*result = NULL;
return 0;
}
char *entry = __search_entry(fd, buf, buflen, NULL, gid);
if (entry != NULL) {
// Close the file.
close(fd);
// Parse the line.
@@ -142,18 +142,17 @@ int getgrgid_r(gid_t gid, struct group* group, char* buf, size_t buflen, struct
return 0;
}
int getgrnam_r(const char* name, struct group* group, char* buf, size_t buflen, struct group** result) {
int getgrnam_r(const char *name, group_t *group, char *buf, size_t buflen, group_t **result)
{
int fd = open("/etc/group", O_RDONLY, 0);
if (fd == -1) {
errno = ENOENT;
*result = NULL;
return 0;
}
char *entry = __search_entry(fd, buf, buflen, name, 0);
if (entry != NULL) {
// Close the file.
close(fd);
// Parse the line.
@@ -168,15 +167,14 @@ int getgrnam_r(const char* name, struct group* group, char* buf, size_t buflen,
return 0;
}
static int fd = -1;
struct group* getgrent(void) {
group_t *getgrent(void)
{
static group_t result;
static group result;
if (fd == -1) {
if (__fd == -1) {
//pr_debug("Opening group file\n");
fd = open("/etc/group", O_RDONLY, 0);
if (fd == -1) {
__fd = open("/etc/group", O_RDONLY, 0);
if (__fd == -1) {
errno = ENOENT;
return 0;
}
@@ -187,8 +185,7 @@ struct group* getgrent(void) {
int pos = 0;
static char buffer[BUFSIZ];
while ((ret = read(fd, &c, 1U))) {
while ((ret = read(__fd, &c, 1U))) {
// Skip carriage return.
if (c == '\r')
continue;
@@ -223,15 +220,15 @@ struct group* getgrent(void) {
return NULL;
}
void endgrent(void) {
void endgrent(void)
{
//pr_debug("Closing group file\n");
close(fd);
fd = -1;
close(__fd);
__fd = -1;
}
void setgrent(void) {
void setgrent(void)
{
//pr_debug("Resetting pointer to beginning of group file\n");
lseek(fd, 0, SEEK_SET);
lseek(__fd, 0, SEEK_SET);
}
+2 -2
View File
@@ -11,11 +11,11 @@
#include "ipc/shm.h"
#include "ipc/msg.h"
_syscall3(long, shmat, int, shmid, char *, shmaddr, int, shmflg)
_syscall3(void *, shmat, int, shmid, const void *, shmaddr, int, shmflg)
_syscall3(long, shmget, key_t, key, size_t, size, int, flag)
_syscall1(long, shmdt, char *, shmaddr)
_syscall1(long, shmdt, const void *, shmaddr)
_syscall3(long, shmctl, int, shmid, int, cmd, struct shmid_ds *, buf)
+5
View File
@@ -46,6 +46,11 @@ static inline void __parse_line(passwd_t *pwd, char *buf)
}
}
/// @brief Reads a line from the file.
/// @param fd the file descriptor.
/// @param buffer the buffer where we place the line.
/// @param buflen the length of the buffer.
/// @return the amount we read.
ssize_t __readline(int fd, char *buffer, size_t buflen)
{
memset(buffer, 0, buflen);
+2
View File
@@ -18,6 +18,7 @@ static const char *months[] = {
"July", "August", "September", "October", "November", "December"
};
/// @brief Time function.
_syscall1(time_t, time, time_t *, t)
time_t difftime(time_t time1, time_t time2)
@@ -377,6 +378,7 @@ size_t strftime(char *str, size_t maxsize, const char *format, const tm_t *timep
return ret;
}
/// @brief nanosleep function.
_syscall2(int, nanosleep, const timespec *, req, timespec *, rem)
unsigned int sleep(unsigned int seconds)
+5 -1
View File
@@ -59,7 +59,11 @@ static inline int __find_in_path(const char *file, char *buf, size_t buf_len)
return -1;
}
_syscall3(int, execve, const char *, path, char *const *, argv, char *const *, envp)
/// @brief Replaces the current process image with a new process
/// image (argument vector), allows the caller to specify
/// the environment of the executed program via `envp`.
/// @return Returns -1 only if an error has occurred, and sets errno.
_syscall3(int, execve, const char *, path, char *const *, argv, char *const *, envp);
int execv(const char *path, char *const argv[])
{