LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 02-02-2008, 02:55 PM   #1
Nick Levinson
LQ Newbie
 
Registered: Jan 2008
Posts: 6

Rep: Reputation: 0
filenames across OSes: portability checker


Linux is so flexible about what names are acceptable that admins have to restrict them in order to avoid problems. One area is with files that are moved between Windows and Linux platforms, especially when lots of files are being moved at once (for example, I back up my Win-oriented flash thumb to a Linux folder).

Some of us solve this by trying to use restrictive names in the first place, such as DOS 8.3- or POSIX-compliant names, but that's less convenient when I'm in Win and it doesn't work for old files.

Can any Linux program or command look at names and draw our attention to those that might violate some specified standard?

Or do we need a new program to do this?

Thanx.

--
Nick
 
Old 02-03-2008, 08:43 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Quote:
Originally Posted by Nick Levinson View Post
(..) restrict them in order to avoid problems (..) less convenient when I'm in Win (..) violate some specified standard
While I agree convenience is nice and that it wouldn't be a bad exercise to have something iterate until you can write C:\Progra~1\Applic~1\File~199.DOC, the "standard" you describe does not affect GNU/Linux:
Quote:
The POSIX.1 standard allows implementations to put additional restrictions on file name syntax, concerning what characters are permitted in file names and on the length of file name and file name component strings. However, in the GNU system, you do not need to worry about these restrictions; any character except the null character is permitted in a file name string, and there are no limits on the length of file name strings.
(OK, not POSIX ISO but the Glibc manual, Portability of File Names).
IMHO compliance here is not a GNU/Linux thing but the Other Thing having made up its own incompatible rules.
 
Old 02-06-2008, 06:57 PM   #3
Nick Levinson
LQ Newbie
 
Registered: Jan 2008
Posts: 6

Original Poster
Rep: Reputation: 0
Can any Linux program or command look at filenames and draw our attention to those that might violate some specified standard? I meant a standard we users/admins specify as an overlay on Linux, not a standard within Linux or GNU/Linux (http://www.gnu.org/software/libc/man...mono/libc.html, [§] 11.2, esp. 11.2.4, as accessed 2-5-08).

For example, Linux permits a hyphen in a filename, including in the leading position, but that can make a filename look like an argument to a command, and therefore, while Linux permits it, an admin might specify a ban on leading hyphens and might want a technical means of preventing filenames from getting leading hyphens and might want a way to catch files coming into a system that weren't restricted by other admins and might have a locally banned character.

In http://www.ibm.com/developerworks/li...ary/l-sp2.html (as accessed 12-8-07), search for "Linux" to find relevant filename discussions.

This is more than convenience. When I drafted this message, my flash was holding 2,127 files and folders. That's a lot of names to check if I have to check them manually one by one. If I eyeball an average of one per second, I'd lose over 35 minutes and what if I accidentally miss one? I already found one accented letter Win95a allows that Linux replaces in filenames, which would make finding the file or folder harder using Search for Files or equivalent.

I don't want Linux to have restrictions built in. I want each admin to be able to set their own or not set any, as they wish. Not setting any would amount to letting Linux do what it does now, which would be fine for many users. But, if constraints are helpful, posting a written memo to all users isn't enough for consistent adherence, and a technical means would be useful.

Windows has the baggage of Microsoft's business and programming practices, but Windows is out there, and many of us must let the 800-pound gorilla sit wherever it wants. I like Linux's power. I want a way that doesn't reduce its power but that allows compatibility of names with various operating systems and other kinds of rules.

Any ideas?

Thanx.

--
Nick
 
Old 02-07-2008, 05:28 AM   #4
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
I thought LFN would chop things off to whatever it deemed presentable. Anyway. I'm not aware of that kind of "lint check". Maybe something like
Code:
 isValidName() {
 declare -r strRestr="[0-9a-zA-Z-_.]"
 [ -z "${1//$strRestr/}" ] || return
 [ "${1:0:1}" = "-" ] || return
 [ ${#1} -gt 11 ] || return
} 
isValidName "somefile\#n@me" || echo no
should give you the idea even though it's a crude, way too strict example only working on names. Expanding it to include your local "rules" shouldn't be that hard.
 
Old 02-10-2008, 01:27 PM   #5
Nick Levinson
LQ Newbie
 
Registered: Jan 2008
Posts: 6

Original Poster
Rep: Reputation: 0
That's the basic idea, expandable. I guess we need an envelope, so to speak, so it can run as a background process alerting us when a name is wrong. I'm not a programmer at that level, and I guess there isn't a program to provide this kind of functionality yet, so maybe I'll propose this somewhere and hope someone wants to develop the concept further.

LFN can't be trusted to ensure compatibility. Possibly, the accented letter on my Win platform got auto-replaced or disappeared on my Linux platform because of an encoding or charset difference between Win and Linux, but I don't know. Besides, letting an OS rename a file by a protocol without user preview has a drawback: it can create unexpected names, as happens when you drop two LFN files into a Win directory:

verylongnameMonday.txt
verylongnameTuesday.txt

The order in which they're created in or added to a directory may result in either one becoming VERYLO~1.TXT with the other getting the ~2, leaving you in the dark as to which is which, which is why files called in Win by programs get DOS 8.3 names from the files' programmers regardless of LFN support. Better that a process alert us to problematic names; then you can rename to taste besides being assured of compatibility/compliance.

Thank you for giving the coding a start. I hope someone picks it up.

--
Nick
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LFS portability bobert13581 Linux From Scratch 2 01-17-2008 03:12 AM
portability problem jawwad Linux - Networking 1 07-17-2006 02:16 PM
Reverse Engineering for Portability dlublink Linux - Software 1 11-23-2005 01:43 PM
[C] Attribute portability darklogik_org Programming 2 02-13-2005 09:22 PM
portability??? perdesiz Programming 3 02-18-2004 06:32 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 08:44 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration