C code to reset all usb devices (because ubuntu laptop disables usb mouse after sleep)
Use consistent indentation
I don't know if the indentation style of the code you pasted here is as you wrote it, but if it looks the same in your code editor, you should definitely try to fix it and make it more consistent. I would not bother trying to fix this manually, instead use either code formatting functions of your editor, or use an external tool such as GNU indent, ClangFormat or Artistic Style to reformat your source code.
Return a non-zero exit code on error
When you encounter an error you call perror(), which is great, but then you let the program continue to run, and eventually you will always return 0. It would be better if your program would return a non-zero exit code when it has encountered an error, in particular return EXIT_FAILURE, which is declared in &lt;stdlib.h&gt;.
Don't hardcode the USB bus number
You only open USB bus 1. What if you attach your mouse to a different USB port, which might be on a different bus? I would make it so that the USB bus number has to be passed as a command line option. This makes the program a lot more flexible.
Beware of buffer overflows
While arguably the /dev/bus/usb pathnames can never be longer than 255 bytes, it is bad practice to make any assumptions. At the very least, make sure you never overflow this buffer, by using strncpy() and strncat() instead of strcpy() and strcat() (read the documentation of these functions carefully and be aware what happens if the destination buffer is not large enough to hold the input), or use snprintf(). However, there is another way to sidestep this issue entirely:
Avoid the need for concatenating paths
Instead of manipulating filename all the time, you can avoid all this by calling chdir() to go into the USB bus's directory, like so:
if (chdir(&quot;/dev/bus/usb/001/&quot;) == -1) {
    perror(&quot;Error accessing USB bus directory&quot;);
    return EXIT_FAILURE;
}

DIR *d = opendir(&quot;.&quot;);

if (!d) {
    perror(&quot;Error reading USB bus directory&quot;);
    return EXIT_FAILURE;
}

struct dirent *ent;

while ((ent = readdir(d)) != NULL) {
    int fd = open(ent-&gt;d_name, O_WRONLY);
    ...

Declare variables as close as possible to where they are used
In C99 and later, you can declare a variable anywhere. It is considered good practice to declare a variable close to where it is used, and ideally you also declare and initialize it in one go. I've used this in the example above.