Skip to content

Add flags when open file#7445

Merged
jmarantz merged 1 commit intoenvoyproxy:masterfrom
scw00:open_reconstruct
Aug 2, 2019
Merged

Add flags when open file#7445
jmarantz merged 1 commit intoenvoyproxy:masterfrom
scw00:open_reconstruct

Conversation

@scw00
Copy link
Contributor

@scw00 scw00 commented Jul 2, 2019

Add flags for open method. So user can use it with read only mode or write only mode.

  • Risk Level: Low
  • Testing: unit_tests (under linux platform)
  • Docs Changes: no docs change
  • Release Notes:
    [Optional Fixes #Issue] no issue
    [Optional Deprecated:]

@scw00 scw00 force-pushed the open_reconstruct branch 4 times, most recently from 94d066a to 72e0a14 Compare July 2, 2019 06:51
@scw00 scw00 force-pushed the open_reconstruct branch from 72e0a14 to 2b90a64 Compare July 2, 2019 07:55
@scw00
Copy link
Contributor Author

scw00 commented Jul 2, 2019

Hi, it seems the clang_tidy check run win32 implementation under linux platform. And I am not sure how to fix that.

/source/source/common/filesystem/win32/filesystem_impl.cc:2:10: error: 'io.h' file not found [clang-diagnostic-error]
#include <io.h>
         ^
Suppressed 2 warnings (1 in non-user code, 1 due to line filter).

@mattklein123
Copy link
Member

@scw00 thanks for the contribution. Can you describe the purpose of this change? AFAICT the new functionality is not used? Are you planning on a follow up change?

@scw00
Copy link
Contributor Author

scw00 commented Jul 4, 2019

Hi @mattklein123 . I am trying to implement the static file filter which return static file from local fs. But I didn't found any appropriate structure for reading a file. It is the first step to implement the opening method with reading only flag.

@scw00 scw00 force-pushed the open_reconstruct branch 3 times, most recently from 6c4d30f to f86d9b4 Compare July 7, 2019 01:24
@scw00
Copy link
Contributor Author

scw00 commented Jul 7, 2019

Updated. For using std::bitset and set default value to open method.

Copy link
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

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

Thanks, a few high level comments to get started. Please also check clang-tidy and format.

/wait

@scw00 scw00 force-pushed the open_reconstruct branch from f86d9b4 to 050e9fd Compare July 12, 2019 00:30
@scw00 scw00 force-pushed the open_reconstruct branch 6 times, most recently from 45d2bc7 to 80bdf02 Compare July 12, 2019 04:51
Copy link
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

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

Cool, thanks for working on this. A few small comments otherwise LGTM.

/wait

Copy link
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

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

LGTM with some nits, thanks.

/wait

Copy link
Member

Choose a reason for hiding this comment

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

Please use the default flags function that is already defined, same elsewhere (I already commented on this I think).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure I can use the default function which is defined in access_log_manager_impl.h. file_system_test should not dependent on other implementations .

mattklein123
mattklein123 previously approved these changes Jul 31, 2019
Copy link
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

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

Thanks, LGTM. @jmarantz any further comments?

Copy link
Contributor

@jmarantz jmarantz left a comment

Choose a reason for hiding this comment

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

sorry I should've chimed in earlier; I do have some questions.

Copy link
Contributor

Choose a reason for hiding this comment

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

Declare this method static; it does not appear to require this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks and will do.

Copy link
Contributor

Choose a reason for hiding this comment

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

You reference 'perm' in this PR a few times; can we spell that out? I think it might mean "permanent" but I'm not sure.

Copy link
Contributor Author

@scw00 scw00 Aug 1, 2019

Choose a reason for hiding this comment

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

You mean move this into shared interface . It seems contradictory to previous changes, see
#7445 (comment)

This is also why I make the PermAndFlags into platform implementation.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh it's hard to see exactly what Matt had an issue with because you squashed commits. In general please try to avoid that because we lose the comment history.

I still don't understand the meaning of 'perm'. But looking at how it's used here I retract my "make part of the interface" suggestion, and instead suggest using the correct type and name in posix for the 3rd arg to open: mode_t mode

Copy link
Contributor

Choose a reason for hiding this comment

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

Does it make sense to put FlagsAndPerm in a shared interface, rather than repeating it from win32 and posix?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because the translateFlags method is platform specified function ( the translateFlags is in the platform class not in shared interface). So the implementation should have their own flags and perm or other something more than this two flags.

But currently we only care about the perm and flags, so I'm ok with that . And will change.

Copy link
Contributor

Choose a reason for hiding this comment

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

s/perm/mode/ and s/int/mode_t/ for the mode arg?

Copy link
Contributor

Choose a reason for hiding this comment

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

ah I finally figured out what 'perm' meant by reading the MS docs: https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/open-wopen?view=vs-2019 -- it means "permissions".

but there it's called pmode, not perm.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks and will change

Copy link
Contributor

Choose a reason for hiding this comment

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

pmode

jmarantz
jmarantz previously approved these changes Aug 1, 2019
Copy link
Contributor

Choose a reason for hiding this comment

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

Signed-off-by: cwsong <cwsong@iflytek.com>
@scw00
Copy link
Contributor Author

scw00 commented Aug 1, 2019

/retest

@repokitteh-read-only
Copy link

🤷‍♀️ nothing to rebuild.

🐱

Caused by: a #7445 (comment) was created by @scw00.

see: more, trace.

@dio
Copy link
Member

dio commented Aug 1, 2019

/azp run envoy-macos

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@scw00
Copy link
Contributor Author

scw00 commented Aug 1, 2019

Thanks @dio

@scw00
Copy link
Contributor Author

scw00 commented Aug 2, 2019

Hi @mattklein123 @jmarantz thanks for your comments. And Can I get another approve ?

@jmarantz jmarantz merged commit dd50110 into envoyproxy:master Aug 2, 2019
@scw00
Copy link
Contributor Author

scw00 commented Aug 2, 2019

Thanks

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.

4 participants