LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-28-2010, 02:44 AM   #1
pinga123
Member
 
Registered: Sep 2009
Posts: 684
Blog Entries: 2

Rep: Reputation: 36
CIFS file system check.


I have written a script to take backup of linux data on window's shared folder.
I have used following method in my script.
Code:
 mount -t cifs <windowshare> -o username=username,password=myPassword <mountlocation>
However most of linux system doesnt support CIFS filesystem.
How would i check if CIFS filesystem or service is present or not before executing the script?
 
Old 07-28-2010, 02:56 AM   #2
zirias
Member
 
Registered: Jun 2010
Posts: 361

Rep: Reputation: 59
Hmm your subject was a little misleading to me, I really thought you wanted to fsck a remote fs.

Well I think cifs is available on MOST linux systems, but it is often there as a module. You could check by the following procedure:

Code:
HAVE_CIFS=no
grep -q cifs /proc/filesystems && HAVE_CIFS=yes
/sbin/modinfo cifs &>/dev/null && HAVE_CIFS=yes

if [ "x$HAVE_CIFS" = "xyes" ]; then
  ...
fi
The first line checks whether cifs is currently available as filesystem, the second line checks whether the loadable kernel module is there -- in both cases, cifs will be usable on this box.

Last edited by zirias; 07-28-2010 at 02:58 AM.
 
Old 07-28-2010, 04:32 AM   #3
pinga123
Member
 
Registered: Sep 2009
Posts: 684
Blog Entries: 2

Original Poster
Rep: Reputation: 36
Quote:
Originally Posted by zirias View Post
Hmm your subject was a little misleading to me, I really thought you wanted to fsck a remote fs.

Well I think cifs is available on MOST linux systems, but it is often there as a module. You could check by the following procedure:

Code:
HAVE_CIFS=no
grep -q cifs /proc/filesystems && HAVE_CIFS=yes
/sbin/modinfo cifs &>/dev/null && HAVE_CIFS=yes

if [ "x$HAVE_CIFS" = "xyes" ]; then
  ...
fi
The first line checks whether cifs is currently available as filesystem, the second line checks whether the loadable kernel module is there -- in both cases, cifs will be usable on this box.
above code doesnt help as when i checked with cisssfs which should not exists in /proc/filesystems ,i got wrong output.

Code:
# echo $HAVE_CIFS
yes
[root@TomcatServer /]# grep -q cisssfs /proc/filesystems && HAVE_CIFS=no
[root@TomcatServer /]# echo $HAVE_CIFS
yes
 
Old 07-28-2010, 04:34 AM   #4
zirias
Member
 
Registered: Jun 2010
Posts: 361

Rep: Reputation: 59
This is why HAVE_CIFS is set to "no" in the first line!

PS: Maybe read up a little on shell scripting: The command after && is ONLY executed when the command preceding it returned successful. The script WILL work like presented in my first post.

Last edited by zirias; 07-28-2010 at 04:38 AM.
 
Old 07-28-2010, 05:08 AM   #5
pinga123
Member
 
Registered: Sep 2009
Posts: 684
Blog Entries: 2

Original Poster
Rep: Reputation: 36
Quote:
Originally Posted by zirias View Post
This is why HAVE_CIFS is set to "no" in the first line!

PS: Maybe read up a little on shell scripting: The command after && is ONLY executed when the command preceding it returned successful. The script WILL work like presented in my first post.
thank for the information however i have one doubt in my mind.

what is the difference between
Code:
"x$HAVE_CIFS" = "xyes"
and
Code:
"$HAVE_CIFS" = "yes"
 
Old 07-28-2010, 05:41 AM   #6
zirias
Member
 
Registered: Jun 2010
Posts: 361

Rep: Reputation: 59
The first won't break with versions of "test" that don't deal with emtpy strings correctly. Although $HAVE_CIFS can't be empty in THIS script, I just ALWAYS use the "safe" version.
 
Old 07-28-2010, 11:20 PM   #7
pinga123
Member
 
Registered: Sep 2009
Posts: 684
Blog Entries: 2

Original Poster
Rep: Reputation: 36
Quote:
Originally Posted by zirias View Post
The first won't break with versions of "test" that don't deal with emtpy strings correctly. Although $HAVE_CIFS can't be empty in THIS script, I just ALWAYS use the "safe" version.
Thanks for your helpful suggestion now onward i will always use the safe method.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
recursive write permission on cifs mounted file system mamunbabu2001 Linux - Newbie 2 05-18-2010 09:23 AM
[SOLVED] VirtualBox: WXP guest loses CIFS file system when real net cable unplugged catkin Linux - Virtualization and Cloud 4 02-12-2010 02:31 AM
An error Occurred during the file system check. Dropping you to shell; the system wil aneikei Linux - Newbie 3 02-11-2010 08:38 PM
Moved file partitions, File system check failed on Fedora, Windows will not boot LinkSlayer64 Linux - Newbie 7 12-17-2009 03:18 AM
using apache file viewer / webdav, logical links and cifs file system zerobane Linux - Server 0 03-23-2009 12:10 PM


All times are GMT -5. The time now is 05:56 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration