Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NBD: add nbd_default_export config option #530

Merged
merged 1 commit into from Sep 6, 2021

Conversation

bignaux
Copy link
Member

@bignaux bignaux commented Sep 3, 2021

Pull Request checklist

Note: these are not necessarily requirements

  • I reformatted the code with clang-format
  • I checked to make sure my submission worked
  • I am the author of submission or have permission from the original author
  • Requires update of the PS2SDK
  • Requires update of the gsKit
  • Others (please specify below)

Pull Request description

  • Allow to set nbd_default_export=mc0 in conf_network.cfg to be exported by default.

@bignaux bignaux changed the title NBD: add gdefaultexport config option NBD: add nbd_default_export config option Sep 3, 2021
@rickgaiser
Copy link
Member

Check the formatting (clang-format). Running make format will also format all code.

@bignaux
Copy link
Member Author

bignaux commented Sep 3, 2021

@rickgaiser : i don't understand because i wrote the .clang-format-ignore for this file previous PR. now it seems it didn't work, i think the easiest way i stop wasting time on that, nbd-protocol.h will be formated OPL side, in a purist way i'd have keep this verbatim from nbdkit, noone care after all. I was in a hurry because i want that code for the week end, since someone could release a memorycard driver this day, and i'd to offer him a way to have user without much hard work on the protocol, that is not yet ready. I think i've more priority on my todolist.

EDIT : the scheme i try to break first, is people thinking nbd is for hdd, no and mc driver let people imagine write other drivers. Then nbd is not for device only, and it should really be more known. When i see code for ps2ident, i think, hey guy, divide by 10 or more we have dump via ethernet ...

@AKuHAK
Copy link
Member

AKuHAK commented Sep 4, 2021

@bignaux you have issues not in header file but in source file:
--- ./modules/network/lwnbdsvr/lwnbdsvr.c (original)
+++ ./modules/network/lwnbdsvr/lwnbdsvr.c (reformatted)

@bignaux
Copy link
Member Author

bignaux commented Sep 5, 2021

Oki, i moved files to prepare integration in ps2sdk, quite all files are now in the lwnbd repo, and i forget to change path in .clang-format-ignore . Fixed.

Copy link
Member

@rickgaiser rickgaiser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain a bit what the use of CONFIG_NET_NBD_DEFAULT_EXPORT is to a user? What happens if I set it? What should I set it to? Can I still use NBD if I don't set it? Is it for supporting multiple devices? Etc...

@@ -1401,7 +1404,7 @@ static int loadLwnbdSvr(void)
if (ret == 0) {
ret = sysLoadModuleBuffer(&ps2atad_irx, size_ps2atad_irx, 0, NULL);
if (ret >= 0) {
ret = sysLoadModuleBuffer(&lwnbdsvr_irx, size_lwnbdsvr_irx, 0, NULL);
ret = sysLoadModuleBuffer(&lwnbdsvr_irx, size_lwnbdsvr_irx, 4, (char *)&gExportName);
Copy link
Member

@rickgaiser rickgaiser Sep 5, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is 4 correct here? Shouldn't this be 32 or sizeof(gExportName) ?

EDIT: Shouldn't &gExportName also be gExportName (without the &)

@@ -191,6 +191,7 @@ unsigned char gDefaultUITextColor[3];
hdl_game_info_t *gAutoLaunchGame;
char gOPLPart[128];
char *gHDDPrefix;
char gExportName[32];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This new parameter does not have a default value, and is also never initialized. Shouldn't this be at least initialized to 0?

@bignaux
Copy link
Member Author

bignaux commented Sep 6, 2021

Currently, lwNBD only support old style handshake, so it can't export multiple device and choose it client-side. The only way to use a different device that the hdd0 hardcoded, is to launched it with a default nbd_default_export that is passed to the init() of the server. It could be later change in a callback and have a UI in opl to configure it (but need a callback to get the name of the exports). I did this quickly to allow a contributor to have an easy way to fix his driver, i tested it quickly that was not intented to be documented and used immediatly.

Now a big step will be to rewrite the nbd server with event loop based on select().

@rickgaiser
Copy link
Member

Alright, this was your last change for the v1.1 release ;).

@rickgaiser rickgaiser merged commit 3d3fc4c into ps2homebrew:master Sep 6, 2021
@bignaux
Copy link
Member Author

bignaux commented Sep 6, 2021

hey @rickgaiser i was not forget your review ! but since i don't have good answer right now, you know, i've plan in mind, but people can't guess it. This workaround will be checked, like i'd remove all the printf today according to @AKuHAK previous review.

// int ata_device_sce_identify_drive(int device, void *data);
strcpy(me->super.export_desc, "PlayStation 2 HDD via ATAD");
sprintf(me->super.export_name, "%s%d", "hdd", me->device);
me->super.blocksize = 512;
me->super.buffer = nbd_buffer;
me->super.eflags = NBD_FLAG_HAS_FLAGS;
me->super.eflags = NBD_FLAG_HAS_FLAGS | NBD_FLAG_SEND_FLUSH;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NBD_FLAG_SEND_FLUSH was not functional (no server reply).

AKuHAK pushed a commit that referenced this pull request Sep 30, 2021
NBD: add nbd_default_export config option
citronalco pushed a commit to citronalco/OPL-Daily-Builds that referenced this pull request Sep 10, 2023
NBD: add nbd_default_export config option
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants