Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
99 user(s) are online (52 user(s) are browsing Forums)

Members: 0
Guests: 99

more...

Headlines

 
  Register To Post  

« 1 (2) 3 4 »
Re: How find handler/filesystem name of a volume?
Just can't stay away
Just can't stay away


See User information
@ChrisH

The following code:
#include <proto/dos.h>

int main(int argcchar **argv) {
    
struct DevProc *dvp;
    
struct Process *proc;
    
BPTR seglist;
    
CONST_STRPTR vtag;

    if (
argc != 2) {
        
IDOS->PutErrStr("Usage: fsver <path>\n");
        return 
RETURN_FAIL;
    }

    
dvp IDOS->GetDeviceProcFlags(argv[1], NULLLDF_ALL);
    if (
dvp == NULL) {
        
IDOS->PrintFault(IDOS->IoErr(), argv[1]);
        return 
RETURN_FAIL;
    }

    
proc = (struct Process *)dvp->dvp_Port->mp_SigTask;

    
IDOS->FreeDeviceProc(dvp);

    
IDOS->Printf("process: %p\n"proc);

    
seglist IDOS->GetProcSegList(procGPSLF_RUN);

    
IDOS->Printf("seglist: %p\n", (APTR)seglist);

    if (
seglist != ZERO) {
        
vtag NULL;

        
IDOS->GetSegListInfoTags(seglist,
            
GSLI_VersionString, &vtag,
            
TAG_END);

        
IDOS->Printf("version: %s\n"vtag vtag "(null)");
    }

    return 
RETURN_OK;
}


when used on a smbfs device works just fine for me on my 4.1 beta system.

Quote:

8.Work:Development/Projects/Tests> gcc -O2 -Wall -o fsver fsver.c
8.Work:Development/Projects/Tests> fsver SMBFS0:
process: 0x5b75ac90
seglist: 0x16db2f35
version: $VER: smbfs 1.74 (31.8.2009)


Go to top
Re: How find handler/filesystem name of a volume?
Home away from home
Home away from home


See User information
@salass00
Thanks. I now realise my very stupid mistake; my code was missing the "&" before the "vtag". Also seems to work for FTP Mount & RAM handlers.

I will now try to do same functionality without OS4-specific calls.


Edited by ChrisH on 2016/5/21 20:37:22
Author of the PortablE programming language.
Go to top
Re: How find handler/filesystem name of a volume?
Just can't stay away
Just can't stay away


See User information
@ChrisH

To get the seglist pointer on older AmigaOS you have to read it from proc->pr_SegList. Note that pr_SegList unlike what it's name implies is not just a pointer to a seglist.

Instead it's a BCPL pointer to a SegArray which looks something like:

struct SegArray {
    
ULONG NumEntries;
    
BPTR SegLists[];
};


It's documented in the AmigaDOS manual if you have it.

Go to top
Re: How find handler/filesystem name of a volume?
Just popping in
Just popping in


See User information
Thanks for the code, salass00. Helped me a lot.

Now that we can check for smbfs shares reliably, what do we call them?

Shared Drives or Shared Drawers? Network Drive or Network Drawer? Other? Something generic in case SMBFS isn't the only type.

I ask just so there is some sort of "standard" name used.

Workbench Explorer - A better way to browse drawers
Go to top
Re: How find handler/filesystem name of a volume?
Just can't stay away
Just can't stay away


See User information
@ChrisH

A version tag scanner I put together in only a few minutes:

struct segment_header {
    
ULONG Size;
    
BPTR  Next;
    
UBYTE Code[];
};

static 
struct segment_header *bptr_to_segment_header(BPTR bptr) {
    if (
bptr != 0)
        return (
struct segment_header *)((ULONG *)BADDR(bptr) - 1);
    else
        return 
NULL;
}

static 
CONST_STRPTR scan_vtag_old(UBYTE *codeULONG size) {
    
UBYTE cmp[5];
    
CONST_STRPTR vtag NULL;
    
ULONG ij;

    
cmp[4] = ':';
    
cmp[3] = 'R';
    
cmp[2] = 'E';
    
cmp[1] = 'V';
    
cmp[0] = '$';

    for (
0sizei++) {
        if (
code[i] != cmp[j])
            
0;

        if (
code[i] == cmp[j] && ++== sizeof(cmp)) {
            
vtag = &code[sizeof(cmp) + 1];
            break;
        }
    }

    return 
vtag;
}

static 
CONST_STRPTR get_vtag_old(BPTR seglist) {
    
struct segment_header *seg;
    
CONST_STRPTR vtag NULL;
    for (
seg bptr_to_segment_header(seglist); seg != NULLseg bptr_to_segment_header(seg->Next)) {
        
vtag scan_vtag_old(seg->Codeseg->Size);
        if (
vtag != NULL)
            break;
    }
    return 
vtag;
}


It doesn't do much sanity checking but unless the seglist contains stray "$VER:" sequences it should work just fine.

Don't use code like this on AmigaOS >= 4.0, only use it on older AmigaOS where you have no other choice.


Edited by salass00 on 2016/5/22 12:35:51
Edited by salass00 on 2016/5/22 12:37:21
Go to top
Re: How find handler/filesystem name of a volume?
Just can't stay away
Just can't stay away


See User information
@mritter0

I think the correct name is "Network Shares", be it a drive or a directory, it's still valid.

Philippe 'Elwood' FERRUCCI
Sam460ex 1.10 Ghz
http://elwoodb.free.fr
Go to top
Re: How find handler/filesystem name of a volume?
Just popping in
Just popping in


See User information
What kind of "generic" icon would be used? A harddisk or drawer with a network reference on it?

Workbench Explorer - A better way to browse drawers
Go to top
Re: How find handler/filesystem name of a volume?
Just can't stay away
Just can't stay away


See User information
@mritter0
Maybe something like SYS:Prefs/Env-Archive/Sys/def_ftp.info would work.

Amiga X1000 with 2GB memory & OS 4.1FE + Radeon HD 5450

Go to top
Re: How find handler/filesystem name of a volume?
Just popping in
Just popping in


See User information
I already have had Mason make a network drive and drawer 16x16 pngs for me. Before I went any further with more images and names I was just trying to get a feel for what people think it should be.

I started a new thread.

Workbench Explorer - A better way to browse drawers
Go to top
Re: How find handler/filesystem name of a volume?
Home away from home
Home away from home


See User information
@salass00 Quote:
To get the seglist pointer on older AmigaOS you have to read it from proc->pr_SegList. Note that pr_SegList unlike what it's name implies is not just a pointer to a seglist.

My implementation is a little different, since I based it upon your OS4 code.

Specifically, since you used GPSLF_RUN with GetProcSegList(), which the auto-docs say is obtained from process->pr_CurrentSeg, I used that to get the first seg list. If I fail to find $VER: in that, then I get the next seg list from it's header.

So I don't touch the pr_SegList array. I'm not sure what effect, if any, it might have.

Author of the PortablE programming language.
Go to top
Re: How find handler/filesystem name of a volume?
Just can't stay away
Just can't stay away


See User information
@ChrisH

Quote:

Specifically, since you used GPSLF_RUN with GetProcSegList(), which the auto-docs say is obtained from process->pr_CurrentSeg, I used that to get the first seg list. If I fail to find $VER: in that, then I get the next seg list from it's header.


The pr_CurrentSeg field is only available in AmigaOS >= 4.0 as stated by comments in <dos/dosextens.h>.

Go to top
Re: How find handler/filesystem name of a volume?
Home away from home
Home away from home


See User information
@salass00
Thanks, now fixed. And this time actually compiled & tested for OS3, rather than just testing "OS3 code" on OS4!

BTW, I assumed that after getting the first seglist in the segarray, I could get the next seglist from the current seglist's header, rather than looking at the segarray again. Does that sound reasonable? (It seemed to work in my quick test anyway...)

Author of the PortablE programming language.
Go to top
Re: How find handler/filesystem name of a volume?
Not too shy to talk
Not too shy to talk


See User information
@ChrisH

#include <proto/dos.h>

int main (void)

{
struct DosList *dl;
struct MsgPort *port;
struct Process *pr;
struct CommandLineInterface *cli;

dl LockDosList (LDF_VOLUMES|LDF_READ);

while (
dl NextDosEntry (dl,LDF_VOLUMES))
    {
    
Printf ("%-10b: ",dl->dol_Name);
    if ((
port dl->dol_Task))
        {
        if ((
port->mp_Flags PF_ACTION) == PA_SIGNAL)
            {
            
pr = (struct Process *) port->mp_SigTask;
            if (
pr->pr_Task.tc_Node.ln_Type == NT_PROCESS)
                {
                if ((
cli BADDR(pr->pr_CLI)))
                    {
                    if (
cli->cli_CommandName)
                        
Printf ("%b\\n",cli->cli_CommandName);
                    else
                        
Printf ("no command name\\n");
                    }
                else
                    
Printf ("no CLI\\n");
                }
            else
                
Printf ("task is not a process\\n");
            }
        else
            
Printf ("no task in port\\n");
        }
    else
        
Printf ("no port\\n");
    }

UnLockDosList (LDF_VOLUMES|LDF_READ);

return (
0);
}


gives something like this for me:

5smbvol
Users     
smbfs '//video/users'
Ram Disk  no CLI
Public    : no CLI
VideoWB   
no CLI
5
>


Go to top
Re: How find handler/filesystem name of a volume?
Just can't stay away
Just can't stay away


See User information
@ChrisH

Quoting from the AmigaDOS manual:
Quote:

To identify the segments that a particular process uses, you must use pr_SegList. pr_SegList is an array of longwords with its size in Seg_List[0]. Other elements are either zero or a BPTR to a SegList. CreateProc() and CreateNewProc() create this array with the first two elements of the array pointing to resident code and the third element, being the SegList, passed an argument. When a process terminates, FreeMem() is used to return the space for the pr_SegList.


As far I understand they are separate seglists and you want the third one (sa->SegLists[2]), but I could be wrong as the documentation is not very clear to me.

You can this information on the wiki as well:
http://wiki.amigaos.net/wiki/AmigaDOS_Data_Structures


Go to top
Re: How find handler/filesystem name of a volume?
Just popping in
Just popping in


See User information
The segarray in the process structure has only one field that is
of interest to you, that being segarray[3]. The others are for
other external resident modules that DOS uses, (or zero).

segarray[3] is the seglist for the process code.
However, if that process is a shell process, that seglist would of
course be for the shell handler itself when the new process was created,
and not any current command, so, to prevent the resident shell handler
being unloaded, the shell startup routine always clears segarray[3].

Therefore, to get the seglist for a program currently running in a
shell process, you need to look in the cli structure field cli_Module.

This code should also work all the way back to OS2 or even before.

===================================================

BPTR get_current_seglist( struct Process *proc )
{
BPTR result = 0;

#ifdef __amigaos4__
result = IDOS->GetProcSegList(proc,GPSLF_RUN);
#else
if( proc->pr_Cli )
{
struct CommandLineInterface *cli = BADDR(proc->pr_Cli);
result = cli->cli_Module;
}
else
{
BPTR *segarray = BADDR(proc->pr_SegArray);
result = segarray[3];
}
#endif

return(result);
}

===================================================

Disclaimer: I wrote this without checking for typos.



Edited by colinw on 2016/5/23 7:19:48
Edited by colinw on 2016/5/23 7:21:21
Go to top
Re: How find handler/filesystem name of a volume?
Home away from home
Home away from home


See User information
@colinw
Thanks for your code... but it doesn't work for me :( .

On AmigaOS4, it crashes at "cli->cli_Module;". It seems that "cli" is not a valid pointer (but not zero either). I don't know what happens on AmigaOS3, since it doesn't get called in my test cases.

On AmigaOS3, segarray[3] gives a seglist, but no $VER string. Where-as my old code used segarray[1], which results in a different seglist, and leads to a valid $VER string.

On AmigaOS4, segarray[3] does give a seglist (with a $VER string). While segarray[1] is NULL. So this bit does work.

@salass00
Quote:
As far I understand they are separate seglists and you want the third one (sa->SegLists[2]), but I could be wrong as the documentation is not very clear to me.

To avoid confusing anyone, the "third one" would be sa->SegLists[3], not sa->SegLists[2] as you wrote (since sa->SegLists[0] is the array size rather than a seglist BPTR).

@thomas
Sorry for being thick, but what were you trying to demonstrate with your code?


Edited by ChrisH on 2016/5/23 21:19:15
Edited by ChrisH on 2016/5/23 21:23:26
Edited by ChrisH on 2016/5/23 23:08:34
Author of the PortablE programming language.
Go to top
Re: How find handler/filesystem name of a volume?
Just popping in
Just popping in


See User information
@ChrisH

Check your code, something is wrong with it.

The dosextens file shows the cli structure.
-> BPTR cli_Module; /* SegList of currently loaded command */
it is never anything else.

Make sure you follow the example and check the pointers, it will work
for OS3 and earlier releases, I actually rewrote the DOS library for
OS4, so I know how it works and I know what OS3 compatibility is there.

segarray[3] is the only one you can use that (currently) stays the same in
OS4 and OS3, the others are for things like the shell-segments (2),
one BCLP startup and one C startup, as well as the ram-handler
and con-handler segment and the default filesystem segment,
so don't mess around in there, some of them have disappeared for OS4,
like the ram-handler segment, as the startup methodology has changed
and the default filesystem (FFS) may not even be loaded now, also,
I have reused some old slots for other purposes, like segarray[2],
this was something completely different in OS3, so heed the warning.

For OS4, use the API functions exclusively for structure member access,
segarray[3] may even go away in later releases.



Edited by colinw on 2016/5/24 0:44:53
Edited by colinw on 2016/5/24 0:46:35
Go to top
Re: How find handler/filesystem name of a volume?
Just can't stay away
Just can't stay away


See User information
@ChrisH

Quote:

To avoid confusing anyone, the "third one" would be sa->SegLists[3], not sa->SegLists[2] as you wrote (since sa->SegLists[0] is the array size rather than a seglist BPTR).


No, it wouldn't because I defined the "array size" as a separate ULONG field in my SegArray structure.

Of course if you use a BPTR array rather than defining a structure like I did then the third seglist will be at array index 3.

Go to top
Re: How find handler/filesystem name of a volume?
Home away from home
Home away from home


See User information
@colinw
Although I am coding using PortablE, the C++ code it generates for OS4 looks essentially functionally identical to your C code:

BPTR getProcSegList_Run(struct Processprocess)  {
    
BPTR seglist=(BPTRNULL;
    
struct CommandLineInterfacecli=NULLBPTRsegarray=NULL;
    if (
process->pr_CLI) {
        
cli = (struct CommandLineInterface*) BADDR(process->pr_CLI);
        
seglist cli->cli_Module;
    } else {
        
segarray = (BPTR*) BADDR(process->pr_SegArray);
        
seglist segarray[3];
    }
    return 
seglist;
}


NOTE: For test purposes, I got rid of the OS4-only code, on the assumption/hope it would work on OS4 the same way it does on OS3.

So I am puzzled why it should crash at "cli->cli_Module;" on OS4.


And while I was testing OS3 by generating & compiling AmigaE code, I get the same result when generating & comping very similar C++ code for OS3:
BPTR getProcSegList_Run(struct Processprocess)  {
    
BPTR seglist=(BPTRNULL;
    
struct CommandLineInterfacecli=NULLBPTRsegarray=NULL;
    if (
process->pr_CLI) {
        
cli = (struct CommandLineInterface*) BADDR(process->pr_CLI);
        
seglist cli->cli_Module;
    } else {
        
segarray = (BPTR*) BADDR(process->pr_SegList);
        
seglist segarray[3];
    }
    return 
seglist;
}


HOWEVER, after a bit of further experimentation, I found that segarray[3] does find a $VER for the DF0: filesystem. Just not for the RAM handler, nor the virtual filingsystem provided by E-UAE.

OTOH, segarray[1] reliably finds a $VER for all three test cases. Don't ask me why!

Author of the PortablE programming language.
Go to top
Re: How find handler/filesystem name of a volume?
Home away from home
Home away from home


See User information
@thomas
I had more time to think about your code. I added your extra checks to my (previously crashing) code, and it no-longer crashes.

Where it USED to crash, it now reports "No task in port" for the SFS filing system. I don't understand what "(port->mp_Flags & PF_ACTION) == PA_SIGNAL" is doing, so perhaps you can explain why this check is needed for your code to work?

Author of the PortablE programming language.
Go to top

  Register To Post
« 1 (2) 3 4 »

 




Currently Active Users Viewing This Thread: 1 ( 0 members and 1 Anonymous Users )




Powered by XOOPS 2.0 © 2001-2023 The XOOPS Project