1
0
mirror of https://github.com/deadw00d/AROS.git synced 2025-12-06 05:00:25 +00:00

pack necessary structures to ensure correct alignment of elements.

This commit is contained in:
Kalamatee
2025-10-06 17:22:41 +01:00
committed by deadwood
parent 048c1ff248
commit 6d81c8ad7a
6 changed files with 38 additions and 35 deletions

View File

@ -102,26 +102,24 @@ void GetByNameCmd(struct NetInfoDevice *nid, struct NetInfoReq *req, struct NetI
const UBYTE *name = (const UBYTE *)
((struct NetInfoEnt*)req->io_Data)->nie_name;
struct Ent *e;
LONG retval = NIERR_NOTFOUND;
D(bug("[NetInfo] %s()\n", __func__));
req->io_Error = NIERR_NOTFOUND;
e = InternalSetEnts(nid, nim);
D(bug("[NetInfo] %s: Ents @ 0x%p\n", __func__, e));
while (e = GetNextEnt(e)) {
if (strcmp(e->e_name, name) == 0) {
if (Method(copy_out, nim)(req, e)) {
retval = 0;
req->io_Error = 0;
} else {
retval = NIERR_TOOSMALL;
req->io_Error = NIERR_TOOSMALL;
}
break;
}
}
req->io_Error = retval;
InternalEndEnts(nid, nim);
TermIO(req);
}
@ -133,26 +131,27 @@ void GetByIDCmd(struct NetInfoDevice *nid, struct NetInfoReq *req, struct NetInf
{
struct Ent *e;
LONG id = ((struct NetInfoEnt*)req->io_Data)->nie_id;
BYTE retval = NIERR_NOTFOUND;
D(bug("[NetInfo] %s()\n", __func__));
D(bug("[NetInfo] %s: ID %ld\n", __func__, id));
req->io_Error = NIERR_NOTFOUND;
e = InternalSetEnts(nid, nim);
D(bug("[NetInfo] %s: Ents @ 0x%p\n", __func__, e));
while (e = GetNextEnt(e)) {
D(bug("[NetInfo] %s: ent id %ld\n", __func__, e->e_id));
if (e->e_id == id) {
if (Method(copy_out, nim)(req, e)) {
retval = 0;
req->io_Error = 0;
} else {
retval = NIERR_TOOSMALL;
req->io_Error = NIERR_TOOSMALL;
}
break;
}
}
req->io_Error = retval;
InternalEndEnts(nid, nim);
TermIO(req);
}
@ -179,24 +178,21 @@ void ReadCmd(struct NetInfoDevice *nid, struct NetInfoReq *req, struct NetInfoMa
{
struct NetInfoPointer *p = (struct NetInfoPointer *)req->io_Unit;
struct Ent *e;
BYTE retval;
D(bug("[NetInfo] %s()\n", __func__));
req->io_Error = NIERR_NOTFOUND;
InternalSetEnts(nid, nim);
e = p->nip_Ent;
if (p->nip_Ent && (p->nip_Ent = GetNextEnt(e))) {
if (Method(copy_out, nim)(req, p->nip_Ent)) {
retval = 0;
req->io_Error = 0;
} else {
retval = NIERR_TOOSMALL;
req->io_Error = NIERR_TOOSMALL;
}
} else {
retval = NIERR_NOTFOUND;
}
InternalEndEnts(nid, nim);
req->io_Error = retval;
TermIO(req);
}

View File

@ -26,13 +26,13 @@ struct Ent {
UBYTE *e_name;
LONG e_pwd;
LONG e_id;
};
} __packed;
struct PasswdEnt {
struct Node pe_node;
UWORD pe_tlen;
struct NetInfoPasswd pe_passwd[1];
};
} __packed;
/* we may have an extended version of passwd */
#define PASSWDFIELDS 7
@ -42,7 +42,7 @@ struct GroupEnt {
UWORD ge_tlen;
struct NetInfoGroup ge_group[1];
ULONG ge_nmembers; /* actually, # of members + 1 */
};
} __packed;
/*
* Entry Node Type
@ -82,7 +82,7 @@ void InternalEndEnts(struct NetInfoDevice *, struct NetInfoMap *nim);
struct Ent *GetNextEnt(struct Ent *e);
/* Utility */
static __inline char *stpcopy(char *to, const char *from)
static inline char *stpcopy(char *to, const char *from)
{
while (*to++ = *from++)
;

View File

@ -56,7 +56,7 @@ struct NetInfoPasswd
UBYTE *pw_gecos; /* Real name etc */
UBYTE *pw_dir; /* Home directory */
UBYTE *pw_shell; /* Shell */
};
} __packed;
/* The group structure */
struct NetInfoGroup
@ -65,6 +65,6 @@ struct NetInfoGroup
UBYTE *gr_passwd; /* Password. */
LONG gr_gid; /* Group ID. */
UBYTE **gr_mem; /* Member list. */
};
} __packed;
#endif /* DEVICES_NETINFO_H */

View File

@ -300,7 +300,7 @@ static struct Ent *ParsePasswd(struct NetInfoDevice *nid, register UBYTE *p)
to = stpcopy(pe->pe_passwd->pw_dir = to, field[5]);
to = stpcopy(pe->pe_passwd->pw_shell = to, field[6]);
D(bug("[NetInfo] %s: <%d:%d> '%s'\n", __func__, pe->pe_passwd->pw_uid, pe->pe_passwd->pw_gid, pe->pe_passwd->pw_name));
D(bug("[NetInfo] %s: <%ld:%ld> '%s'\n", __func__, pe->pe_passwd->pw_uid, pe->pe_passwd->pw_gid, pe->pe_passwd->pw_name));
#if defined(DEBUG)
assert(to == pe->pe_passwd->pw_name + txtlen);

View File

@ -147,7 +147,9 @@ AROS_LH1(struct group *, getgrnam,
gr->gr_name = (char *)name;
nreq->io_Command = NI_GETBYNAME;
D(bug("[UserGroup] %s: sending NI_GETBYNAME to netinfo.device/%d...\n", __func__, NETINFO_GROUP_UNIT));
if (ug_DoIO(nreq) != 0) {
if (ug_DoIO(nreq) == 0) {
D(bug("[UserGroup] %s: -> '%s'\n", __func__, gr->gr_gid));
} else {
gr = NULL;
SetDeviceErr((struct Library *)UserGroupBase);
}
@ -179,7 +181,9 @@ AROS_LH1(struct group *, getgrgid,
gr->gr_gid = gid;
nreq->io_Command = NI_GETBYID;
D(bug("[UserGroup] %s: sending NI_GETBYID to netinfo.device/%d...\n", __func__, NETINFO_GROUP_UNIT));
if (ug_DoIO(nreq) != 0) {
if (ug_DoIO(nreq) == 0) {
D(bug("[UserGroup] %s: -> '%s'\n", __func__, gr->gr_name));
} else {
gr = NULL;
SetDeviceErr((struct Library *)UserGroupBase);
}
@ -189,6 +193,7 @@ AROS_LH1(struct group *, getgrgid,
ReleaseSemaphore(&UserGroupBase->ni_lock);
D(bug("[UserGroup] %s: returning 0x%p\n", __func__, gr));
return gr;
AROS_LIBFUNC_EXIT
@ -251,6 +256,7 @@ AROS_LH0(struct group *, getgrent,
ReleaseSemaphore(&UserGroupBase->ni_lock);
D(bug("[UserGroup] %s: returning 0x%p\n", __func__, gr));
return gr;
AROS_LIBFUNC_EXIT

View File

@ -138,7 +138,9 @@ AROS_LH1(struct passwd *, getpwnam,
pw->pw_name = (char *)name;
nreq->io_Command = NI_GETBYNAME;
D(bug("[UserGroup] %s: sending NI_GETBYNAME to netinfo.device/%d...\n", __func__, NETINFO_PASSWD_UNIT));
if (ug_DoIO(nreq) != 0) {
if (ug_DoIO(nreq) == 0) {
D(bug("[UserGroup] %s: -> %d\n", __func__, pw->pw_uid));
} else {
pw = NULL;
SetDeviceErr((struct Library *)UserGroupBase);
}
@ -166,13 +168,13 @@ AROS_LH1(struct passwd *, getpwuid,
ObtainSemaphore(&UserGroupBase->ni_lock);
if (nreq = ug_OpenUnit((struct Library *)UserGroupBase, NETINFO_PASSWD_UNIT)) {
pw = (struct passwd *)nreq->io_Data;
pw = (struct passwd *)nreq->io_Data;
pw->pw_uid = uid;
nreq->io_Command = NI_GETBYID;
D(bug("[UserGroup] %s: sending NI_GETBYID to netinfo.device/%d...\n", __func__, NETINFO_PASSWD_UNIT));
if (ug_DoIO(nreq) != 0) {
if (ug_DoIO(nreq) == 0) {
D(bug("[UserGroup] %s: -> '%s'\n", __func__, pw->pw_name));
} else {
pw = NULL;
SetDeviceErr((struct Library *)UserGroupBase);
}
@ -183,6 +185,7 @@ AROS_LH1(struct passwd *, getpwuid,
ReleaseSemaphore(&UserGroupBase->ni_lock);
D(bug("[UserGroup] %s: returning 0x%p\n", __func__, pw));
return pw;
AROS_LIBFUNC_EXIT
@ -201,9 +204,7 @@ AROS_LH0(void, setpwent,
if (nreq = ug_OpenUnit((struct Library *)UserGroupBase, NETINFO_PASSWD_UNIT)) {
nreq->io_Command = CMD_RESET;
D(bug("[UserGroup] %s: sending CMD_RESET to netinfo.device/%d...\n", __func__, NETINFO_PASSWD_UNIT));
ug_DoIO(nreq);
UserGroupBase->setent_done = 1;
} else {
@ -234,7 +235,6 @@ AROS_LH0(struct passwd *, getpwent,
ug_DoIO(nreq);
UserGroupBase->setent_done = 1;
}
D(bug("[UserGroup] %s: sending CMD_READ to netinfo.device/%d...\n", __func__, NETINFO_PASSWD_UNIT));
nreq->io_Command = CMD_READ;
if (ug_DoIO(nreq) == 0) {
@ -248,6 +248,7 @@ AROS_LH0(struct passwd *, getpwent,
ReleaseSemaphore(&UserGroupBase->ni_lock);
D(bug("[UserGroup] %s: returning 0x%p\n", __func__, pw));
return pw;
AROS_LIBFUNC_EXIT