Re: Porting from Linux to FreeBSD (procfs question)
On Fri, 4 Jan 2008, [EMAIL PROTECTED] wrote: Also, have you considered procstat ? (as i read here: http://ivoras.sharanet.org/freebsd/freebsd8.html it is destined to replace procfs in a way, am I wrong ?) Depending on how short term your application must be available (and how long it will take to MFC procstat), it might do the thing. Not really related to the thread in a general sense, but: I do plan to MFC procstat, probably in February or March. I will definitely MFC it to 7.x, and I may also MFC it to 6.x. Robert N M Watson Computer Laboratory University of Cambridge ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: Porting from Linux to FreeBSD (procfs question)
Fernando Apesteguía [EMAIL PROTECTED] writes: Dag-Erling Smørgrav [EMAIL PROTECTED] writes: Fernando Apesteguía [EMAIL PROTECTED] writes: I have an application written in C + Gtk + Glib that gathers information from procfs under Linux. Now, I'm trying to port this application to FreeBSD (I'm working with 7.0 RC1). man linprocfs Yes, I checked it. But although the cpuinfo file is quite close to the original one in Linux, there are other important files missed. Have you checked that the missing files aren't in linsysfs? If they aren't, submit a PR and maybe the lin{proc,sys}fs maintainers (or somebody else) will add them. This is really the least-effort solution for you (less code to modify), and it will also benefit native Linux binaries running under the linuxulator. While you're at it, please also submit a PR pointing out that the linprocfs(5) man page is lagging behind the code... DES -- Dag-Erling Smørgrav - [EMAIL PROTECTED] ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: Porting from Linux to FreeBSD (procfs question)
Quoting Fernando Apesteguía [EMAIL PROTECTED]: Maybe a mix of both could be good: use the linxprocfs when it is almost straightforward (in fact I could run the app, just changing few lines) and sysctl when the linprocfs doesn't provide the information that I need. Wouldn't the opposite be more legitimate: using sysctl and falling back on linuxprocfs when lacking functionality ? (Depending on whether it's a FreeBSD *port*, or if you want to keep it as general as you can) Also, have you considered procstat ? (as i read here: http://ivoras.sharanet.org/freebsd/freebsd8.html it is destined to replace procfs in a way, am I wrong ?) Depending on how short term your application must be available (and how long it will take to MFC procstat), it might do the thing. ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: Porting from Linux to FreeBSD (procfs question)
Quoting Fernando Apesteguía [EMAIL PROTECTED]: Maybe a mix of both could be good: use the linxprocfs when it is almost straightforward (in fact I could run the app, just changing few lines) and sysctl when the linprocfs doesn't provide the information that I need. And I just made a fool of myself by mistaking procfs for linprocfs: ooops, awfully sorry :-( ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: Porting from linux to FreeBSD (procfs question)
On 03/01/2008, Fernando Apesteguía [EMAIL PROTECTED] wrote: Yes, that's my problem. In Linux I can get from /proc/cpuinfo for example: name, model, stepping, cache size, clock speed, supported extensions, etc... But using sysctl in FreeBSD (sysctl -a) I can only see name and vendor for the cpu and a few more things. Am I limited to the variables showed in sysctl -a? Probably. I don't know if there's anything that can give you the details present in cpuinfo (except using CPUID data directly). Thanks in advance. BTW if this is isn't the proper list to continue with this thread, let me know. Maybe hackers@ would help you more. ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: Porting from linux to FreeBSD (procfs question)
On Thu, Jan 03, 2008 at 05:16:42PM +0100, Ivan Voras wrote: On 03/01/2008, Fernando Apesteguía [EMAIL PROTECTED] wrote: Yes, that's my problem. In Linux I can get from /proc/cpuinfo for example: name, model, stepping, cache size, clock speed, supported extensions, etc... But using sysctl in FreeBSD (sysctl -a) I can only see name and vendor for the cpu and a few more things. Am I limited to the variables showed in sysctl -a? Probably. I don't know if there's anything that can give you the details present in cpuinfo (except using CPUID data directly). Best bet is parsing or using the hw.model sysctl, or if you need lower-level information, there is a port that apparently gets cache size and other data. There are very few things I liked about Linux /proc when I used it, but getting h/w information happened to be one of them... -- | Jeremy Chadwickjdc at parodius.com | | Parodius Networking http://www.parodius.com/ | | UNIX Systems Administrator Mountain View, CA, USA | | Making life hard for others since 1977. PGP: 4BD6C0CB | ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to [EMAIL PROTECTED]
Porting from Linux to FreeBSD (procfs question)
Hi all, I post my question in this list cause Ivan Voras ([EMAIL PROTECTED]) suggested that here I could find more help. I have an application written in C + Gtk + Glib that gathers information from procfs under Linux. Now, I'm trying to port this application to FreeBSD (I'm working with 7.0 RC1). I've been pointed to get rid of the procfs stuff in the freebsd code and use sysctl instead. However, I can't find some of the information that is present under /proc in Linux. I can only get for the CPU for instance some small bits of info in hw.model but I can't get the cache size, supported extensions, etc. I have the same problem with the memory (how much memory is cached, in buffers, marked as dirty, etc...). How can I get all that information? Could you point me to some source I can look at? Is this information (that I suppose it is known by the kernel) somehow exported to userland? Here is a small list of the information the Linux application is available to show: - CPU info: (vendor, model, clock speed, stepping, cache size, supported extensions) - Memory: total, free, shared, cached, used in buffers, marked as dirty, etc.. - Devices: list of block and char devices - Filesystems loaded in the kernel - Network information (bytes sent and received, packets, errors, for each NIC) - Loaded modules (sizes of the modules, if they are used by other modules...) - Some kernel parameters (max files per process, semaphores, etc...) I've seen this is fully covered with sysctl. Thanks in advance and Happy New Year. ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: Porting from Linux to FreeBSD (procfs question)
On Thu, Jan 03, 2008 at 06:26:21PM +0100, Fernando Apestegu?a wrote: Hi all, I post my question in this list cause Ivan Voras ([EMAIL PROTECTED]) suggested that here I could find more help. I have an application written in C + Gtk + Glib that gathers information from procfs under Linux. Now, I'm trying to port this application to FreeBSD (I'm working with 7.0 RC1). I've been pointed to get rid of the procfs stuff in the freebsd code and use sysctl instead. However, I can't find some of the information that is present under /proc in Linux. I can only get for the CPU for instance some small bits of info in hw.model but I can't get the cache size, supported extensions, etc. I have the same problem with the memory (how much memory is cached, in buffers, marked as dirty, etc...). How can I get all that information? Could you point me to some source I can look at? Is this information (that I suppose it is known by the kernel) somehow exported to userland? Here is a small list of the information the Linux application is available to show: - CPU info: (vendor, model, clock speed, stepping, cache size, supported extensions) See misc/cpuid for a port that extracts this from the CPU. To some extent it would be better if the kernel did this because it can better know which CPU it's on, but this does most of it. - Memory: total, free, shared, cached, used in buffers, marked as dirty, etc.. You can't get a perfect mapping do these because we have different virtual memory systems. The continued delusion that any of this is comparable between OSes is a pet peeve of mine. :) The sysutils/ganglia-monitor-core port does some of this (search for freebsd.c). - Devices: list of block and char devices ls /dev :-) - Filesystems loaded in the kernel lsvfs(1) reports this information. - Network information (bytes sent and received, packets, errors, for each NIC) See ganglia. - Loaded modules (sizes of the modules, if they are used by other modules...) see kldstat(8) - Some kernel parameters (max files per process, semaphores, etc...) I've seen this is fully covered with sysctl. -- Brooks pgpciLAjvh8bb.pgp Description: PGP signature
Re: Porting from Linux to FreeBSD (procfs question)
Fernando Apesteguía [EMAIL PROTECTED] writes: I have an application written in C + Gtk + Glib that gathers information from procfs under Linux. Now, I'm trying to port this application to FreeBSD (I'm working with 7.0 RC1). man linprocfs DES -- Dag-Erling Smørgrav - [EMAIL PROTECTED] ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: Porting from Linux to FreeBSD (procfs question)
On Jan 3, 2008 8:50 PM, Dag-Erling Smørgrav [EMAIL PROTECTED] wrote: Fernando Apesteguía [EMAIL PROTECTED] writes: I have an application written in C + Gtk + Glib that gathers information from procfs under Linux. Now, I'm trying to port this application to FreeBSD (I'm working with 7.0 RC1). man linprocfs Yes, I checked it. But although the cpuinfo file is quite close to the original one in Linux, there are other important files missed. That's because I'm trying to find the best approach. Maybe a mix of both could be good: use the linxprocfs when it is almost straightforward (in fact I could run the app, just changing few lines) and sysctl when the linprocfs doesn't provide the information that I need. Cheers DES -- Dag-Erling Smørgrav - [EMAIL PROTECTED] ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: Porting from Linux to FreeBSD (procfs question)
Fernando Apesteguía wrote: Maybe a mix of both could be good: use the linxprocfs when it is almost straightforward (in fact I could run the app, just changing few lines) and sysctl when the linprocfs doesn't provide the information that I need. Also, linprocfs is never mounted by default - this might or might not be an obstacle, depending on how user-friendly the application is (asking desktop users to alter their fstabs may be asking too much :) ). signature.asc Description: OpenPGP digital signature
Re: Porting from Linux to FreeBSD (procfs question)
On Jan 3, 2008 9:53 PM, Ivan Voras [EMAIL PROTECTED] wrote: Fernando Apesteguía wrote: Maybe a mix of both could be good: use the linxprocfs when it is almost straightforward (in fact I could run the app, just changing few lines) and sysctl when the linprocfs doesn't provide the information that I need. Also, linprocfs is never mounted by default - this might or might not be an obstacle, depending on how user-friendly the application is (asking desktop users to alter their fstabs may be asking too much :) ). I hadn't thought about it... but it's quite to the point. Maybe it makes no sense to ask for a particular filesystem from a graphical Gnome application... ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: Porting from linux to freebsd help needed
Hi All, I wanted to add a psuedo network driver can any one tell me what else needs to be done here to provide a simple psuedo interface test_modevent(module_t mod, int type, void *data) { switch (type) { case MOD_LOAD: uprintf(The psuedo driver loaded\n); //attach a ifnet structure ip=(struct inet *)malloc(sizeof(struct ifnet),M_DEVBUF,M_WAITOK); ip-if_dname=test; ip-if_flags = IFF_UP| IFF_RUNNING| IFF_POINTOPOINT | IFF_MULTICAST | IFF_NEEDSGIANT; ip-if_ioctl = test_sioctl; ip-if_start = test_ifstart; ip-if_watchdog = test_ifwatchdog; ip-if_init = test_initialize; strlcpy(ip-if_xname, test,5); if_attach (ip); break; case MOD_UNLOAD: uprintf(test_ps module unload - not possible for this module type\n); if_detach (ip); free(ip,M_DEVBUF); return EINVAL; default: return EOPNOTSUPP; } return 0; } Thanks and Regards, Rashmi.N.S ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: [BUGI] Re: Porting from linux to freebsd help needed
On 13.09-10:16, rashmi ns wrote: [ ... ] I wanted to add a psuedo network driver can any one tell me what else needs to be done here to provide a simple psuedo interface not to repeat what david said but look at /usr/src/sys/net/if_disc.c for information. the code supplied is only enough to handle the module loading -- nothing to do with network interfaces (except that they may also be modules). most of the magic is handled by the macro definitions and kernel callbacks. if you're really stuck try posting the full source. if you are looking to implement a pseudo device you may wish to look at netgraph -- i have no experience of it but rumour suggests it is an effective way to stack protocol handlers, drivers and other network magic. -- t t w ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to [EMAIL PROTECTED]
porting from linux
Hi, I'm trying to track down a problem in the netsaint-plugins plugin check_snmp. It partially works, but if check_snmp is given more than one OID, it bombs out with a failure in strscat. Apparently strscat comes from utils.c which is linked with check_snmp.c. The error generally looks like this: bash-2.05a# /usr/local/libexec/netsaint/check_snmp -H localhost -C -o .1.3.6.1.4.1.2021.10.1.5.1,.1.3.6.1.4.1.2021.10.1.5.2,.1.3.6.1.4.1.2021.10.1.5.3 -w :1,:2,:3 -c :5,:10,:20 -l load check_snmp in free(): warning: chunk is already free check_snmp in realloc(): warning: chunk is already free failed malloc in strscat I'm guessing that since netsaint is developed on Linux, I'm running into some odd linux-ism. I did a send-pr on the port and contacted the port maintainer, but I thought maybe I'd find someone here who would like to tinker. The port of the netsaint-plugins is under /usr/ports/net. FWIW, here's the strscat function in utils.c: /** * * Concatenates one string to the end of another * * Given a pointer destination string, which may or may not already * hold some text, and a source string with additional text (possibly * NULL or empty), returns a pointer to a string that is the first * string with the second concatenated to it. Uses realloc to free * memory held by the dest argument if new storage space is required. * * Example: * * char *str=NULL; * str = strscpy(This is a line of text with no trailing newline); * str = strscat(str,\n); * */ char *strscat(char *dest, const char *src) { int len,l2; if (src) l2 = strlen (src); else return dest; if (dest) len = strlen (dest); else len = 0; dest = realloc (dest, len + l2 + 1); if (dest == NULL) terminate (STATE_UNKNOWN, failed malloc in strscat\n); strncpy (dest + len, src, l2); dest[len + l2] = 0; return dest; } And the call to strscat in check_snmp: while (fgets(input_buffer, MAX_INPUT_BUFFER - 1, child_process)) output = strscat(output, input_buffer); --- if (ptr strstr(ptr, delimiter) == NULL) { response = strscat(response, ptr); ptr = NULL; --- I'm not a C person at all. I wish this had just been written in perl :) FWIW, I found some general porting guidelines on the net, but most of them in talking about free(), malloc(), and realloc() just mention that you shouldn't be including malloc.h, and this does not. Any help is appreciated. PR is: http://www.freebsd.org/cgi/query-pr.cgi?pr=39182 port maintainer is: [EMAIL PROTECTED] Thanks for any help! Charles To Unsubscribe: send mail to [EMAIL PROTECTED] with unsubscribe freebsd-hackers in the body of the message