Re: [systemd-devel] Scan all USB devices from Linux service

2024-02-15 Thread Andy Pieters
On Thu, 15 Feb 2024 at 13:12, Greg KH  wrote:

> On Thu, Feb 15, 2024 at 12:04:27PM +, Andy Pieters wrote:
> > On Thu, 15 Feb 2024 at 09:12, Greg KH  wrote:
> >
> > >
> > > provenance matters HUGELY when it comes to code, as you need a license
> > > and other things as well (copyright law is strict.)  "AI generated"
> code
> > > has none of that and as such, can NOT be used for almost any use until
> > > that is sorted out.
> > >
> > > Just go talk to your lawyer about the issues involved please if you
> have
> > > any questions, it's not trivial.
> > >
> > > thanks,
> > >
> > > greg k-h
> > >
> >
> > I think you're moving the goalpost here by now invoking copyright law.
>
> Nope!
>
>
OK the original reply I sent was to the message Reto:

> Let's keep responses based on human interaction shall we, rather than
> parroting

math models.


To which I said,

> Comment on the code itself, what origin matter etc


But then you start talking about copyright, so that's why I feel the
goalpost was moved.



> > All I'm saying is, don't blanket ban code just because it is AI
> > 'generated'. The guy disclosed it even.
>
> And as such, you can not trust it nor use it for anything at all as
> again, the copyright and license of it is unknown and probably violates
> everyone's policies.
>

Ok, I'll byte this time. If this *were* copyrighted code would we be
breaking copyright by including it in this mailing list?
 Maybe, and since none of us has actually embedded the code in our replies,
I think only the original poster would be in jeopardy (but see [1])

Would we break copyright by discussing the code and suggesting fixes or
analysing it?
 I think not, fair use says critique is allowed, and analysing and
suggesting fixes squarely makes it critique.
 So if we were to look at the code and quote bits and pieces of it saying
'this is rubish, do it this way instead' it would fall under fair use
doctrine.

Granted, and I'm not a lawyer, but I don't think any of this really applies
to this case anyway, because of this ruling [1]

[1]
https://www.spiceworks.com/tech/artificial-intelligence/news/us-copyright-law-ai-generated-content
"U.S. Federal Judge Exempts AI-Created Content from Copyright
United States District Court Judge Beryl A. Howell said creative direction
and control through human involvement is essential to include it under
copyright law. "
>From April 2023


Re: [systemd-devel] Scan all USB devices from Linux service

2024-02-15 Thread Greg KH
On Thu, Feb 15, 2024 at 12:04:27PM +, Andy Pieters wrote:
> On Thu, 15 Feb 2024 at 09:12, Greg KH  wrote:
> 
> >
> > provenance matters HUGELY when it comes to code, as you need a license
> > and other things as well (copyright law is strict.)  "AI generated" code
> > has none of that and as such, can NOT be used for almost any use until
> > that is sorted out.
> >
> > Just go talk to your lawyer about the issues involved please if you have
> > any questions, it's not trivial.
> >
> > thanks,
> >
> > greg k-h
> >
> 
> I think you're moving the goalpost here by now invoking copyright law.

Nope!

> All I'm saying is, don't blanket ban code just because it is AI
> 'generated'. The guy disclosed it even.

And as such, you can not trust it nor use it for anything at all as
again, the copyright and license of it is unknown and probably violates
everyone's policies.

So it shouldn't even be posted as an example.

thanks,

greg k-h


Re: [systemd-devel] Scan all USB devices from Linux service

2024-02-15 Thread Andy Pieters
On Thu, 15 Feb 2024 at 09:12, Greg KH  wrote:

>
> provenance matters HUGELY when it comes to code, as you need a license
> and other things as well (copyright law is strict.)  "AI generated" code
> has none of that and as such, can NOT be used for almost any use until
> that is sorted out.
>
> Just go talk to your lawyer about the issues involved please if you have
> any questions, it's not trivial.
>
> thanks,
>
> greg k-h
>

I think you're moving the goalpost here by now invoking copyright law.

All I'm saying is, don't blanket ban code just because it is AI
'generated'. The guy disclosed it even.


Re: [systemd-devel] Scan all USB devices from Linux service

2024-02-15 Thread Greg KH
On Thu, Feb 15, 2024 at 08:45:41AM +, Andy Pieters wrote:
> On Thu, 15 Feb 2024 at 08:32, Reto  wrote:
> 
> > On Wed, Feb 14, 2024 at 05:56:31PM +0100, Vadim Lebedev wrote:
> > > This is what ChatGPT proposes:
> >
> > Can we like not...
> > If people want to ask a generative AI they do so on their own.
> >
> > Let's keep responses based on human interaction shall we, rather than
> > parroting
> > math models.
> >
> 
> 
> Respectfully, I disagree.
> 
> 
> Comment on the code itself, or suggest ways to improve it, but don't diss
> on it just because it was 'generated by AI'
> 
> What does the provenance matter? He's got a problem, he's doing some work
> towards solving it, why bar the submission just because you don't agree
> with its origins? (sounds familiar...)

provenance matters HUGELY when it comes to code, as you need a license
and other things as well (copyright law is strict.)  "AI generated" code
has none of that and as such, can NOT be used for almost any use until
that is sorted out.

Just go talk to your lawyer about the issues involved please if you have
any questions, it's not trivial.

thanks,

greg k-h


Re: [systemd-devel] Scan all USB devices from Linux service

2024-02-15 Thread Andy Pieters
On Thu, 15 Feb 2024 at 08:32, Reto  wrote:

> On Wed, Feb 14, 2024 at 05:56:31PM +0100, Vadim Lebedev wrote:
> > This is what ChatGPT proposes:
>
> Can we like not...
> If people want to ask a generative AI they do so on their own.
>
> Let's keep responses based on human interaction shall we, rather than
> parroting
> math models.
>


Respectfully, I disagree.


Comment on the code itself, or suggest ways to improve it, but don't diss
on it just because it was 'generated by AI'

What does the provenance matter? He's got a problem, he's doing some work
towards solving it, why bar the submission just because you don't agree
with its origins? (sounds familiar...)


Re: [systemd-devel] Scan all USB devices from Linux service

2024-02-15 Thread Reto
On Wed, Feb 14, 2024 at 05:56:31PM +0100, Vadim Lebedev wrote:
> This is what ChatGPT proposes:

Can we like not...
If people want to ask a generative AI they do so on their own.

Let's keep responses based on human interaction shall we, rather than parroting
math models.


Re: [systemd-devel] Scan all USB devices from Linux service

2024-02-14 Thread Vadim Lebedev
This is what ChatGPT proposes:
#include 
#include 

void scan_devices(const char* target_string) {
libusb_device **devs;
libusb_context *ctx = NULL;
int r;
ssize_t cnt;

r = libusb_init();
if (r < 0) return;

cnt = libusb_get_device_list(ctx, );
if (cnt < 0) return;

for (ssize_t i = 0; i < cnt; i++) {
libusb_device *dev = devs[i];
libusb_device_handle *handle = NULL;

if (libusb_open(dev, ) == 0) {
// Iterate through all configurations and interfaces
struct libusb_config_descriptor *config;
libusb_get_config_descriptor(dev, 0, );

for (int j = 0; j < config->bNumInterfaces; j++) {
const struct libusb_interface *inter =
>interface[j];
const struct libusb_interface_descriptor *interdesc =
>altsetting[0];
if (interdesc->iInterface) {
unsigned char buffer[256];
int len = libusb_get_string_descriptor_ascii(handle,
interdesc->iInterface, buffer, sizeof(buffer));
if (len > 0) {
printf("Interface %d: %s\n", j, buffer);
if (strcmp((char*)buffer, target_string) == 0) {
// Match found
printf("Match found for interface %d\n", j);
}
}
}
}
libusb_free_config_descriptor(config);
libusb_close(handle);
}
}

libusb_free_device_list(devs, 1);
libusb_exit(ctx);
}

int main() {
scan_devices("Particular String");
return 0;
}


On Wed, Feb 14, 2024 at 3:54 PM Muni Sekhar  wrote:

> HI all,
>
> USB devices can have multiple interfaces (functional units) that serve
> different purposes (e.g., data transfer, control, audio, etc.).
>
> Each interface can have an associated string descriptor (referred to
> as iInterface). The string descriptor provides a human-readable name
> or description for the interface.
>
> From user space service utility, How to scan all the USB devices
> connected to the system and read each interface string
> descriptor(iInterface)  and check whether it matches "Particular
> String" or not.
>
> The service program should trigger scanning all the USB devices on any
> USB device detection or removal. Can libusb be used for it?
>
> Any input would be appreciated.
>
> --
> Thanks,
> Sekhar
>


Re: [systemd-devel] Scan all USB devices from Linux service

2024-02-14 Thread Lennart Poettering
On Mi, 14.02.24 20:24, Muni Sekhar (munisekhar...@gmail.com) wrote:

> HI all,
>
> USB devices can have multiple interfaces (functional units) that serve
> different purposes (e.g., data transfer, control, audio, etc.).
>
> Each interface can have an associated string descriptor (referred to
> as iInterface). The string descriptor provides a human-readable name
> or description for the interface.
>
> >From user space service utility, How to scan all the USB devices
> connected to the system and read each interface string
> descriptor(iInterface)  and check whether it matches "Particular
> String" or not.

You can use sd-device.h, allocate an sd_device_enumerator_new(), then
apply some filter via sd_device_enumerator_add_match_sysattr() and
then enumerate through it via
sd_device_enumerator_get_device_first()/sd_device_enumerator_get_device_next().

Lennart

--
Lennart Poettering, Berlin


Re: [systemd-devel] Scan all USB devices from Linux service

2024-02-14 Thread Greg KH
On Wed, Feb 14, 2024 at 08:24:25PM +0530, Muni Sekhar wrote:
> HI all,
> 
> USB devices can have multiple interfaces (functional units) that serve
> different purposes (e.g., data transfer, control, audio, etc.).
> 
> Each interface can have an associated string descriptor (referred to
> as iInterface). The string descriptor provides a human-readable name
> or description for the interface.
> 
> >From user space service utility, How to scan all the USB devices
> connected to the system and read each interface string
> descriptor(iInterface)  and check whether it matches "Particular
> String" or not.

Just write some code to do so using either libusb, or your own sysfs
scanning logic or talk directly to all of the usb devices using usbfs.

> The service program should trigger scanning all the USB devices on any
> USB device detection or removal. Can libusb be used for it?

For detection/removal, no, libusb isn't for that.  udev can provide you
the needed callbacks to your code for that situation.

But what problem are you trying to solve that isn't already handled by
the kernel and userspace usb handling logic already?

good luck!

greg k-h


[systemd-devel] Scan all USB devices from Linux service

2024-02-14 Thread Muni Sekhar
HI all,

USB devices can have multiple interfaces (functional units) that serve
different purposes (e.g., data transfer, control, audio, etc.).

Each interface can have an associated string descriptor (referred to
as iInterface). The string descriptor provides a human-readable name
or description for the interface.

>From user space service utility, How to scan all the USB devices
connected to the system and read each interface string
descriptor(iInterface)  and check whether it matches "Particular
String" or not.

The service program should trigger scanning all the USB devices on any
USB device detection or removal. Can libusb be used for it?

Any input would be appreciated.

-- 
Thanks,
Sekhar