Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
41 changes: 41 additions & 0 deletions developer/debug/test/dos/lockrelative.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
Copyright (C) 1995-2021, The AROS Development Team. All rights reserved.
*/

#include <stdio.h>
#include <proto/dos.h>

int main (int argc, char **argv) {
if (argc < 3) {
printf("usage: lockrelative <base> <file>\n");
return 1;
}

BPTR baselock = Lock(argv[1], ACCESS_READ);
if (baselock == BNULL) {
PrintFault(IoErr(), "lockrelative: base lock");
return 1;
}

BPTR filelock = LockRelative(baselock, argv[2], ACCESS_READ);
if (filelock == BNULL) {
PrintFault(IoErr(), "lockrelative: file lock");
UnLock(baselock);
return 1;
}

char path[256];
if (NameFromLock(filelock, path, sizeof(path)) == 0) {
PrintFault(IoErr(), "lockrelative: name from lock");
UnLock(filelock);
UnLock(baselock);
return 1;
}

printf("%s\n", path);

UnLock(filelock);
UnLock(baselock);
return 0;
}

1 change: 1 addition & 0 deletions developer/debug/test/dos/mmakefile.src
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ FILES := \
getenv \
inhibit \
isinteractive \
lockrelative \
match \
matchtest \
minicat \
Expand Down
19 changes: 1 addition & 18 deletions rom/dos/createdir.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,6 @@
Desc: Create a new directory.
*/

#include <aros/debug.h>
#include <exec/memory.h>
#include <proto/exec.h>
#include <utility/tagitem.h>
#include <dos/dos.h>
#include <proto/dos.h>
#include <proto/utility.h>
#include "dos_intern.h"

/*****************************************************************************
Expand Down Expand Up @@ -51,17 +44,7 @@
{
AROS_LIBFUNC_INIT

BPTR lock = BNULL;
struct PacketHelperStruct phs;

D(bug("[CreateDir] '%s'\n", name));

if (getpacketinfo(DOSBase, name, &phs)) {
lock = (BPTR)dopacket2(DOSBase, NULL, phs.port, ACTION_CREATE_DIR, phs.lock, phs.name);
freepacketinfo(DOSBase, &phs);
}

return lock;
return CreateDirRelative(BNULL, name);

AROS_LIBFUNC_EXIT
} /* CreateDir */
Expand Down
62 changes: 62 additions & 0 deletions rom/dos/createdirrelative.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
Copyright (C) 1995-2013, The AROS Development Team. All rights reserved.

Desc: Create a new directory.
*/

#include <aros/debug.h>
#include <exec/memory.h>
#include <proto/exec.h>
#include <utility/tagitem.h>
#include <dos/dos.h>
#include <proto/dos.h>
#include <proto/utility.h>
#include "dos_intern.h"

/*****************************************************************************

NAME */
#include <proto/dos.h>

AROS_LH2(BPTR, CreateDirRelative,

/* SYNOPSIS */
AROS_LHA(BPTR, lock, D1),
AROS_LHA(CONST_STRPTR, name, D2),

/* LOCATION */
struct DosLibrary *, DOSBase, 231, Dos)

/* FUNCTION
Creates a new directory under the given name. If all went well, an
exclusive lock on the new diretory is returned.

INPUTS
name - NUL terminated name.

RESULT
Exclusive lock to the new directory or 0 if it couldn't be created.
IoErr() gives additional information in that case.

NOTES
This call is AROS-specific.

*****************************************************************************/
{
AROS_LIBFUNC_INIT

BPTR lock = BNULL;
struct PacketHelperStruct phs;

D(bug("[CreateDirRelative] lock=0x%p '%s'\n", lock, name));

if (getpacketinfo(DOSBase, lock, name, &phs)) {
lock = (BPTR)dopacket2(DOSBase, NULL, phs.port, ACTION_CREATE_DIR, phs.lock, phs.name);
freepacketinfo(DOSBase, &phs);
}

return lock;

AROS_LIBFUNC_EXIT
} /* CreateDirRelative */

19 changes: 1 addition & 18 deletions rom/dos/deletefile.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,6 @@

Desc: Delete a file or directory.
*/
#include <aros/debug.h>
#include <exec/memory.h>
#include <proto/exec.h>
#include <utility/tagitem.h>
#include <dos/dos.h>
#include <proto/dos.h>
#include <proto/utility.h>
#include "dos_intern.h"

/*****************************************************************************
Expand Down Expand Up @@ -50,17 +43,7 @@
{
AROS_LIBFUNC_INIT

LONG status = 0;
struct PacketHelperStruct phs;

D(bug("[DeleteFile] '%s'\n", name));

if (getpacketinfo(DOSBase, name, &phs)) {
status = dopacket2(DOSBase, NULL, phs.port, ACTION_DELETE_OBJECT, phs.lock, phs.name);
freepacketinfo(DOSBase, &phs);
}

return status;
return DeleteFileRelative(BNULL, name);

AROS_LIBFUNC_EXIT
} /* DeleteFile */
60 changes: 60 additions & 0 deletions rom/dos/deletefilerelative.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
Copyright (C) 1995-2013, The AROS Development Team. All rights reserved.

Desc: Delete a file or directory.
*/
#include <aros/debug.h>
#include <exec/memory.h>
#include <proto/exec.h>
#include <utility/tagitem.h>
#include <dos/dos.h>
#include <proto/dos.h>
#include <proto/utility.h>
#include "dos_intern.h"

/*****************************************************************************

NAME */
#include <proto/dos.h>

AROS_LH2(BOOL, DeleteFileRelative,

/* SYNOPSIS */
AROS_LHA(BPTR, lock, D1),
AROS_LHA(CONST_STRPTR, name, D2),

/* LOCATION */
struct DosLibrary *, DOSBase, 232, Dos)

/* FUNCTION
Tries to delete a file or directory by a given name.
May fail if the file is in use or protected from deletion.

INPUTS
name - NUL terminated name.

RESULT
!= 0 if the file is gone, 0 if is still there.
IoErr() gives additional information in that case.

NOTES
This call is AROS-specific.

*****************************************************************************/
{
AROS_LIBFUNC_INIT

LONG status = 0;
struct PacketHelperStruct phs;

D(bug("[DeleteFileRelative] lock=0x%p '%s'\n", lock, name));

if (getpacketinfo(DOSBase, lock, name, &phs)) {
status = dopacket2(DOSBase, NULL, phs.port, ACTION_DELETE_OBJECT, phs.lock, phs.name);
freepacketinfo(DOSBase, &phs);
}

return status;

AROS_LIBFUNC_EXIT
} /* DeleteFileRelative */
13 changes: 13 additions & 0 deletions rom/dos/dos.conf
Original file line number Diff line number Diff line change
Expand Up @@ -255,4 +255,17 @@ LONG ScanVars(struct Hook * hook, ULONG flags, APTR userdata) (D1,D2,D3)
LONG GetSegListInfo(BPTR seglist, const struct TagItem *taglist) (D0, A0)
.skip 29
BOOL AssignAddToList(CONST_STRPTR name, BPTR lock, ULONG position) (D1, D2, D3)
# AROS-specific
BPTR LockRelative(BPTR lock, CONST_STRPTR name, LONG accessMode) (D1,D2,D3)
BPTR OpenRelative(BPTR lock, CONST_STRPTR name, LONG accessMode) (D1,D2,D3)
struct DevProc *GetDeviceProcRelative(BPTR lock, CONST_STRPTR name, struct DevProc *dp) (D1,D2,D3)
BOOL IsFileSystemRelative(BPTR lock, CONST_STRPTR devicename) (D1,D2)
BPTR CreateDirRelative(BPTR lock, CONST_STRPTR name) (D1,D2)
BOOL DeleteFileRelative(BPTR lock, CONST_STRPTR name) (D1,D2)
LONG SetCommentRelative(BPTR lock, CONST_STRPTR name, CONST_STRPTR comment) (D1,D2,D3)
BOOL SetFileDateRelative(BPTR lock, CONST_STRPTR name, const struct DateStamp *date) (D1,D2,D3)
BOOL SetOwnerRelative(BPTR lock, CONST_STRPTR name, ULONG owner_info) (D1,D2,D3)
LONG SetProtectionRelative(BPTR lock, CONST_STRPTR name, ULONG protect) (D1,D2,D3)
LONG MakeLinkRelative(BPTR lock, CONST_STRPTR name, SIPTR dest, LONG soft) (D1,D2,D3,D4)
LONG RenameRelative(BPTR oldLock, CONST_STRPTR oldName, BPTR newLock, CONST_STRPTR newName) (D1,D2,D3,D4)
##end functionlist
6 changes: 4 additions & 2 deletions rom/dos/dos_intern.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ struct vfp

/* Softlink handling */
STRPTR ResolveSoftlink(BPTR cur, struct DevProc *dvp, CONST_STRPTR name, struct DosLibrary *DOSBase);
LONG RootDir(struct DevProc *dvp, struct DosLibrary *DOSBase);

/* Packet I/O */
struct DosPacket *allocdospacket(void);
Expand Down Expand Up @@ -313,7 +312,7 @@ struct PacketHelperStruct
struct DevProc *dp;
};

BOOL getpacketinfo(struct DosLibrary *DOSBase, CONST_STRPTR, struct PacketHelperStruct*);
BOOL getpacketinfo(struct DosLibrary *DOSBase, BPTR, CONST_STRPTR, struct PacketHelperStruct*);
BOOL getdevpacketinfo(struct DosLibrary *DOSBase, CONST_STRPTR devname, CONST_STRPTR name, struct PacketHelperStruct *phs);
void freepacketinfo(struct DosLibrary *DOSBase, struct PacketHelperStruct*);

Expand All @@ -338,4 +337,7 @@ BPTR findseg_shell(BOOL isBoot, struct DosLibrary *DOSBase);
*/
BOOL pseudoLock(CONST_STRPTR name, LONG lockMode, BPTR *lock, LONG *ret, struct DosLibrary *DOSBase);

/* helper for recursively resolving softlinks */
STRPTR ResolveSoftlink(BPTR lock, struct DevProc *dvp, CONST_STRPTR name, struct DosLibrary *DOSBase);

#endif /* DOS_INTERN_H */
2 changes: 1 addition & 1 deletion rom/dos/errorreport.c
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@
case REPORT_INSERT:
if (arg1 == (IPTR)NULL)
return DOSTRUE;
if (!getpacketinfo(DOSBase, (STRPTR)arg1, &phs))
if (!getpacketinfo(DOSBase, BNULL, (STRPTR)arg1, &phs))
return DOSTRUE;
msgport = phs.port;
volname = (STRPTR) arg1;
Expand Down
19 changes: 0 additions & 19 deletions rom/dos/fs_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,25 +61,6 @@ LONG fs_Open(struct FileHandle *handle, struct MsgPort *port, BPTR lock, LONG mo
return status ? 0 : error;
}

LONG fs_ReadLink(BPTR parent, struct DevProc *dvp, CONST_STRPTR path, STRPTR buffer, ULONG size, struct DosLibrary *DOSBase)
{
struct MsgPort *port;

if (parent)
{
struct FileLock *fl = BADDR(parent);

port = fl->fl_Task;
}
else
{
port = dvp->dvp_Port;
parent = dvp->dvp_Lock;
}

return ReadLink(port, parent, path, buffer, size);
}

LONG fs_ChangeSignal(BPTR handle, struct Process *task, struct DosLibrary *DOSBase)
{
SIPTR error = 0;
Expand Down
1 change: 0 additions & 1 deletion rom/dos/fs_driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

LONG fs_LocateObject(BPTR *ret, struct MsgPort *port, BPTR parent, CONST_STRPTR name, LONG accessMode, struct DosLibrary *DOSBase);
LONG fs_Open(struct FileHandle *fh, struct MsgPort *port, BPTR lock, LONG accessMode, CONST_STRPTR name, struct DosLibrary *DOSBase);
LONG fs_ReadLink(BPTR parent, struct DevProc *dvp, CONST_STRPTR path, STRPTR buffer, ULONG size, struct DosLibrary *DOSBase);
LONG fs_ChangeSignal(BPTR handle, struct Process *task, struct DosLibrary *DOSBase);
LONG fs_AddNotify(struct NotifyRequest *notify, struct DevProc *dvp, BPTR lock, struct DosLibrary *DOSBase);
BYTE DosDoIO(struct IORequest *iORequest);
Expand Down
Loading