os.rename causes crash when dest. path > 31 characters - General Help and Assistance on using CHDK stable releases - CHDK Forum

os.rename causes crash when dest. path > 31 characters

  • 23 Replies
  • 2278 Views
os.rename causes crash when dest. path > 31 characters
« on: 13 / July / 2021, 15:26:33 »
Advertisements
Hello,
I am experiencing a crash every time I execute os.rename("short", "long5678901234567890123456789012").

Meaning the function only accepts a destination path length of 31 bytes or lower. This is also true when the destination path contains many short directory names like "a/bcd/e/fg..." but the total path length is 32 bytes or longer. Is there a way around?

Thank you.
« Last Edit: 13 / July / 2021, 15:28:50 by Joker135 »

*

Offline Caefix

  • *****
  • 652
  • Sorry, busy deleting test shots...
Re: os.rename causes crash when dest. path > 31 characters
« Reply #1 on: 13 / July / 2021, 15:37:47 »
Yuo could run lfntest2.lua for additional info.  ??? Maybe it´s a firmware limit...
https://chdk.setepontos.com/index.php?topic=10833.msg125241#msg125241
All lifetime is a loan from eternity.

Re: os.rename causes crash when dest. path > 31 characters
« Reply #2 on: 13 / July / 2021, 15:47:40 »
Maybe it´s a firmware limit
Is os.rename a wraparound function that uses the canon firmware?

BTW: The source path does not have the 31 byte limit.
« Last Edit: 13 / July / 2021, 15:50:52 by Joker135 »

*

Offline reyalp

  • ******
  • 13456
Re: os.rename causes crash when dest. path > 31 characters
« Reply #3 on: 13 / July / 2021, 16:12:52 »
Hello,
I am experiencing a crash every time I execute os.rename("short", "long5678901234567890123456789012").

Meaning the function only accepts a destination path length of 31 bytes or lower. This is also true when the destination path contains many short directory names like "a/bcd/e/fg..." but the total path length is 32 bytes or longer. Is there a way around?
No. Various Canon firmware versions have various path limits. I'd guess your camera is in the DryOS 39-43 range, which is particularly limited. See discussion starting around https://chdk.setepontos.com/index.php?topic=10833.msg125194#msg125194

Quote
Is os.rename a wraparound function that uses the canon firmware?
Yes, CHDK uses firmware functions to interact with the filesystem.
Don't forget what the H stands for.


Re: os.rename causes crash when dest. path > 31 characters
« Reply #4 on: 14 / July / 2021, 11:08:43 »
Thank you both of you. Ok, I will do further testings and try if it is possible to avoid a crash in my script as discussed in the mentioned topic.

My camera is a SX620HS. But I also got a slightly older SX710HS for testing. The older SX710HS hasn't crashed yet, but I am not sure if I ever had such a long path with it.

How can I check my DryOS version?

*

Offline Caefix

  • *****
  • 652
  • Sorry, busy deleting test shots...
Re: os.rename causes crash when dest. path > 31 characters
« Reply #5 on: 14 / July / 2021, 11:24:55 »
 :) Sx620 & 710 have in trunc/...platform/.../stubs_entry.s
Code: [Select]
//#define CAM_DRYOS_2_3_R39 1 // Defined for cameras with DryOS version R39 or higher
//#define CAM_DRYOS_2_3_R47 1 // Defined for cameras with DryOS version R47 or higher
when the destination path contains many short directory names like "a/bcd/e/fg..."
'/' is not a letter, each subfolder should exist or needs a os.mkdir() per segment, (or it´s own os.rename() in Your case...)
Other experiences: https://chdk.setepontos.com/index.php?topic=14037.msg143417#msg143417
« Last Edit: 14 / July / 2021, 11:57:30 by Caefix »
All lifetime is a loan from eternity.

Re: os.rename causes crash when dest. path > 31 characters
« Reply #6 on: 14 / July / 2021, 11:31:27 »
:) Sx620 & 710 have in trunc/...platform/.../stubs_entry.s
Code: [Select]
//#define CAM_DRYOS_2_3_R39 1 // Defined for cameras with DryOS version R39 or higher
//#define CAM_DRYOS_2_3_R47 1 // Defined for cameras with DryOS version R47 or higher

That means that both of my cameras are not in the DryOS 39-43 range, right?

So the problem might really be with the destination path and not a general path length limit. Especially since the source path does not have the 31 characters limit.
« Last Edit: 14 / July / 2021, 11:34:01 by Joker135 »

Re: os.rename causes crash when dest. path > 31 characters
« Reply #7 on: 14 / July / 2021, 11:57:23 »
I just noticed that it probably would be possible to move in chunks:

Instead of moving from
A/file.txt
to
A/a/b/c/file.txt

I could move from
A/file.txt
to
A/c/file.txt

Then from
A/c
to
A/b/c

Then from
A/b
to
A/a/b

Afterwards
A/file.txt
would have moved to
A/a/b/c/file.txt

But it will be a mess to script, dirty and requires that A/b and A/c didn't exist before.


*

Offline Caefix

  • *****
  • 652
  • Sorry, busy deleting test shots...
Re: os.rename causes crash when dest. path > 31 characters
« Reply #8 on: 14 / July / 2021, 12:32:45 »
But it will be a mess to script, dirty and
Sure,  :( move = copy + delete + reboot.
and requires that A/b and A/c didn't exist before.
os.mkdir("A/b") is okay even if "A/b" exists already.
All lifetime is a loan from eternity.

Re: os.rename causes crash when dest. path > 31 characters
« Reply #9 on: 14 / July / 2021, 12:50:00 »
If A/b already exists then the content will be moved to A/a/b.

os.rename doesn't seem to copy and delete. It seems to be a move. But if you use the chdk file browser then moving seems to be a copy and delete. Or for some other reason extreme slow.

 

Related Topics