gotgt icon indicating copy to clipboard operation
gotgt copied to clipboard

Add support for block device storage endpoints.

Open jeremy-gill opened this issue 3 years ago • 4 comments

gotgt can't export a block device because Stat() is used to determine storage endpoint file size. Stat() reports 0 for block devices. This pull request implements an alternative method of determining storage endpoint size that will works for block devices.

jeremy-gill avatar Sep 04 '20 17:09 jeremy-gill

In the line you added if mode&os.ModeDevice != 0 { != has higher precedence than & Then you mean if mode & (os.ModeDevice != 0) { I doubt that's what you intend to do in the code.

tpaullee avatar Sep 04 '20 19:09 tpaullee

The block of code in question was lifted from the os.ModeDevice example on golang.org (here), and here's an example of the code running in the golang playground link. I'm happy to wrap the code in question with parentheses to reduce confusion but I believe it's correct as is.

jeremy-gill avatar Sep 11 '20 18:09 jeremy-gill

Jeremy, You are right about this. I have my traditional language operator precedence in mind, and with sites like Go - Operators Precedence - Tutorialspoint to misguide, which actually is incorrect against the official Go Language spec The Go Programming Language Specification - The Go Programming Language (search for Operator Precedence). I played with your Playground test code and learned that forcing evaluation order (below) actually causing build to fail! That leads my search to the language spec :-). I am sure that you noticed that too since you commented out those two lines of code.    fmt.Println(file1 & (os.ModeDevice != 0)) I can imagine that strong typing of the Go language necessarily have to enforce a different set of operator precedence.  I learned something, especially what strong typing can mean in a language. Explicit execution enforcement definitely is not necessary although helpful.  Then, the code reader will miss an opportunity to learn something subtle and significant. Best Regards,T.Paul

| | | | The Go Programming Language Specification - The Go Programming Language

Go is an open source programming language that makes it easy to build simple, reliable, and efficient software. |

|

|

 

| | | | | |

|

| | | | Go - Operators Precedence - Tutorialspoint

Go - Operators Precedence - Operator precedence determines the grouping of terms in an expression. This affects ... |

|

|

N 37-17.454 W 121-57.679 http://tpaullee.blogspot.com/ Cultivating Human Goodness

On Friday, September 11, 2020, 11:20:44 AM PDT, Jeremy Gill <[email protected]> wrote:  

The block of code in question was lifted from the os.ModeDevice example on golang.org (here), and here's an example of the code running in the golang playground link. I'm happy to wrap the code in question with parentheses to reduce confusion but I believe it's correct as is.

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub, or unsubscribe.

tpaullee avatar Sep 12 '20 00:09 tpaullee

@jeremy-gill Thanks for your PR, could you please fix the travis-ci issue:

image

carmark avatar Sep 15 '20 11:09 carmark