Re: sysctl hacks

2004-08-22 Thread Alfred Perlstein
* Poul-Henning Kamp [EMAIL PROTECTED] [040821 13:29] wrote:
 In message [EMAIL PROTECTED], Alfred Perlstein writes:
 I'm doing some work that requires that I have a sysctl structure
 be passed around, but inside that structure are several pointers I
 may need to dereference.
 
 Basically:
 
 struct mysysctldata {
 (data here)
void *moredata;
size_t morelen;
 };
 
 What is the proper way of sysctl'ing IN the data from moredata?
 
 I need to make a copy of the sysctl req, but... I'm not sure what
 to initialize the 'lock' member to.
 
 Just use the SYSCTL_IN() and ..._OUT() functions.

:(

I wasn't clear.

I have a sysctl node that takes a struct like so:

struct mysysctldata {
   (data here)
  struct moredata * vc_ptr;
  size_t len vc_len;
}

If I use SYSCTL_IN(), then I can get mysysctldata, but I only
get the pointer to moredata, now I want to get a copy of 
moredata, what's a good way to do this?

I have a macro that does this:

#define VCTLTOREQ(vc, req)  \
do {\
(req)-newptr = (vc)-vc_ptr;   \
(req)-newlen = (vc)-vc_len;   \
(req)-newidx = 0;  \
} while (0)

Is that right?


-- 
- Alfred Perlstein
- Research Engineering Development Inc.
- email: [EMAIL PROTECTED] cell: 408-480-4684
___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: sysctl hacks

2004-08-22 Thread John-Mark Gurney
Alfred Perlstein wrote this message on Sat, Aug 21, 2004 at 23:47 -0700:
 * Poul-Henning Kamp [EMAIL PROTECTED] [040821 13:29] wrote:
  In message [EMAIL PROTECTED], Alfred Perlstein writes:
  I'm doing some work that requires that I have a sysctl structure
  be passed around, but inside that structure are several pointers I
  may need to dereference.
  
  Basically:
  
  struct mysysctldata {
  (data here)
 void *moredata;
 size_t morelen;
  };
  
  What is the proper way of sysctl'ing IN the data from moredata?
  
  I need to make a copy of the sysctl req, but... I'm not sure what
  to initialize the 'lock' member to.
  
  Just use the SYSCTL_IN() and ..._OUT() functions.
 
 :(
 
 I wasn't clear.
 
 I have a sysctl node that takes a struct like so:
 
 struct mysysctldata {
    (data here)
   struct moredata * vc_ptr;
   size_t len vc_len;
 }
 
 If I use SYSCTL_IN(), then I can get mysysctldata, but I only
 get the pointer to moredata, now I want to get a copy of 
 moredata, what's a good way to do this?
 
 I have a macro that does this:
 
 #define VCTLTOREQ(vc, req)\
   do {\
   (req)-newptr = (vc)-vc_ptr;   \
   (req)-newlen = (vc)-vc_len;   \
   (req)-newidx = 0;  \
   } while (0)
 
 Is that right?

After reading the sysctl code, it appears that you can't do that..
SYSCTL_IN only lets you read serially from the buffer passed in...  so
you have to have all the data serially in userland...  once you do a
SYSCTL_IN of x bytes of data, the pointer is updated to skip those x,
and the next call will read in the bytes following the first read...

Hope this helps.

-- 
  John-Mark Gurney  Voice: +1 415 225 5579

 All that I will do, has been done, All that I have, has not.
___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: sysctl hacks

2004-08-22 Thread Alfred Perlstein
* John-Mark Gurney [EMAIL PROTECTED] [040822 00:18] wrote:
 Alfred Perlstein wrote this message on Sat, Aug 21, 2004 at 23:47 -0700:
  
  I have a sysctl node that takes a struct like so:
  
  struct mysysctldata {
 (data here)
struct moredata * vc_ptr;
size_t len vc_len;
  }
  
  If I use SYSCTL_IN(), then I can get mysysctldata, but I only
  get the pointer to moredata, now I want to get a copy of 
  moredata, what's a good way to do this?
  
  I have a macro that does this:
  
  #define VCTLTOREQ(vc, req)  \
  do {\
  (req)-newptr = (vc)-vc_ptr;   \
  (req)-newlen = (vc)-vc_len;   \
  (req)-newidx = 0;  \
  } while (0)
  
  Is that right?
 
 After reading the sysctl code, it appears that you can't do that..
 SYSCTL_IN only lets you read serially from the buffer passed in...  so
 you have to have all the data serially in userland...  once you do a
 SYSCTL_IN of x bytes of data, the pointer is updated to skip those x,
 and the next call will read in the bytes following the first read...
 
 Hope this helps.

Yes, but you can update the sysctlreq struct's newptr, newlen and
newidx to point to the auxiliary data as my macro does, I just
wanted to make sure I wasn't missing some subtle point of the
how sysctl works.

-- 
- Alfred Perlstein
- Research Engineering Development Inc.
- email: [EMAIL PROTECTED] cell: 408-480-4684
___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


sysctl hacks

2004-08-21 Thread Alfred Perlstein
I'm doing some work that requires that I have a sysctl structure
be passed around, but inside that structure are several pointers I
may need to dereference.

Basically:

struct mysysctldata {
    (data here)
   void *moredata;
   size_t morelen;
};

What is the proper way of sysctl'ing IN the data from moredata?

I need to make a copy of the sysctl req, but... I'm not sure what
to initialize the 'lock' member to.

Any hints would be appeciated.



-- 
- Alfred Perlstein
- Research Engineering Development Inc.
- email: [EMAIL PROTECTED] cell: 408-480-4684
___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: sysctl hacks

2004-08-21 Thread Poul-Henning Kamp
In message [EMAIL PROTECTED], Alfred Perlstein writes:
I'm doing some work that requires that I have a sysctl structure
be passed around, but inside that structure are several pointers I
may need to dereference.

Basically:

struct mysysctldata {
    (data here)
   void *moredata;
   size_t morelen;
};

What is the proper way of sysctl'ing IN the data from moredata?

I need to make a copy of the sysctl req, but... I'm not sure what
to initialize the 'lock' member to.

Just use the SYSCTL_IN() and ..._OUT() functions.

-- 
Poul-Henning Kamp   | UNIX since Zilog Zeus 3.20
[EMAIL PROTECTED] | TCP/IP since RFC 956
FreeBSD committer   | BSD since 4.3-tahoe
Never attribute to malice what can adequately be explained by incompetence.
___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]