• Welcome to OS2World OLD-STATIC-BACKUP Forum.
 

News:

This is an old OS2World backup forum for reference only. IT IS READ ONLY!!!

If you need help with OS/2 - eComStation visit http://www.os2world.com/forum

Main Menu

Backup filenames on JFS

Started by jep, 2008.05.13, 15:47:02

Previous topic - Next topic

jep

Marked as: Advanced
Hello,

If you run into trouble with JFS volumes chkdisk may at times release files due to problems with the internal structure. June ( http://ecomstation.ru/jrescuer ) may then be the tool for you to use to recover those files, but you can only recover the filenames togheter with the file if you've previously set the .LONGNAME Extend Attribute (EA) as JFS doesn't keep the path nor filename info as e.g. HPFS (partially) does.

The documentation for June/JRescuer mention that you shold set the EA so that June can use the info when it has to recover a file.

I've extended the original script to include the progressbar and information about the folders it process that was lacking. This version doesn't take any parameters as it process all local drives.

Solution included in this script for you to study:
How to calculate the progress even if you only have found out info about the current folder.
Function that call itself several times (recursive calls)

Good:
Can begin to process files almost immediately

Not good:
Time calculation for ( recursive ) functions doesn't work

Possible improvements:
Remove recursive calls and put everything in loops
Add time estimation when the script may be done.

//Jan-Erik

Changes 2008-05-15:
Replaced text with █ (Alt + 219) and ░ (Alt + 176)
or use some other characters if you want to...

to select one or more drives, modify code before the line:
drives = SysDriveMap( , 'LOCAL' )
to something like

if ARG() > 0 then
  drives = ARG(1)
else

be sure to specify the parameters for the drives such as
E: F: G:
or one path like
I:\path\to\set\long\ea
when you run it then.

/*
    Script: Set .LONGNAME EA for all files in specifiled
            directory and subdirectories.
*/


call rxFuncAdd "SysLoadFuncs" , "RexxUtil" , "SysLoadFuncs"
call SysLoadFuncs

call SysCls
call rxBusy 'Searching drives...one moment please.', 0

elapsed = TIME( 'R' )
drives = SysDriveMap( , 'LOCAL' )
do i = 1 to words( drives )
    call processPath subword( drives, i, 1 ), ( i - 1 ) / words( drives ), 1 / words( drives )
    call rxProgress i / words( drives ), 2
end
exit 0

processPath: procedure expose elapsed counter_
    p = arg(1)
    progress = arg(2)
    chunk = ARG(3)
   
    call rxBusy 'Processing '||p, 0
    call SysFileTree p||'\*', 'folder', 'DO'
    do j = 1 to folder.0
        call processPath folder.j, progress + j / folder.0 * chunk, chunk / folder.0
    end
    drop folder.

    call SysFileTree p||'\*', 'file', 'FO'
    do i = 1 to file.0
        if TIME( 'E' ) > 1 + elapsed then do
            call rxBusy 'Processing '||p, 0
            call rxProgress progress + i / file.0 * chunk, 2
            elapsed = TIME( 'E' )
        end
        rc = SysGetEA( file.i, ".LONGNAME", "tmp" )
        if rc \= 0 | tmp=""  then do
            name = FILESPEC( 'N', file.i )
            nameinfo = 'FDFF'x || d2c(length(name)) || '00'x || name
            call SysPutEA file.i, ".LONGNAME", nameinfo
        end
    end
    drop file.

return

/* part, of_total, display_on_row */
rxProgress: Procedure
    if datatype( ARG(1), 'N' ) then
    do
        progress = trunc( 76 * ARG(1) )
        call rxOut left( copies( '█', progress )||copies( '░', 76 - progress ), 76 )||right( trunc( 100 * ARG(1) )||'%', 4 ), ARG(2)
    end
Return 0
   
rxBusy: Procedure expose counter_
    SELECT
        WHEN counter_ = 1 THEN
            call rxOut '/ '||ARG(1), ARG(2)
        WHEN counter_ = 2 THEN
            call rxOut '- '||ARG(1), ARG(2)
        WHEN counter_ = 3  THEN
            call rxOut '\ '||ARG(1), ARG(2)
        OTHERWISE
            counter_ = 0
            call rxOut '| '||ARG(1), ARG(2)
        END
    counter_ = counter_ + 1
Return 0
   
/* text, display_on_row */
rxOut: Procedure
    if datatype( ARG(2), 'W' ) then
        parse value SysCurPos( ARG(2), 0 ) with prev_row prev_col
    say left( ARG(1), 80 )
    if datatype( ARG(2), 'W' ) then
        call SysCurPos prev_row, prev_col
Return 0

Andi

Tried out and got -
REX0006: Error 6 running D:\batch\Longname_EA.cmd, line 56: Unmatched "/*" or quote

Unfortunatly my rexx knowledge is very limited and I cann't see the problem in the code.



abwillis

Looks like this code
call rxOut left( copies( '', progress )||copies( '', 76 - progress ), 76 )||right( trunc( 100 * ARG(1) )||'%', 4 ), ARG(2)
got line wrapped and it should all be one line... at least that is what caused the error here.
Andy

Andi

The problem seems to be the character which is enclosed in the quotes. I copied the code from here into MED and MED interprets this as an right arrow. In VisualSlickEdit this character is the last what is read from the file. The rest is truncated. So I think the rexx interpreter can not read the file as VisualSlickEdit do. Changing the arrow to ' ' and I get a little further. Now searching drives is displayed but the script stops with -

progress), 76) || right(( trunc(100 * ARG(1)) || '%', 4), ARG(2) ;
REX0037: Error 37 running D:\batch\Longname_EA.cmd, line 56: Unexpected "," or
")"
    37 +++                 Call rxProgress progress + i / file.0 * chunk, 2;
    29 +++         Call processPath folder.j, progress + j / folder.0 * chunk, chunk / fol
der.0;
    16 +++     Call processPath subword(drives, i, 1), ( i - 1 ) / words(drives), 1 / word
s(drives);

Running the sript with output redirection like 'Longname_EA.cmd >tmp.txt' stops with the same message as above but leaves in tmp.txt the following -

| Searching drives...one moment please.
/ Processing C:
- Processing C:\ADVANT
\ Processing C:\ADVANT

Seems now it stops after processing at least a few files in one subdirectory. C:\ is a FAT partition on this machine.

abwillis

Hmm, it ran fine here... it went through my C: drive (NTFS so it couldn't really do anything as it is read only) and then D: and E: (both JFS) just fine.
Andy

warpcafe

Hi Andi,

Quote from: Andi on 2008.05.14, 23:29:55
Seems now it stops after processing at least a few files in one subdirectory. C:\ is a FAT partition on this machine.

...just a short question:
The script stores the filename into the longname EA of the appropriate file for JUNE. JUNE only works on JFS partitions... why do you want to run this script on a FAT partition?
Or... is it rather unintended because the script processes ALL local drives starting with "C"... while you just actually need to run it on a different (JFS) partition?

Regards,
Thomas
"It is not worth an intelligent man's time to be in the majority.
By definition, there are already enough people to do that"
- G.H. Hardy

Andi

Quote from: warpcafe on 2008.05.15, 10:13:31
.... is it rather unintended because the script processes ALL local drives starting with "C"... while you just actually need to run it on a different (JFS) partition?

Regards,
Thomas
Yes it's unintended. I think there's no command line option to avoid searching _all_ drives. Have to learn rexx and change the script for that I think until no one else will do it for me to see if it's a FAT problem ;)

jep

#7
Hello,

as you mention... the homepage interpreted the input for the characters funny and they're not easy to add either. :-(

You can replace them with '█' (Alt + 219) and '░' (Alt + 176)
I'll try to see if line brake in code above can be fixed.
The code wasn't wrapped, so it may have been wrapped in your web browser.

OS/2 FAT, HPFS and JFS can handle EA's but it's probably to no use.
NTFS can also handle EA's b.t.w. accoring to a magazine I've read, but only when one can write to it.

//Jan-Erik

Andi

Playing a little bit more after being back home -
- Hide FAT partition (C:)
- tried 'Longname_EA.cmd >>tmp.txt' another two times leaves in tmp.txt

| Searching drives...one moment please.                                         
/ Processing C:                                                                 
- Processing C:\ADVANT                                                         
\ Processing C:\DOS                                                             
| Processing C:\E2                                                             
/ Processing C:\MSI                                                             
- Processing C:\ARJ                                                             
\ Processing C:\ARJ\OS2                                                         
| Processing C:\DELETE                                                         
| Searching drives...one moment please.                                         
/ Processing D:                                                                 
- Processing D:\backup                                                         
\ Processing D:\backups                                                         
| Processing D:\batch                                                           
/ Processing D:\batch\backup                                                   
- Processing D:\batch\backups                                                   
\ Processing D:\BIN                                                             
| Processing D:\BIN\backups                                                     
/ Processing D:\BOOKS                                                           
- Processing D:\CID                                                             
\ Processing D:\CID\LOCINSTU                                                   
| Processing D:\DELETE                                                         
/ Processing D:\DELETE                                                         
| Searching drives...one moment please.                                         
/ Processing D:                                                                 
- Processing D:\backup                                                         
\ Processing D:\backups                                                         
| Processing D:\batch                                                           
/ Processing D:\batch\backup                                                   
- Processing D:\batch\backups                                                   
\ Processing D:\BIN                                                             
| Processing D:\BIN\backups                                                     
/ Processing D:\BOOKS                                                           
- Processing D:\CID                                                             
\ Processing D:\CID\LOCINSTU                                                   
| Processing D:\DELETE                                                         
/ Processing D:\DELETE 

I think it has problems with the DELETE directory on whatever drive it is used. D: is HPFS on this machine. Have you guys tried this script when DELDIR is set?

jep

#9
Hello,

I haven't tried the script with deldir set. Hmmm, perhaps a "dir /s" can tell us more?

If you have many files in a folder, the rotating progressbar will continue to "turn" after ~1 sec, that's deliberate so that you should be aware that it hasn't frozen.

How many folders do you have on D:, many? With alot of files and folders after "D:\Delete"?

You can also place a
call rxBusy file.i, 4
right after the line:
rc = SysGetEA( file.i, ".LONGNAME", "tmp" )
to see each file beeing processed and then you'll notice where it exit.

//Jan-Erik

Andi

Thanks, done. The scipts crashes immediatly, read

Seems there are different files which the script do not like. At first it crashes on C:\Delete. After removing C: it crashes on the app. 250. file in D:\DELETE. After deleteing all files in D:\DELETE it crashes in the template folder (after about 540 files) -
<skip> ...
/ Processing D:\Desktop\TCP!IP Shadows                                         
- Processing D:\Desktop\TCP!IP Shadows\Dos!Windows                             
\ Processing D:\Desktop\TCP!IP Shadows\TCP!IP Configuration                     
| Processing D:\Desktop\TCP!IP Shadows\TCP!IP Information                       
/ Processing D:\Desktop\TCP!IP Shadows\TCP!IP Internet^(LAN)                   
- Processing D:\Desktop\TCP!IP Shadows\TCP!IP Internet^(Modem)                 
\ Processing D:\Desktop\TCP!IP Shadows\TCP!IP Templates                         
| Processing D:\Desktop\Templates                                               
/ Processing D:\Desktop\Templates\Create Audio-CD                               
- Processing D:\Desktop\Templates\Create Data-CD                               
\ Processing D:\Desktop\Templates\Create Data-DVD                               
| Processing D:\Desktop\Templates\Folder                                       
/ Processing D:\Desktop\Templates\Folder!1                                     
- Processing D:\Desktop\Templates\Internet Templates                           
\ Processing D:\Desktop\Templates\Internet Templates\FTP Host                   
| Processing D:\Desktop\Templates\Internet Templates\URL Folder                 
/ Processing D:\Desktop\Templates\Internet Templates   

Message in CLI window -

     57 +++                               Call rxOut left(copies(' ', progress) || copies(' ', 76 - p
rogress), 76) || right(( trunc(100 * ARG(1)) || '%', 4), ARG(2);
REX0037: Error 37 running D:\batch\Longname_EA.cmd, line 57: Unexpected "," or
")"
    37 +++                         Call rxProgress progress + i / file.0 * chunk, 2;
    29 +++                 Call processPath folder.j, progress + j / folder.0 * chunk, chunk / folde
r.0;
    29 +++             Call processPath folder.j, progress + j / folder.0 * chunk, chunk / folder.0;

    29 +++         Call processPath folder.j, progress + j / folder.0 * chunk, chunk / folder.0;
    16 +++     Call processPath subword(drives, i, 1), ( i - 1 ) / words(drives), 1 / words(drives);


Is my rexx broken? How can I check the rexx version? This is basically a eCS2.0b2 installation but with a lot of additions installed.

These are my *rexx.dlls  on the boot drive -

{0}[D:\] ls *rexx.dll /s

The volume label in drive D is ECS2_0.
The Volume Serial Number is A9D5:7815.

Directory of D:\DLL

23.05.08 15.23          46.181     34 a---  sliprexx.dll
        1 file(s)        46.181 bytes used

Directory of D:\ecs\dll

9.06.05 14.41         192.894      0 a---  VPREXX.DLL
        1 file(s)       192.894 bytes used

Directory of D:\IBMLAN\RPL\MPTN\DLL

18.09.01 18.48          46.181      0 a---  sliprexx.dll
        1 file(s)        46.181 bytes used

Directory of D:\MPTN\DLL

18.09.01 18.48          46.181      0 a---  sliprexx.dll
        1 file(s)        46.181 bytes used

Directory of D:\OS2\DLL

6.09.00 14.45          97.811      0 a---  NAMEREXX.DLL
6.03.01 13.59         491.299      0 a---  OREXX.DLL
6.09.00 14.42         266.031      0 a---  REXX.DLL
        3 file(s)       855.141 bytes used
Total files listed:
        7 file(s)     1.186.578 bytes used
                    228.532.224 bytes free

Andi

Shit - it crashes after 500-650 files after about 2 seconds. There was really one ) missed in that line as the error message says. To be pecisec it was actually one ( to much there.

Rexx is interpreter not compiler. I'm used to compilers so never thougt an syntax error can pop up after running for about 2 seconds.

Additionaly I don't see the progress bar and the funny 'Processing .....' message cause I usually work with cmshl for CLI windows which seems to suppress this message completly. First drawback of cmdshl since years of heavily using command lines...

Sorry for bothering you with that. I can't imagine how this additionaly ( comes into this line. Tought it was exakt copy/paste of your script here.

Now the script runs for minutes and is at 81%. I think it would process the rest without problems now.

jep

Hello,

that's OK Andi, actually your problem has been very helpful to describe how rexx behave in some cases and cause what may seem like "random problems" at other times.

Hopefully it'll give insight how and what the code does, it's quite common that one accidentally test a call to some function and therefore add parenthesis some_function(...) and later forget to remove them all. Remember that my cut and paste here didn't quite work for █ and ░, so you may have tried to fix it?!

I usually try out the code on my computer before posting it, but cut and paste to a homepage doesn't always produce the correct result, especially with characters such as ░▒▒▓█ so It might very well have been an error on my part.

Hehe, that's what's so "great" about it, you can run it up to the point where everything goes haywire, but only in classic rexx if you've got an error like that in the code. Guess someone that was used to ordinary compiled code didn't like that way so they had to change the behavior on object rexx, it complains right away, very annoying when one's used to the relaxed checking by classic rexx that's so much easier to test ideas.

As Andi now have noticed, and everyone else may want to think about is that the interpreter in classic rexx never look at code until it has to use it. The line if TIME( 'E' ) > 1 + elapsed then do was never fulfilled until the code had to process a folder with many files¹ and thus the comparison was true² after 1 sec.

Thank you Andi for the clarifications and how you found out what the problem was.

//Jan-Erik

¹) It took over 1 sec to process, may have been caused by heavy load on the computer. At another time it may have happened in another folder for this particular problem
²) For this particular code you can see it in the output that it show the same folder D:\DELETE twice

Tip: To debug code, add call trace '?i' a few lines before the line where the problem occur.
You'll get a hint where the problem occured (bold), while the description should tell you what to look for (Italic).
   57 +++                               Call rxOut left(copies(' ', progress) || copies(' ', 76 - p
rogress), 76) || right(( trunc(100 * ARG(1)) || '%', 4), ARG(2);
REX0037: Error 37 running D:\batch\Longname_EA.cmd, line 57: Unexpected "," or ")"

In this case you may have wanted to place call trace '?i' right after the if TIME( 'E' ) > 1 + elapsed then do.