LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-08-2010, 02:35 PM   #1
thinke365
LQ Newbie
 
Registered: Dec 2009
Posts: 3

Rep: Reputation: 0
problems encountered when read vsftpd code


the version of vsftpd i read is 1.2.1, i find the following code in main.c:

struct vsf_sysutil_statbuf* p_statbuf = 0;

but i cannot find the definition of this structure.
then anybody here can tell me what is the definition of vsf_sysutil_statbuf struct?
thank you
 
Old 06-08-2010, 04:12 PM   #2
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
It's part of the vsftpd source.

Either you didn't get the complete source package, or you're not looking in the right place:

1. Search for all the #include files in your .c program

2. Search for all of the corresponding .h files in your source tree and/or filesystem.

3. Failing all else, download a different copy of the vsftpd source package.
 
0 members found this post helpful.
Old 06-08-2010, 04:18 PM   #3
thinke365
LQ Newbie
 
Registered: Dec 2009
Posts: 3

Original Poster
Rep: Reputation: 0
i find its forward declaration now, in sysstr.h,
but there is no concrete definiton for this structure, i am confused about this ...

struct vsf_sysutil_statbuf;
 
Old 06-08-2010, 11:12 PM   #4
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Thumbs down

So you marked the post "not helpful" just because YOU can't find the definition?

I'm confused about THAT

Good luck .. PSM
 
Old 06-09-2010, 12:25 AM   #5
thinke365
LQ Newbie
 
Registered: Dec 2009
Posts: 3

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by paulsm4 View Post
So you marked the post "not helpful" just because YOU can't find the definition?

I'm confused about THAT

Good luck .. PSM
since i have tried that before you told me, so that is not so helpful, i am sorry if you mind that, this is the first time i use recommand function this forum provides

i have tried google codesearch, still not find that definition, maybe this is an confusing "forward definition" trick, i don't know, why there is no concrete definition?
 
Old 06-09-2010, 10:50 AM   #6
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Hi -

1. I downloaded and examined the VSFTP source:
Code:
wget ftp://vsftpd.beasts.org/users/cevans/vsftpd-2.3.0pre2.tar.gz

tar xvzf vsftpd-2.3.0pre2.tar.gz

cd vs*pre2

grep vsf_sysutil_statbuf *|less =>
  sysutil.h
  sysutil.c
  <= these are the VSFTP modules that "define" vsf_sysutil_statbuf
2. I found exactly the same "definition" as you've been seeing:
Code:
less sysutil.h =>
struct vsf_sysutil_statbuf;
  <= Nothing but a forward definition...
3. So I looked at how it's being used:
Code:
less sysutil.c =>
int
vsf_sysutil_stat(const char* p_name, struct vsf_sysutil_statbuf** p_ptr)
{
  vsf_sysutil_alloc_statbuf(p_ptr);
  return stat(p_name, (struct stat*) (*p_ptr));
}
...
static void
vsf_sysutil_alloc_statbuf(struct vsf_sysutil_statbuf** p_ptr)
{
  if (*p_ptr == NULL)
  {
    *p_ptr = vsf_sysutil_malloc(sizeof(struct stat));
  }
}
...
Soooooooo.......

1. vsf_sysutil_statbuf is nothing more than a wrapper around the OS's "stat" struct.

2. vsf_sysutil_alloc_statbuf() only allocates memory once (and re-uses the memory if it's already been allocated)

3. The whole scheme "insulates" the rest of the VSFTP code from "stat" being different on different OS's. All of the "details" are encapsulated entirely within sysutil.c

'Hope that helps.. PSM
 
  


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
vsftpd read-only/write per user. arashi256 Linux - Software 2 01-26-2009 07:04 PM
Tried to update MySQL, but then encountered problems unmet dependencies, and others. Spreegem Debian 4 01-10-2007 12:09 PM
vsftpd won't read vsftpd.conf m2azer Linux - Software 9 04-21-2006 03:25 PM
Display problems encountered when using IC 5.0 under RH 7.2 walker8764 Linux - Software 2 02-20-2006 05:43 AM
vsftpd local users read-only fluffyvoidbunny Linux - Networking 2 02-07-2006 11:55 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:08 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
Open Source Consulting | Domain Registration